-
Notifications
You must be signed in to change notification settings - Fork 1
/
_main.scss
133 lines (97 loc) · 4.11 KB
/
_main.scss
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
// Initialise config
@mixin windbreakercss($config) {
// Variables
$separator: map-get($config, separator);
$utilities: map-get($config, utilities);
$breakpoints: map-get($config, breakpoints);
// Go through all the utilities and generate classes
@each $key, $utility in $utilities {
@include windbreakercss-utility($utility, $separator);
@if type-of($breakpoints) == 'map' and map-get($utility, responsive) == true {
@each $bp, $size in $breakpoints {
@media screen and (min-width: $size) {
@include windbreakercss-utility($utility, $separator, $bp);
}
}
}
}
}
// Output the css
@mixin windbreakercss-output($selector, $property, $value, $important: false) {
$important-value: '';
@if $important == true {
$important-value: ' !important';
}
#{$selector} {
@if type-of($value) == 'map' {
@each $p, $v in $value {
@if type-of($v) == 'string' {
#{$p}: #{unquote($v) + $important-value};
} @else {
#{$p}: #{$v + $important-value};
}
}
} @else if type-of($value) == 'string' {
#{$property}: #{unquote($value) + $important-value};
} @else {
#{$property}: #{$value + $important-value};
}
}
}
// Create utility
@mixin windbreakercss-utility($config, $separator, $key: '') {
// Variables
$prefix: map-get($config, prefix);
$dark-mode: map-get($config, dark-mode);
$group: map-get($config, group);
$property: map-get($config, property);
$states: map-get($config, states);
// Create the prefix
@if $key != '' {
$key: $separator + $key;
}
// Go through each value
@each $name, $value in map-get($config, values) {
// Create the standard classes
$selector: '.' + $prefix + $name + $key;
// Add state classes
@if type-of($states) == 'list' {
@each $state in $states {
$selector: $selector + ', .' + $state + $separator + $prefix + $name + $key + ':' + $state;
}
} @else if type-of($states) == 'string' {
$selector: $selector + ', .' + $states + $separator + $prefix + $name + $key + ':' + $states;
}
// Add group classes
@if type-of($group) == 'list' {
@each $state in $group {
$selector: $selector + ', .group:' + $state + ' .group' + $separator + $state + $separator + $prefix + $name + $key;
}
} @else if type-of($group) == 'string' {
$selector: $selector + ', .group:' + $group + ' .group' + $separator + $group + $separator + $prefix + $name + $key;
}
@include windbreakercss-output($selector, $property, $value);
// Add dark classes
@if $dark-mode == true {
// Add standard class
$selector: '.dark .' + $prefix + $name + $separator + 'dark' + $key;
// Add state classes
@if type-of($states) == 'list' {
@each $state in $states {
$selector: $selector + ', .dark .' + $state + $separator + $prefix + $name + $separator + 'dark' + $key + ':' + $state;
}
} @else if type-of($states) == 'string' {
$selector: $selector + ', .dark .' + $states + $separator + $prefix + $name + $separator + 'dark' + $key + ':' + $states;
}
// Add group classes
@if type-of($group) == 'list' {
@each $state in $group {
$selector: $selector + ', .dark .group:' + $state + ' .group' + $separator + $state + $separator + $prefix + $name + $separator + 'dark' + $key;
}
} @else if type-of($group) == 'string' {
$selector: $selector + ', .dark .group:' + $group + ' .group' + $separator + $group + $separator + $prefix + $name + $separator + 'dark' + $key;
}
@include windbreakercss-output($selector, $property, $value, true);
}
}
}