1 | @import "restyle";
|
2 |
|
3 | @function number($str) {
|
4 | $nums: (
|
5 | '0': 0,
|
6 | '1': 1,
|
7 | '2': 2,
|
8 | '3': 3,
|
9 | '4': 4,
|
10 | '5': 5,
|
11 | '6': 6,
|
12 | '7': 7,
|
13 | '8': 8,
|
14 | '9': 9
|
15 | );
|
16 | @return map-get($nums, $str);
|
17 | }
|
18 |
|
19 | @function get-width($numCols) {
|
20 | @return (
|
21 | width: percentage(1 / number($numCols))
|
22 | );
|
23 | }
|
24 |
|
25 | @include restyle-define(test, (
|
26 | columns: none,
|
27 | restyle-modifiers: (
|
28 | '{cols}-column': (
|
29 | columns: restyle-var(cols),
|
30 | restyle-function(get-width): restyle-var(cols)
|
31 | ),
|
32 | '{rows}-rows': (
|
33 | rows: restyle-var(rows)
|
34 | ),
|
35 | 'disabled-{is-disabled}': (
|
36 | disabled: restyle-var(is-disabled)
|
37 | ),
|
38 | '{cols}x{rows}': (
|
39 | rows: restyle-var(rows),
|
40 | columns: restyle-var(cols),
|
41 | ),
|
42 | '{foo}-bar': (
|
43 | foo: restyle-var(foo)
|
44 | )
|
45 | )
|
46 | ));
|
47 |
|
48 | .test {
|
49 | @include restyle(test);
|
50 |
|
51 | &.cols-2 {
|
52 | @include restyle(2-column test);
|
53 | }
|
54 | &.cols-4 {
|
55 | @include restyle(4-column test);
|
56 | }
|
57 | &.4x3 {
|
58 | @include restyle(4x3 test);
|
59 | }
|
60 | &.2x2 {
|
61 | @include restyle(2x2 test);
|
62 | }
|
63 | &.4x4.foo-bar {
|
64 | @include restyle(4x4 foo-bar test);
|
65 | }
|
66 |
|
67 |
|
68 | &.is-disabled {
|
69 | @include restyle(disabled-true test);
|
70 | }
|
71 | &.is-not-disabled {
|
72 | @include restyle(disabled-false test);
|
73 | }
|
74 | }
|