-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
style.scss
369 lines (309 loc) · 8.15 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
.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: $gray-900;
&[aria-expanded="true"],
&:hover {
color: var(--wp-admin-theme-color);
}
// Unset some hovers, instead of adding :not specificity.
&[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) var(--wp-admin-theme-color);
// 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: var(--wp-admin-theme-color);
color: $white;
text-decoration: none;
text-shadow: none;
// Show the boundary of the button, in High Contrast Mode.
outline: 1px solid transparent;
&:hover:not(:disabled) {
background: var(--wp-admin-theme-color-darker-10);
color: $white;
}
&:active:not(:disabled) {
background: var(--wp-admin-theme-color-darker-20);
border-color: var(--wp-admin-theme-color-darker-20);
color: $white;
}
&:focus:not(:disabled) {
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
}
&: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 {
color: rgba($white, 0.4);
background: var(--wp-admin-theme-color);
border-color: var(--wp-admin-theme-color);
opacity: 1;
outline: none;
&:focus:enabled {
box-shadow:
0 0 0 $border-width $white,
0 0 0 3px var(--wp-admin-theme-color);
}
}
&.is-busy,
&.is-busy:disabled,
&.is-busy[aria-disabled="true"] {
color: $white;
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,
var(--wp-admin-theme-color) 33%,
var(--wp-admin-theme-color-darker-20) 33%,
var(--wp-admin-theme-color-darker-20) 70%,
var(--wp-admin-theme-color) 70%
);
/* stylelint-enable */
border-color: var(--wp-admin-theme-color);
}
}
/**
* 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) {
background: $gray-300;
color: var(--wp-admin-theme-color-darker-10);
box-shadow: none;
}
&:hover:not(:disabled) {
color: var(--wp-admin-theme-color-darker-10);
box-shadow: inset 0 0 0 $border-width var(--wp-admin-theme-color-darker-10);
}
&:disabled,
&[aria-disabled="true"],
&[aria-disabled="true"]:hover {
color: lighten($gray-700, 5%);
background: lighten($gray-300, 5%);
transform: none;
opacity: 1;
box-shadow: none;
outline: none;
}
}
/**
* Secondary button style.
*/
&.is-secondary {
box-shadow: inset 0 0 0 $border-width var(--wp-admin-theme-color);
outline: 1px solid transparent; // Shown in high contrast mode.
white-space: nowrap;
color: var(--wp-admin-theme-color);
background: transparent;
}
/**
* Tertiary buttons.
*/
&.is-tertiary {
white-space: nowrap;
color: var(--wp-admin-theme-color);
background: transparent;
padding: $grid-unit-15 * 0.5; // This reduces the horizontal padding on tertiary/text buttons, so as to space them optically.
.dashicon {
display: inline-block;
flex: 0 0 auto;
}
// 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 {
color: $alert-red;
box-shadow: inset 0 0 0 $border-width $alert-red;
&:hover:not(:disabled) {
color: darken($alert-red, 20%);
box-shadow: inset 0 0 0 $border-width darken($alert-red, 20%);
}
&:focus:not(:disabled) {
color: var(--wp-admin-theme-color);
}
&:active:not(:disabled) {
background: $gray-400;
}
}
&.is-destructive.is-primary {
color: #fff;
background: $alert-red;
box-shadow: inset 0 0 0 $border-width $alert-red;
&:hover:not(:disabled) {
color: #fff;
background: darken($alert-red, 20%);
box-shadow: inset 0 0 0 $border-width darken($alert-red, 20%);
}
}
&.is-destructive.is-tertiary {
box-shadow: none;
&:hover:not(:disabled) {
box-shadow: inset 0 0 0 $border-width $alert-red;
color: $alert-red;
}
&:focus:not(:disabled) {
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) $alert-red;
color: $alert-red;
}
}
/**
* Link buttons.
*/
&.is-link {
margin: 0;
padding: 0;
box-shadow: none;
border: 0;
border-radius: 0;
background: none;
outline: none;
text-align: left;
color: var(--wp-admin-theme-color);
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;
}
// Link buttons that are red to indicate destructive behavior.
&.is-destructive {
color: $alert-red;
&:active:not(:disabled),
&:hover:not(:disabled) {
color: darken($alert-red, 20%);
background: none;
}
&:focus:not(:disabled) {
color: var(--wp-admin-theme-color);
}
}
}
&:not([aria-disabled="true"]):active {
color: inherit;
}
&: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,
darken($white, 2%) 33%,
darken($white, 12%) 33%,
darken($white, 12%) 70%,
darken($white, 2%) 70%
);
/* stylelint-enable */
}
&.is-small {
height: 24px;
line-height: 22px;
padding: 0 8px;
font-size: 11px;
&.has-icon:not(.has-text) {
padding: 0 8px;
width: 24px;
}
}
&.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;
.dashicon {
display: inline-block;
flex: 0 0 auto;
margin-left: 2px;
margin-right: 2px;
}
&.has-text {
justify-content: left;
}
&.has-text svg {
margin-right: 8px;
}
&.has-text .dashicon {
margin-right: 10px;
}
}
// Toggled style.
&.is-pressed {
color: $white;
background: $gray-900;
&:focus:not(:disabled) {
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent;
}
&:hover:not(:disabled) {
color: $white;
background: $gray-900;
}
}
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;
}
}