|
12 | 12 |
|
13 | 13 | // Modules.
|
14 | 14 | @use '../../function';
|
| 15 | +@use '../../map'; |
15 | 16 | @use '../../values';
|
16 | 17 |
|
17 | 18 | // Status: DONE
|
|
20 | 21 | // @param `$pseudo-class` Pseudo class for class `$variant`.
|
21 | 22 | // @param `$dictionary` Dictionary to translate class `$variant`.
|
22 | 23 | // @param `$function` The function to set class `$variant`.
|
| 24 | +// @param `$modifier` |
23 | 25 | @mixin variant(
|
24 | 26 | $variant,
|
25 | 27 | $pseudo-class: (),
|
|
47 | 49 | }
|
48 | 50 | @if type-of($attribute-variant) == map {
|
49 | 51 | @each $attribute, $variant in $attribute-variant {
|
| 52 | + // TODO: Remove in future. |
50 | 53 | @if type-of($attribute) == map {
|
51 | 54 | @each $key, $value in $attribute {
|
52 | 55 | $attribute: nest($key, $value);
|
|
61 | 64 | @include class.content(
|
62 | 65 | values.join(
|
63 | 66 | if(&, '&', ()),
|
| 67 | + map.get($modifier, (class, prefix), null), |
64 | 68 | $class,
|
65 | 69 | $attribute,
|
66 |
| - if(list.separator($value-class) == comma, ($value-class,), $value-class) |
| 70 | + map.get($modifier, (class, attribute), null), |
| 71 | + if(list.separator($value-class) == comma, ($value-class,), $value-class), |
| 72 | + map.get($modifier, (class, suffix), null), |
67 | 73 | ),
|
68 | 74 | $pseudo-class,
|
69 | 75 | $dictionary,
|
70 | 76 | $function,
|
71 | 77 | ) {
|
72 |
| - $values: ($class, $property or $class, $attribute, $value-class, $value, ($value-class: $value)); |
| 78 | + // Set property. |
| 79 | + $-property: $property or $class; |
| 80 | + @if $modifier { |
| 81 | + @if list.separator($-property) == comma { |
| 82 | + $i: 1; |
| 83 | + @each $base in $-property { |
| 84 | + $-property: list.set-nth( |
| 85 | + $-property, |
| 86 | + $i, |
| 87 | + values.join( |
| 88 | + map.get($modifier, (property, name), null), |
| 89 | + $base, |
| 90 | + $attribute, |
| 91 | + map.get($modifier, (property, attribute), null), |
| 92 | + ) |
| 93 | + ); |
| 94 | + $i: $i + 1; |
| 95 | + } |
| 96 | + } @else { |
| 97 | + $-property: values.join( |
| 98 | + map.get($modifier, (property, name), null), |
| 99 | + $-property, |
| 100 | + $attribute, |
| 101 | + map.get($modifier, (property, attribute), null), |
| 102 | + ); |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + $values: ($class, $-property, $attribute, $value-class, $value, ($value-class: $value)); |
73 | 107 | $content: if(
|
74 | 108 | $content-type == map,
|
75 | 109 | to-map($values, $content-keys...),
|
|
90 | 124 | @each $attribute in if(list.separator($attribute) == comma, $attribute, ($attribute,)) {
|
91 | 125 | $value-class: $attribute;
|
92 | 126 | @include class.content(
|
93 |
| - values.join(if(&, '&', ()), $class, $value-class), |
| 127 | + values.join( |
| 128 | + if(&, '&', ()), |
| 129 | + map.get($modifier, (class, prefix), null), |
| 130 | + $class, |
| 131 | + map.get($modifier, (class, attribute), null), |
| 132 | + $value-class, |
| 133 | + map.get($modifier, (class, suffix), null), |
| 134 | + ), |
94 | 135 | $pseudo-class,
|
95 | 136 | $dictionary,
|
96 | 137 | $function,
|
97 | 138 | ) {
|
98 |
| - $values: ($class, $property or $class, null, $value-class, $value, ($value-class: $value)); |
| 139 | + // Set property. |
| 140 | + $-property: $property or $class; |
| 141 | + @if $modifier { |
| 142 | + @if list.separator($-property) == comma { |
| 143 | + $i: 1; |
| 144 | + @each $base in $-property { |
| 145 | + $-property: list.set-nth( |
| 146 | + $-property, |
| 147 | + $i, |
| 148 | + values.join( |
| 149 | + map.get($modifier, (property, name), null), |
| 150 | + $base, |
| 151 | + map.get($modifier, (property, attribute), null), |
| 152 | + ) |
| 153 | + ); |
| 154 | + $i: $i + 1; |
| 155 | + } |
| 156 | + } @else { |
| 157 | + $-property: values.join( |
| 158 | + map.get($modifier, (property, name), null), |
| 159 | + $-property, |
| 160 | + map.get($modifier, (property, attribute), null), |
| 161 | + ); |
| 162 | + } |
| 163 | + } |
| 164 | + |
| 165 | + $values: ($class, $-property, null, $value-class, $value, ($value-class: $value)); |
99 | 166 | $arguments: if(
|
100 | 167 | $content-type == map,
|
101 | 168 | to-map($values, $content-keys...),
|
|
114 | 181 | }
|
115 | 182 | } @else {
|
116 | 183 | // FEATURE: Works fine.
|
| 184 | + // `variant.class-value()` |
117 | 185 | @each $value in if(list.separator($attribute-variant) == comma, $attribute-variant, ($attribute-variant,)) {
|
118 | 186 | @each $class in if(list.separator($class) == comma, $class, ($class,)) {
|
119 | 187 | @include class.content(
|
120 |
| - values.join(if(&, '&', ()), $class), |
| 188 | + values.join( |
| 189 | + if(&, '&', ()), |
| 190 | + map.get($modifier, (class, prefix), null), |
| 191 | + $class, |
| 192 | + map.get($modifier, (class, attribute), null), |
| 193 | + map.get($modifier, (class, suffix), null), |
| 194 | + ), |
121 | 195 | $pseudo-class,
|
122 | 196 | $dictionary,
|
123 | 197 | $function
|
124 | 198 | ) {
|
| 199 | + // Set property. |
| 200 | + $-property: $property or $class; |
| 201 | + @if $modifier { |
| 202 | + @if list.separator($-property) == comma { |
| 203 | + $i: 1; |
| 204 | + @each $base in $-property { |
| 205 | + $-property: list.set-nth( |
| 206 | + $-property, |
| 207 | + $i, |
| 208 | + values.join( |
| 209 | + (separator: space), |
| 210 | + map.get($modifier, (property, name), null), |
| 211 | + $base, |
| 212 | + map.get($modifier, (property, attribute), null), |
| 213 | + ) |
| 214 | + ); |
| 215 | + $i: $i + 1; |
| 216 | + } |
| 217 | + } @else { |
| 218 | + $-property: values.join( |
| 219 | + (separator: space), |
| 220 | + map.get($modifier, (property, name), null), |
| 221 | + $-property, |
| 222 | + map.get($modifier, (property, attribute), null), |
| 223 | + ); |
| 224 | + } |
| 225 | + } |
| 226 | + |
| 227 | + // Set `$arguments` for `@content`. |
125 | 228 | $arguments: if(
|
126 | 229 | $content-type == map,
|
127 |
| - to-map(($class, $property or $class, $value), $content-keys...), |
128 |
| - values.combine((separator: comma), $class, $property or $class, $value) |
| 230 | + to-map(($class, $-property, $value), $content-keys...), |
| 231 | + values.combine((separator: comma), $class, $-property, $value) |
129 | 232 | );
|
130 | 233 | @if type-of($arguments) == list {
|
131 | 234 | @content($arguments...);
|
|
0 commit comments