forked from leafo/scssphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.scss
More file actions
175 lines (139 loc) · 2.49 KB
/
functions.scss
File metadata and controls
175 lines (139 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
@function hello($x) {
@return $x + 4;
}
@function add($a, $b) {
@return $a + $b;
}
div {
color: hello(10px);
sum: add(11, 12);
}
// make sure values are being reduced before being passed up to previous scope
@function one($a, $b) {
@return $a $b;
}
@function two($a, $b) {
@return $a#{$a} $b;
}
@function three($a, $b: default) {
@return "hello #{$a} and #{$b}"
}
@function all($a...) {
@return "hello #{$a}"
}
div {
hello: one(10, 55);
hello: two(10, 55);
hello: three(10, 55);
}
@function hello_world() {
@return 1000;
}
del {
color: hello-world();
}
div {
$args: foo bar;
hello: three($args...);
hello: three(bar...);
hello: all(Alice, Bob, Tom);
}
@function stringConcatCompassStyle($start,$last)
{
// Compass still uses it like this
@return #{$start}-#{$last};
}
.foo
{
test2: stringConcatCompassStyle(-moz,art);
}
@mixin content_test {
span {
$color: green;
@content;
}
}
@function func_test($c) {
@return $c + 1;
}
div {
@include content_test {
height: func_test(2px);
}
}
@function test ($a, $b: $a/2) {
@return $b;
}
div {
width: test(4);
}
@function test($args...){
@return type-of($args); // should return arglist, but returns list
}
p{
color: test("a", "s", "d", "f");
}
@function test-function() {
$str: 'test-function';
@return $str;
}
@mixin test-mixin {
$str: 'test-mixin';
display: $str;
$new-bp: test-function();
display: $str;
}
$str: 'global';
.test{
display: $str;
@include test-mixin;
display: $str;
}
.test-inspect {
n: inspect(null);
b1: inspect(true);
b2: inspect(false);
n1: inspect(0);
s1: inspect('');
s2: inspect('hello');
l1: inspect(1 2);
l2: inspect((3 4));
l3: inspect((5,6));
l4: inspect((a: 1, b: 2));
l5: inspect($value: (a: 1, b: 2));
}
@function contains($list, $values...) {
@each $value in $values {
@if type-of(index($list, $value)) != "number" {
@return false;
}
}
@return true;
}
@function mapping($items) {
$src: ();
$map: (
one: 1px 1px,
two: 2px 2px,
);
@each $key, $values in $map {
@if contains($items, $key) {
$value1: nth($values, 1);
$value2: nth($values, 2);
$src: append($src, $value1 $value2, space);
}
}
@return $src;
}
@mixin test() {
padding: mapping(one two);
}
div {
margin: mapping(one two);
@include test();
}
$a: rgba(#000, 0.5);
$b: rgba(#fff, 0.75);
.test {
color: mix($a, $b);
}