UNPKG

1.94 kBSCSSView Raw
1@import "restyle";
2
3// define our UI element...
4@include restyle-define(button, (
5 // Note that this is different from a Sass $variable. The Sass $variable will
6 // be evaluated at definition time, whereas the special restyle variable is
7 // evaluated at invocation time. This is important for the cascading
8 // behavior of modifiers/states
9 '@restyle.var border-color': #3079ed,
10
11 display: inline-block,
12 padding: 5px 10px,
13 font-weight: bold,
14 text-align: center,
15 vertical-align: middle,
16 border: 1px solid '@var.border-color',
17 border-radius: 2px,
18 background-color: #4787ed,
19 color: #fff,
20 cursor: pointer,
21
22 '@restyle.states': (
23 hover: (
24 background-color: #357ae8,
25 border-color: #2f5bb7
26 ),
27
28 disabled: (
29 border-color: '@var.border-color',
30 // note that we can reference other values within the definition
31 background-color: '@root.background-color',
32 color: '@root.color',
33 opacity: 0.8,
34 cursor: default
35 )
36 ),
37 '@restyle.modifiers': (
38 secondary: (
39 '@restyle.var border-color': rgba(0, 0, 0, 0.1),
40 border: 1px solid '@var.border-color',
41 background-color: #f5f5f5,
42 color: #444,
43
44 '@restyle.states': (
45 hover: (
46 background-color: #e0e0e0,
47 border-color: null,
48 color: #333
49 )
50 )
51 ),
52
53 close: (
54 '@restyle.alias': close-button
55 ),
56
57 close-inherit: (
58 '@restyle.inherit': close
59 )
60 )
61));
62
63@include restyle-define(close-button, (
64 close-button: true
65));
66
67// register the states (note that this would be a "per app" configuration)
68@include restyle-add-state((
69 hover: '&:hover',
70 disabled: '&[disabled]'
71));
72
73// ...
74
75// now invoke it...
76.btn {
77 @include restyle(button);
78 &.secondary {
79 @include restyle(secondary button);
80 }
81}
82
83.btn-close {
84 @include restyle(close button);
85}
86
87.btn-close-inherit {
88 @include restyle(close-inherit button);
89}