UNPKG

6.75 kBSCSSView Raw
1//
2// Copyright IBM Corp. 2016, 2018
3//
4// This source code is licensed under the Apache-2.0 license found in the
5// LICENSE file in the root directory of this source tree.
6//
7
8@import '../../globals/scss/vars';
9@import '../../globals/scss/typography';
10@import '../../globals/scss/helper-mixins';
11@import '../../globals/scss/css--helpers';
12@import '../../globals/scss/tooltip';
13@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
14@import 'mixins';
15@import '../../globals/scss/css--reset';
16
17/// Button styles
18/// @access private
19/// @group button
20@mixin button {
21 // button set styles
22 .#{$prefix}--btn-set {
23 display: flex;
24 }
25
26 .#{$prefix}--btn-set--stacked {
27 flex-direction: column;
28 }
29
30 .#{$prefix}--btn-set .#{$prefix}--btn {
31 width: 100%;
32 // 196px from design kit
33 max-width: rem(196px);
34
35 &:not(:focus) {
36 box-shadow: rem(-1px) 0 0 0 $button-separator;
37 }
38
39 &:first-of-type:not(:focus) {
40 box-shadow: inherit;
41 }
42 }
43
44 .#{$prefix}--btn-set .#{$prefix}--btn:focus + .#{$prefix}--btn {
45 box-shadow: inherit;
46 }
47
48 .#{$prefix}--btn-set--stacked .#{$prefix}--btn:not(:focus) {
49 box-shadow: 0 rem(-1px) 0 0 $button-separator;
50 }
51
52 .#{$prefix}--btn-set--stacked .#{$prefix}--btn:first-of-type:not(:focus) {
53 box-shadow: inherit;
54 }
55
56 .#{$prefix}--btn-set .#{$prefix}--btn.#{$prefix}--btn--disabled {
57 box-shadow: rem(-1px) 0 0 0 $disabled-03;
58
59 &:first-of-type {
60 box-shadow: none;
61 }
62 }
63
64 .#{$prefix}--btn-set--stacked .#{$prefix}--btn.#{$prefix}--btn--disabled {
65 box-shadow: 0 rem(-1px) 0 0 $disabled-03;
66
67 &:first-of-type {
68 box-shadow: none;
69 }
70 }
71
72 .#{$prefix}--btn {
73 @include button-base;
74 }
75
76 // Reset intrisic padding in Firefox (see #731)
77 .#{$prefix}--btn::-moz-focus-inner {
78 padding: 0;
79 border: 0;
80 }
81
82 .#{$prefix}--btn--primary {
83 @include button-theme(
84 $interactive-01,
85 transparent,
86 $text-04,
87 $hover-primary,
88 currentColor,
89 $active-primary
90 );
91
92 &:hover {
93 color: $text-04;
94 }
95 }
96
97 .#{$prefix}--btn--secondary {
98 @include button-theme(
99 $interactive-02,
100 transparent,
101 $text-04,
102 $hover-secondary,
103 currentColor,
104 $active-secondary
105 );
106
107 &:hover,
108 &:focus {
109 color: $text-04;
110 }
111 }
112
113 .#{$prefix}--btn--tertiary {
114 @include button-theme(
115 transparent,
116 $interactive-03,
117 $interactive-03,
118 $hover-tertiary,
119 currentColor,
120 $active-tertiary
121 );
122
123 &:hover {
124 color: $inverse-01;
125 }
126
127 &:focus {
128 color: $inverse-01;
129 background-color: $interactive-03;
130 }
131
132 &:active {
133 border-color: transparent;
134 }
135
136 &:disabled,
137 &:hover:disabled,
138 &:focus:disabled,
139 &.#{$prefix}--btn--disabled,
140 &.#{$prefix}--btn--disabled:hover,
141 &.#{$prefix}--btn--disabled:focus {
142 color: $disabled;
143 background: transparent;
144 outline: none;
145 }
146 }
147
148 .#{$prefix}--btn--ghost {
149 @include button-theme(
150 transparent,
151 transparent,
152 $link-01,
153 $hover-ui,
154 currentColor,
155 $active-ui
156 );
157
158 padding: $button-padding-ghost;
159
160 .#{$prefix}--btn__icon {
161 position: static;
162 margin-left: $carbon--spacing-03;
163 }
164
165 &:hover,
166 &:active {
167 color: $hover-primary-text;
168 }
169
170 &:active {
171 background-color: $active-ui;
172 }
173
174 &:disabled,
175 &:hover:disabled,
176 &:focus:disabled,
177 &.#{$prefix}--btn--disabled,
178 &.#{$prefix}--btn--disabled:hover,
179 &.#{$prefix}--btn--disabled:focus {
180 color: $disabled;
181 background: transparent;
182 border-color: transparent;
183 outline: none;
184 }
185
186 &.#{$prefix}--btn--sm {
187 padding: $button-padding-ghost-sm;
188 }
189
190 &.#{$prefix}--btn--field {
191 padding: $button-padding-ghost-field;
192 }
193 }
194
195 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger {
196 @include tooltip--trigger('icon', 'bottom');
197
198 svg,
199 &:hover svg,
200 &:focus svg {
201 fill: currentColor;
202 }
203 }
204
205 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--btn--ghost:focus svg {
206 fill: $icon-01;
207 }
208
209 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--btn--ghost:hover svg {
210 fill: $icon-01;
211 }
212
213 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger:focus {
214 border-color: $focus;
215 }
216
217 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger:focus
218 svg {
219 outline-color: transparent;
220 }
221
222 .#{$prefix}--btn--icon-only--top {
223 @include tooltip--trigger('icon', 'top');
224 @include tooltip--placement('icon', 'top', 'center');
225 }
226
227 .#{$prefix}--btn--icon-only--bottom {
228 @include tooltip--placement('icon', 'bottom', 'center');
229 }
230
231 .#{$prefix}--btn--icon-only {
232 padding-right: rem(15px);
233 padding-left: rem(15px);
234
235 .#{$prefix}--btn__icon {
236 position: static;
237 }
238
239 &.#{$prefix}--btn--ghost .#{$prefix}--btn__icon {
240 margin: 0;
241 }
242 }
243
244 .#{$prefix}--btn path[data-icon-path='inner-path'] {
245 fill: none;
246 }
247
248 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--btn--ghost
249 .#{$prefix}--btn__icon,
250 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--btn--ghost:hover
251 .#{$prefix}--btn__icon {
252 fill: $icon-01;
253 }
254
255 .#{$prefix}--btn--ghost.#{$prefix}--btn--icon-only
256 .#{$prefix}--btn__icon
257 path,
258 .#{$prefix}--btn--ghost.#{$prefix}--btn--icon-only .#{$prefix}--btn__icon {
259 fill: $icon-01;
260 }
261
262 .#{$prefix}--btn--ghost.#{$prefix}--btn--icon-only[disabled]
263 .#{$prefix}--btn__icon
264 path,
265 .#{$prefix}--btn--ghost.#{$prefix}--btn--icon-only[disabled]
266 .#{$prefix}--btn__icon,
267 .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--btn--ghost[disabled]:hover
268 .#{$prefix}--btn__icon {
269 fill: $disabled-02;
270 }
271
272 .#{$prefix}--btn--ghost.#{$prefix}--btn--icon-only[disabled] {
273 cursor: not-allowed;
274 }
275
276 .#{$prefix}--btn--field.#{$prefix}--btn--icon-only {
277 padding-right: rem(11px);
278 padding-left: rem(11px);
279 }
280
281 .#{$prefix}--btn--sm.#{$prefix}--btn--icon-only {
282 padding-right: rem(7px);
283 padding-left: rem(7px);
284 }
285
286 .#{$prefix}--btn--danger {
287 @include button-theme(
288 $danger,
289 transparent,
290 $text-04,
291 $hover-danger,
292 currentColor,
293 $active-danger
294 );
295
296 &:hover {
297 color: $text-04;
298 }
299 }
300
301 .#{$prefix}--btn--sm {
302 min-height: rem(32px);
303 padding: $button-padding-sm;
304 }
305
306 .#{$prefix}--btn--field {
307 min-height: rem(40px);
308 padding: $button-padding-field;
309 }
310
311 // Skeleton State
312 .#{$prefix}--btn.#{$prefix}--skeleton {
313 @include skeleton;
314
315 width: rem(150px);
316 }
317}
318
319@include exports('button') {
320 @include button;
321}