UNPKG

4.32 kBSCSSView Raw
1@import '../../css/variables';
2@import '../../css/mixins';
3@import 'css/variables';
4@import 'css/colors';
5@import 'css/sizes';
6
7/**
8 * Button
9 */
10.button {
11 display: inline-flex;
12 font-weight: var(----font-weight);
13 font-size: var(----font-size);
14 line-height: var(----line-height);
15 text-align: center;
16 white-space: nowrap;
17 vertical-align: middle;
18 user-select: none;
19 border-style: var(----border-style);
20 border-width: var(----border-width);
21 border-color: var(----border-color);
22 border-radius: var(----border-radius);
23 box-shadow: var(----box-shadow);
24 padding: var(----padding);
25 justify-content: center;
26 align-items: center;
27 transition-property: background-color, border-color, color;
28 transition-duration: var(--transition-duration);
29 transition-timing-function: var(--transition-easing);
30 color: var(----color);
31 background: var(----background);
32
33 // Target non disabled buttons
34 &:not(:disabled):not(.-disabled) {
35 // Add "hand" cursor to non-disabled .button elements
36 cursor: pointer;
37
38 // Focus and hover state
39 &:hover,
40 &:focus,
41 &.-hovered,
42 &.-focused {
43 ----background: var(----background--hover);
44 ----border-color: var(----border-color--hover);
45 text-decoration: none;
46 color: var(----color);
47 outline: 0;
48 }
49
50 &:active,
51 &.-active {
52 ----background: var(----background--active);
53 }
54 }
55
56 // Disabled state
57 // Disabled state comes first so active can properly restyle
58 &.-disabled,
59 &:disabled {
60 opacity: var(----opacity--disabled);
61 box-shadow: none;
62 }
63
64 // Block buttons
65 // Make buttons span the whole parent width
66 &.-block {
67 display: block;
68 width: 100%;
69
70 + .button.-block {
71 margin-left: 0;
72 margin-top: var(----block--margin);
73 }
74 }
75
76 // Link buttons
77 // Make a button look and behave like a link
78 &.-link {
79 ----color: var(----link--color);
80 box-shadow: none;
81 background-color: transparent;
82 border-color: transparent;
83
84 &:not(:disabled):not(.-disabled) {
85 &:hover,
86 &:focus,
87 &:active,
88 &.-hovered,
89 &.-focused,
90 &.-active {
91 ----color: var(----link--color--active);
92 background-color: transparent;
93 border-color: transparent;
94 box-shadow: none;
95 text-decoration: underline;
96 }
97 }
98
99 &:disabled,
100 &.-disabled {
101 pointer-events: none;
102 }
103 }
104
105 // Outline buttons
106 // Remove button background and add a beautiful transition on hover
107 &.-outline {
108 background: transparent;
109 color: var(----background);
110 border-color: var(----background);
111 ----box-shadow: none;
112
113 &:not(:disabled):not(.-disabled) {
114 &:hover,
115 &:focus,
116 &:active,
117 &.-hovered,
118 &.-focused,
119 &.-active {
120 ----border-color: var(----border-color--hover);
121 background: var(----background);
122 color: var(----color);
123 }
124 }
125 }
126
127 // Circle button
128 &.-circle {
129 ----border-radius: 100%;
130 width: var(----circle--size);
131 height: var(----circle--size);
132 padding: 0;
133 }
134
135 .loader {
136 margin-top: spacing('1/4');
137 margin-bottom: spacing('1/4');
138 width: var(----font-size);
139 height: var(----font-size);
140
141 > svg > circle {
142 stroke: var(----color) !important;
143 }
144 }
145
146 //
147 // Button group border accent
148 //
149
150 .button-group:not(.-vertical) > &:not(:first-child) {
151 ----border-left-color: var(----background--hover);
152 }
153
154 .button-group.-vertical > &:not(:first-child) {
155 ----border-top-color: var(----background--hover);
156 }
157}
158
159// Future-proof disabling of clicks on `<a>` elements
160a.button.-disabled,
161*:disabled a.button {
162 pointer-events: none;
163}
164
165// Specificity overrides
166input[type="submit"],
167input[type="reset"],
168input[type="button"] {
169 &.-block {
170 width: 100%;
171 }
172}