Skip to content

Commit 5056694

Browse files
authored
Reveal block boundaries on hover in the Site Editor (#27271)
* Reveal block boundaries on hover, and colorise template parts * Hover boundary width * Remove focus and selected styles * fix clipping issue and better align hover outline * Apply 1px black border when selected, but not focussed * Default cursor on hover * Only hide the outline on text editable blocks whilst typing * outline alignment * Even more alignment fixes... * Remove the pseudo-spotlight effect on template parts * Remove template part spotlight and move outline styles
1 parent eea43a4 commit 5056694

File tree

3 files changed

+47
-49
lines changed

3 files changed

+47
-49
lines changed

packages/block-editor/src/components/block-list/style.scss

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,6 @@
206206
}
207207
}
208208

209-
// Active entity spotlight.
210-
&.has-active-entity:not(.is-focus-mode) {
211-
opacity: 0.5;
212-
transition: opacity 0.1s linear;
213-
@include reduce-motion("transition");
214-
215-
&.is-active-entity,
216-
&.has-child-selected,
217-
&:not(.has-child-selected) .block-editor-block-list__block,
218-
&.is-active-entity .block-editor-block-list__block,
219-
.is-active-entity .block-editor-block-list__block {
220-
opacity: 1;
221-
}
222-
}
223-
224209
/**
225210
* Block styles and alignments
226211
*/

packages/block-library/src/template-part/editor.scss

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -89,37 +89,3 @@
8989
box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
9090
}
9191
}
92-
93-
.block-editor-block-list__block[data-type="core/template-part"] {
94-
&.is-selected,
95-
&.has-child-selected {
96-
&::after {
97-
top: $border-width;
98-
bottom: $border-width;
99-
left: $border-width;
100-
right: $border-width;
101-
border-radius: $radius-block-ui - $border-width; // Border is outset, so so subtract the width to achieve correct radius.
102-
}
103-
}
104-
105-
&.is-selected {
106-
&::after {
107-
// 2px outside.
108-
box-shadow: 0 0 0 $border-width-focus var(--wp-admin-theme-color);
109-
// Show a light color for dark themes.
110-
.is-dark-theme & {
111-
box-shadow: 0 0 0 $border-width-focus $dark-theme-focus;
112-
}
113-
}
114-
}
115-
116-
&.has-child-selected {
117-
&::after {
118-
box-shadow: 0 0 0 $border-width $gray-300;
119-
120-
.is-dark-theme & {
121-
box-shadow: 0 0 0 $border-width-focus $gray-700;
122-
}
123-
}
124-
}
125-
}

packages/edit-site/src/components/block-editor/style.scss

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,50 @@
1111
padding: 6px;
1212
}
1313
}
14+
15+
.block-editor-block-list__layout {
16+
&.edit-site-block-editor__block-list {
17+
.block-editor-block-list__block {
18+
&::after {
19+
outline: 2px solid transparent;
20+
}
21+
22+
&.is-selected {
23+
&::after {
24+
box-shadow: 0 0 0 $border-width $gray-900; // Selected not focussed
25+
top: $border-width;
26+
left: $border-width;
27+
right: $border-width;
28+
bottom: $border-width;
29+
}
30+
31+
&:focus {
32+
&::after {
33+
box-shadow: 0 0 0 $border-width-focus var(--wp-admin-theme-color);
34+
}
35+
}
36+
}
37+
38+
&.is-hovered:not(.is-selected) {
39+
cursor: default;
40+
41+
&::after {
42+
top: $border-width;
43+
left: $border-width;
44+
right: $border-width;
45+
bottom: $border-width;
46+
box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
47+
}
48+
}
49+
}
50+
51+
// Do not display a border on rich text blocks when hovered and selected
52+
.block-editor-rich-text__editable {
53+
&.is-selected.is-hovered.is-typing {
54+
&::after {
55+
box-shadow: none;
56+
}
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)