-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
style.scss
350 lines (296 loc) · 8.54 KB
/
style.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
.components-button {
display: inline-flex;
text-decoration: none;
font-family: inherit;
font-weight: normal;
font-size: $default-font-size;
margin: 0;
border: 0;
cursor: pointer;
-webkit-appearance: none;
background: none;
transition: box-shadow 0.1s linear;
@include reduce-motion("transition");
height: $button-size;
align-items: center;
box-sizing: border-box;
padding: 6px 12px;
border-radius: $radius-block-ui;
color: $components-color-foreground;
&.is-next-40px-default-size {
height: $button-size-next-default-40px;
}
&[aria-expanded="true"],
&:hover {
color: $components-color-accent;
}
// Unset some hovers, instead of adding :not specificity.
&:disabled:hover,
&[aria-disabled="true"]:hover {
color: initial;
}
// Focus.
// See https://github.com/WordPress/gutenberg/issues/13267 for more context on these selectors.
&:focus:not(:disabled) {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 3px solid transparent;
}
/**
* Primary button style.
*/
&.is-primary {
white-space: nowrap;
background: $components-color-accent;
color: $components-color-accent-inverted;
text-decoration: none;
text-shadow: none;
// Show the boundary of the button, in High Contrast Mode.
outline: 1px solid transparent;
&:hover:not(:disabled) {
background: $components-color-accent-darker-10;
color: $components-color-accent-inverted;
}
&:active:not(:disabled) {
background: $components-color-accent-darker-20;
border-color: $components-color-accent-darker-20;
color: $components-color-accent-inverted;
}
&:focus:not(:disabled) {
box-shadow: inset 0 0 0 1px $components-color-background, 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
}
&:disabled,
&:disabled:active:enabled,
&[aria-disabled="true"],
&[aria-disabled="true"]:enabled, // This catches a situation where a Button is aria-disabled, but not disabled.
&[aria-disabled="true"]:active:enabled {
// TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
color: rgba($white, 0.4);
background: $components-color-accent;
border-color: $components-color-accent;
opacity: 1;
outline: none;
&:focus:enabled {
box-shadow:
0 0 0 $border-width $components-color-background,
0 0 0 3px $components-color-accent;
}
}
&.is-busy,
&.is-busy:disabled,
&.is-busy[aria-disabled="true"] {
color: $components-color-accent-inverted;
background-size: 100px 100%;
// Disable reason: This function call looks nicer when each argument is on its own line.
/* stylelint-disable */
background-image: linear-gradient(
-45deg,
$components-color-accent 33%,
$components-color-accent-darker-20 33%,
$components-color-accent-darker-20 70%,
$components-color-accent 70%
);
/* stylelint-enable */
border-color: $components-color-accent;
}
}
/**
* Secondary and tertiary buttons.
*/
&.is-secondary,
&.is-tertiary {
// Show the boundary of the button, in High Contrast Mode.
outline: 1px solid transparent;
&:active:not(:disabled) {
box-shadow: none;
}
&:disabled,
&[aria-disabled="true"],
&[aria-disabled="true"]:hover {
color: $gray-600;
background: transparent;
transform: none;
opacity: 1;
box-shadow: none;
outline: none;
}
}
/**
* Secondary button style.
*/
&.is-secondary {
box-shadow: inset 0 0 0 $border-width $components-color-accent;
outline: 1px solid transparent; // Shown in high contrast mode.
white-space: nowrap;
color: $components-color-accent;
background: transparent;
&:hover:not(:disabled, [aria-disabled="true"]) {
box-shadow: inset 0 0 0 $border-width $components-color-accent-darker-10;
}
}
/**
* Tertiary buttons.
*/
&.is-tertiary {
white-space: nowrap;
color: $components-color-accent;
background: transparent;
&:hover:not(:disabled, [aria-disabled="true"]) {
// TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
}
&:active:not(:disabled, [aria-disabled="true"]) {
// TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
}
// Pull left if the tertiary button stands alone after a description, so as to vertically align with items above.
p + & {
margin-left: -($grid-unit-15 * 0.5);
}
}
/**
* Destructive buttons.
*/
&.is-destructive {
--wp-components-color-accent: #{$alert-red};
--wp-components-color-accent-darker-10: #{darken($alert-red, 10%)};
--wp-components-color-accent-darker-20: #{darken($alert-red, 20%)};
// Only the default variant is styled differently from the non-destructive counterparts.
&:not(.is-primary):not(.is-secondary):not(.is-tertiary):not(.is-link) {
color: $alert-red;
&:hover:not(:disabled) {
color: darken($alert-red, 20%);
}
&:focus:not(:disabled) {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $alert-red;
}
&:active:not(:disabled) {
background: $gray-400;
}
}
}
/**
* Link buttons.
*/
&.is-link {
margin: 0;
padding: 0;
box-shadow: none;
border: 0;
border-radius: 0;
background: none;
outline: none;
text-align: left;
color: $components-color-accent;
text-decoration: underline;
transition-property: border, background, color;
transition-duration: 0.05s;
transition-timing-function: ease-in-out;
@include reduce-motion("transition");
height: auto;
&:focus {
border-radius: $radius-block-ui;
}
}
&:not(:disabled, [aria-disabled="true"]):active {
color: $components-color-foreground;
}
&:disabled,
&[aria-disabled="true"] {
cursor: default;
opacity: 0.3;
}
&.is-busy,
&.is-secondary.is-busy,
&.is-secondary.is-busy:disabled,
&.is-secondary.is-busy[aria-disabled="true"] {
animation: components-button__busy-animation 2500ms infinite linear;
opacity: 1;
background-size: 100px 100%;
// Disable reason: This function call looks nicer when each argument is on its own line.
/* stylelint-disable */
background-image: linear-gradient(
-45deg,
// TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
darken($white, 2%) 33%,
darken($white, 12%) 33%,
darken($white, 12%) 70%,
darken($white, 2%) 70%
);
/* stylelint-enable */
}
&.is-compact {
height: $button-size-compact;
&.has-icon:not(.has-text) {
padding: 0;
width: $button-size-compact;
min-width: $button-size-compact;
}
}
&.is-small {
height: $button-size-small;
line-height: 22px;
padding: 0 8px;
font-size: 11px;
&.has-icon:not(.has-text) {
padding: 0;
width: $button-size-small;
min-width: $button-size-small;
}
}
&.has-icon {
padding: 6px; // Works for 24px icons. Smaller icons are vertically centered by flex alignments.
// Icon buttons are square.
min-width: $button-size;
justify-content: center;
&.is-next-40px-default-size {
min-width: $button-size-next-default-40px;
}
.dashicon {
display: inline-flex;
justify-content: center;
align-items: center;
padding: 2px;
box-sizing: content-box;
}
&.has-text {
justify-content: start;
padding-right: $grid-unit-15;
padding-left: $grid-unit-10;
gap: $grid-unit-05;
}
}
// Toggled style.
&.is-pressed {
color: $components-color-foreground-inverted;
background: $components-color-foreground;
&:focus:not(:disabled) {
box-shadow: inset 0 0 0 1px $components-color-background, 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent;
}
&:hover:not(:disabled) {
color: $components-color-foreground-inverted;
background: $components-color-foreground;
}
}
svg {
fill: currentColor;
outline: none;
// Optimizate for high contrast modes.
// See also https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/.
@media (forced-colors: active) {
fill: CanvasText;
}
}
// Fixes a Safari+VoiceOver bug, where the screen reader text is announced not respecting the source order.
// See https://core.trac.wordpress.org/ticket/42006 and https://github.com/h5bp/html5-boilerplate/issues/1985
.components-visually-hidden {
height: auto;
}
}
@keyframes components-button__busy-animation {
0% {
background-position: 200px 0;
}
}