-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
content.scss
476 lines (406 loc) · 12.9 KB
/
content.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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
// This remove the margins set here: https://github.com/WordPress/gutenberg/blob/17e5c2d870d84fb6de48dcd5bc3c38cd0c0fb0d0/packages/block-library/src/editor.scss#L56
// It removes the margins around blocks when a BlockPreview is rendered in the block style selector
.block-editor-block-styles .block-editor-block-list__block {
margin: 0;
}
/**
* Cross-Block Selection
*/
@keyframes selection-overlay__fade-in-animation {
from {
opacity: 0;
}
to {
opacity: 0.4;
}
}
// Hide selections on this element, otherwise Safari will include it stacked
// under your actual selection.
// This uses a CSS hack to show the rules to Safari only. Failing here is okay,
// it just makes the selection indication slightly less precise. That makes this
// hack a progressive enhancement.
/* stylelint-disable -- Stylelint is disabled to allow the hack to work. */
_::-webkit-full-page-media, _:future, :root .block-editor-block-list__layout::selection,
_::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-block-list__layout::selection {
background-color: transparent;
}
/* stylelint-enable */
// Note to developers refactoring this, please test navigation mode, and
// multi selection and hovering the block switcher to highlight the block.
// Also be sure to test partial selections in Safari, as it draws the
// selection marker with an entirely different model than Blink.
.block-editor-block-list__layout {
position: relative;
// Block multi selection
.block-editor-block-list__block.is-multi-selected:not(.is-partially-selected) {
// Hide the native selection indicator, for the selection, and children.
&::selection,
& ::selection {
background: transparent;
}
// Draw a spot color overlay.
&::after {
content: "";
position: absolute;
z-index: 1;
pointer-events: none;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: var(--wp-admin-theme-color);
opacity: 0.4;
// Animate.
animation: selection-overlay__fade-in-animation 0.1s ease-out;
animation-fill-mode: forwards;
@include reduce-motion("animation");
// Show outline in high contrast mode.
outline: 2px solid transparent;
}
// Don't show the highlight focus style when multi selected.
&.is-highlighted::after {
outline-color: transparent;
}
}
// Block highlight, and navigation mode, and focus.
// This piece of code has gone back and forth between using a pseudo element
// vs. styling the block directly. Ultimately we likely need a pseudo element
// (unless styles like focus and selection overlay can be rendered as separate elements),
// since things like border-radius need to be able to be set on the block itself.
.block-editor-block-list__block.is-highlighted,
.block-editor-block-list__block.is-highlighted ~ .is-multi-selected,
&.is-navigate-mode .block-editor-block-list__block.is-selected,
.block-editor-block-list__block:not([contenteditable="true"]):focus {
outline: none;
// We're using a pseudo element to overflow placeholder borders
// and any border inside the block itself.
&::after {
@include selected-block-focus();
z-index: 1;
}
}
// Moving blocks using keyboard (Ellipsis > Move).
& .is-block-moving-mode.block-editor-block-list__block.is-selected {
&::after {
content: "";
position: absolute;
z-index: 0;
pointer-events: none;
transition:
border-color 0.1s linear,
border-style 0.1s linear,
box-shadow 0.1s linear;
right: 0;
left: 0;
top: -$default-block-margin * 0.5;
border-radius: $radius-small;
border-top: 4px solid $gray-400;
bottom: auto;
box-shadow: none;
}
}
& .is-block-moving-mode.can-insert-moving-block.block-editor-block-list__block.is-selected {
&::after {
border-color: var(--wp-admin-theme-color);
}
}
// Ensure an accurate partial text selection.
// To do this, we disable text selection on the main container, then re-enable it only on the
// elements that actually get selected.
// To keep in mind: user-select is currently inherited to all nodes inside.
.has-multi-selection & {
user-select: none;
}
// Re-enable it on components inside.
[class^="components-"] {
user-select: text;
}
}
.is-block-moving-mode.block-editor-block-list__block-selection-button {
// Should be invisible but not unfocusable.
opacity: 0;
font-size: 1px;
height: 1px;
padding: 0;
}
.block-editor-block-list__layout .block-editor-block-list__block {
// With `position: static`, Safari marks a full-width selection rectangle, including margins.
// With `position: relative`, Safari marks an inline selection rectangle, similar to that of
// Blink based browsers, but it also does "crop" the marker, which can result in a small line
// from the preceding paragraph showing, which is effectively the above selection bleeding in.
// We choose relative, as that matches the multi-selection, which is limited to the block footprint.
position: relative;
// Break long strings of text without spaces so they don't overflow the block.
overflow-wrap: break-word;
pointer-events: auto;
user-select: text;
&.is-editing-disabled {
pointer-events: none;
user-select: none;
}
&.has-negative-margin {
&.is-selected,
&.has-child-selected {
// Bring the selected block forward so we can see it.
z-index: z-index(".block-editor-block-list__block.is-selected");
}
}
.reusable-block-edit-panel * {
z-index: z-index(".block-editor-block-list__block .reusable-block-edit-panel *");
}
/**
* Notices
*/
.components-placeholder .components-with-notices-ui {
margin: -10px 0 12px 0;
}
.components-with-notices-ui {
margin: 0 0 12px 0;
width: 100%;
.components-notice {
.components-notice__content {
font-size: $default-font-size;
}
}
}
// Warnings
&.has-warning {
min-height: $grid-unit-60;
// When a block has a warning, you shouldn't be able to manipulate the contents.
> * {
pointer-events: none;
user-select: none;
}
// Allow the warning action buttons to be manipulable.
.block-editor-warning {
pointer-events: all;
}
}
// Scrim overlay.
&.has-warning::after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba($white, 0.4);
}
// Avoid conflict with the multi-selection highlight color.
&.has-warning.is-multi-selected::after {
background-color: transparent;
}
// Reusable blocks clickthrough overlays.
&.is-reusable > .block-editor-inner-blocks > .block-editor-block-list__layout.has-overlay {
// Remove only the top click overlay.
&::after {
display: none;
}
// Restore it for subsequent.
.block-editor-block-list__layout.has-overlay::after {
display: block;
}
}
// Reusable blocks parent border.
&.is-reusable.has-child-selected::after {
box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
}
// Clear floats.
&[data-clear="true"] {
float: none;
}
}
.is-outline-mode .block-editor-block-list__block:not(.remove-outline) {
&.is-selected,
&.is-hovered {
cursor: default;
&.rich-text,
.rich-text {
cursor: auto;
}
}
&.is-hovered:not(.is-selected),
&:not(.rich-text):not([contenteditable="true"]).is-selected {
&::after {
@include selected-block-focus();
}
}
}
// Colorize outlines for template parts and synced patterns (.is-reusable).
.is-outline-mode .block-editor-block-list__block:not(.remove-outline).wp-block-template-part,
.is-outline-mode .block-editor-block-list__block:not(.remove-outline).is-reusable {
&.is-hovered::after,
&.is-selected::after,
&.is-highlighted::after {
outline-color: var(--wp-block-synced-color);
}
&.block-editor-block-list__block:not([contenteditable]):focus {
&::after {
outline-color: var(--wp-block-synced-color);
}
}
}
// Add fade in/out background for editable blocks in synced patterns.
@keyframes block-editor-is-editable__animation {
from {
background-color: rgba(var(--wp-admin-theme-color--rgb), 0.1);
}
to {
background-color: rgba(var(--wp-admin-theme-color--rgb), 0);
}
}
@keyframes block-editor-is-editable__animation_reduce-motion {
0% {
background-color: rgba(var(--wp-admin-theme-color--rgb), 0.1);
}
99% {
background-color: rgba(var(--wp-admin-theme-color--rgb), 0.1);
}
100% {
background-color: rgba(var(--wp-admin-theme-color--rgb), 0);
}
}
.is-root-container:not([inert]) .block-editor-block-list__block.is-reusable.is-selected .block-editor-block-list__block.has-editable-outline::after {
animation-name: block-editor-is-editable__animation;
animation-duration: 0.8s;
animation-timing-function: ease-out;
animation-delay: 0.1s;
animation-fill-mode: backwards;
bottom: 0;
content: "";
left: 0;
pointer-events: none;
position: absolute;
right: 0;
top: 0;
// Unique reduced-motion affordance to ensure the effect is still visible when reduce motion is enabled.
@media (prefers-reduced-motion: reduce) {
animation-name: block-editor-is-editable__animation_reduce-motion;
animation-delay: 0s;
}
}
// Spotlight mode. Fade out blocks unless they contain a selected block.
.is-focus-mode .block-editor-block-list__block:not(.has-child-selected) {
opacity: 0.2;
transition: opacity 0.1s linear;
@include reduce-motion("transition");
// Nested blocks should never be faded. If the parent block is already faded
// out, it shouldn't be faded out more. If the parent block in not faded
// out, it shouldn't be faded out either because the block as a whole,
// including inner blocks, should be focused.
.block-editor-block-list__block,
&.is-selected,
&.is-multi-selected {
opacity: 1;
}
}
.is-focus-mode .block-editor-block-list__block.is-content-locked.has-child-selected,
.is-focus-mode .block-editor-block-list__block.is-content-locked-temporarily-editing-as-blocks.has-child-selected {
&,
& .block-editor-block-list__block {
opacity: 1;
}
}
.wp-block[data-align="left"] > *,
.wp-block[data-align="right"] > *,
.wp-block.alignleft,
.wp-block.alignright {
// Without z-index, won't be clickable as "above" adjacent content.
z-index: z-index("{core/image aligned left or right} .wp-block");
}
.wp-site-blocks > [data-align="left"] {
float: left;
margin-right: 2em;
}
.wp-site-blocks > [data-align="right"] {
float: right;
margin-left: 2em;
}
.wp-site-blocks > [data-align="center"] {
justify-content: center;
margin-left: auto;
margin-right: auto;
}
/**
* In-Canvas Inserter
*/
.block-editor-block-list .block-editor-inserter {
margin: $grid-unit-10;
cursor: move; // Fallback for IE/Edge < 14
cursor: grab;
}
@keyframes block-editor-inserter__toggle__fade-in-animation {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
// Hide the appender that sits at the end of block lists, when inside a nested block,
// unless the block itself, or a parent, is selected.
.wp-block .block-list-appender .block-editor-inserter__toggle {
animation: block-editor-inserter__toggle__fade-in-animation 0.1s ease;
animation-fill-mode: forwards;
@include reduce-motion("animation");
}
.block-editor-block-list__block:not(.is-selected):not(.has-child-selected) .block-editor-default-block-appender {
display: none;
.block-editor-inserter__toggle {
opacity: 0;
transform: scale(0);
}
}
.block-editor-block-list__block .block-editor-block-list__block-html-textarea {
display: block;
margin: 0;
padding: $grid-unit-15;
width: 100%;
border: none;
outline: none;
border-radius: $radius-small;
box-shadow: inset 0 0 0 $border-width $gray-900;
resize: none;
overflow: hidden;
font-family: $editor-html-font;
font-size: $text-editor-font-size;
line-height: 1.5;
transition: padding 0.2s linear;
@include reduce-motion("transition");
&:focus {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
}
}
/**
* Warnings.
*/
.block-editor-block-list__block .block-editor-warning {
z-index: z-index(".block-editor-warning");
position: relative;
&.block-editor-block-list__block-crash-warning {
// The block crash warning has no block preview underneath it.
// The lack of a preview combined with the negative margin that
// the warning normally has results in crashed blocks overlapping
// any blocks that come after them. Resetting the margin to `auto`
// solves this.
margin-bottom: auto;
}
}
.block-editor-block-list__zoom-out-separator {
/* same color as the iframe's background */
background: $gray-300;
// Additional -1px is required to avoid sub pixel rounding errors allowing background to show.
margin-left: -1px;
margin-right: -1px;
transition: background-color 0.3s ease;
&.is-dragged-over {
background: $gray-400;
}
}
// In Post Editor allow the separator to occupy the full width by ignoring (cancelling out) the global padding.
.has-global-padding > .block-editor-block-list__zoom-out-separator,
.block-editor-block-list__layout.is-root-container.has-global-padding > .block-editor-block-list__zoom-out-separator {
max-width: none;
// Additional -1px is required to avoid sub pixel rounding errors allowing background to show.
margin: 0 calc(-1 * var(--wp--style--root--padding-right) - 1px) 0 calc(-1 * var(--wp--style--root--padding-left) - 1px) !important;
}