Skip to content

Commit 8b837f7

Browse files
Mayank-Tripathi32Mayank-Tripathi32t-hamano
authored
[Block Editor]: A11y - Add and Update missing reduce-motion mixing (#68417)
Co-authored-by: Mayank-Tripathi32 <[email protected]> Co-authored-by: t-hamano <[email protected]>
1 parent 4f5270a commit 8b837f7

File tree

19 files changed

+131
-78
lines changed

19 files changed

+131
-78
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ iframe[name="editor-canvas"] {
44
height: 100%;
55
display: block;
66
// Handles transitions between device previews
7-
transition: all 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96);
8-
@include reduce-motion("transition");
7+
@media not ( prefers-reduced-motion ) {
8+
transition: all 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96);
9+
}
910
background-color: $gray-300;
1011
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@
5959
justify-content: center;
6060
align-items: center;
6161
background-color: transparent;
62-
transition: all 0.1s linear 0.1s;
62+
@media not ( prefers-reduced-motion ) {
63+
transition: all 0.1s linear 0.1s;
64+
}
6365

6466
.block-editor-block-draggable-chip__disabled-icon {
6567
width: $grid-unit-50 * 0.5;

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

+19-12
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
5858
background: var(--wp-admin-theme-color);
5959
opacity: 0.4;
6060

61-
// Animate.
62-
animation: selection-overlay__fade-in-animation 0.1s ease-out;
63-
animation-fill-mode: forwards;
64-
@include reduce-motion("animation");
61+
@media not ( prefers-reduced-motion ) {
62+
63+
// Animate.
64+
animation: selection-overlay__fade-in-animation 0.1s ease-out;
65+
animation-fill-mode: forwards;
66+
}
6567

6668
// Show outline in high contrast mode.
6769
outline: 2px solid transparent;
@@ -271,8 +273,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
271273
// Spotlight mode. Fade out blocks unless they contain a selected block.
272274
.is-focus-mode .block-editor-block-list__block:not(.has-child-selected) {
273275
opacity: 0.2;
274-
transition: opacity 0.1s linear;
275-
@include reduce-motion("transition");
276+
@media not ( prefers-reduced-motion ) {
277+
transition: opacity 0.1s linear;
278+
}
276279

277280
// Nested blocks should never be faded. If the parent block is already faded
278281
// out, it shouldn't be faded out more. If the parent block in not faded
@@ -339,9 +342,10 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
339342
// Hide the appender that sits at the end of block lists, when inside a nested block,
340343
// unless the block itself, or a parent, is selected.
341344
.wp-block .block-list-appender .block-editor-inserter__toggle {
342-
animation: block-editor-inserter__toggle__fade-in-animation 0.1s ease;
343-
animation-fill-mode: forwards;
344-
@include reduce-motion("animation");
345+
@media not ( prefers-reduced-motion ) {
346+
animation: block-editor-inserter__toggle__fade-in-animation 0.1s ease;
347+
animation-fill-mode: forwards;
348+
}
345349
}
346350

347351
.block-editor-block-list__block:not(.is-selected):not(.has-child-selected) .block-editor-default-block-appender {
@@ -367,8 +371,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
367371
font-family: $editor-html-font;
368372
font-size: $text-editor-font-size;
369373
line-height: 1.5;
370-
transition: padding 0.2s linear;
371-
@include reduce-motion("transition");
374+
@media not ( prefers-reduced-motion ) {
375+
transition: padding 0.2s linear;
376+
}
372377

373378
&:focus {
374379
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
@@ -400,7 +405,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
400405
// Additional -1px is required to avoid sub pixel rounding errors allowing background to show.
401406
margin-left: -1px;
402407
margin-right: -1px;
403-
transition: background-color 0.3s ease;
408+
@media not ( prefers-reduced-motion ) {
409+
transition: background-color 0.3s ease;
410+
}
404411
display: flex;
405412
align-items: center;
406413
justify-content: center;

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@
8787
right: $grid-unit-10;
8888
z-index: -1;
8989

90-
// Animate in.
91-
animation: components-button__appear-animation 0.1s ease;
92-
animation-fill-mode: forwards;
93-
@include reduce-motion("animation");
90+
@media not ( prefers-reduced-motion ) {
91+
// Animate in.
92+
animation: components-button__appear-animation 0.1s ease;
93+
animation-fill-mode: forwards;
94+
}
9495
}
9596

9697
// Don't show the focus inherited by the Button component.

packages/block-editor/src/components/block-pattern-setup/style.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@
130130
background-color: $white;
131131
margin: auto;
132132
padding: 0;
133-
transition: transform 0.5s, z-index 0.5s;
133+
@media not ( prefers-reduced-motion ) {
134+
transition: transform 0.5s, z-index 0.5s;
135+
}
134136
z-index: z-index(".block-editor-block-pattern-setup .pattern-slide");
135137

136138
&.active-slide {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
outline: $border-width solid rgba($black, 0.1);
4545
outline-offset: -$border-width;
4646
border-radius: $radius-medium;
47-
48-
transition: outline 0.1s linear;
49-
@include reduce-motion("transition");
47+
@media not ( prefers-reduced-motion ) {
48+
transition: outline 0.1s linear;
49+
}
5050
}
5151
}
5252

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@
129129
.block-editor-block-switcher__preview-patterns-container-list__item {
130130
height: 100%;
131131
border-radius: $radius-small;
132-
transition: all 0.05s ease-in-out;
132+
@media not ( prefers-reduced-motion ) {
133+
transition: all 0.05s ease-in-out;
134+
}
133135
position: relative;
134136
border: $border-width solid transparent;
135137

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
overflow-y: hidden;
1313
overflow-x: auto;
1414

15-
// Animation
16-
transition: border-color 0.1s linear, box-shadow 0.1s linear;
17-
@include reduce-motion("transition");
15+
@media not ( prefers-reduced-motion ) {
16+
17+
// Animation
18+
transition: border-color 0.1s linear, box-shadow 0.1s linear;
19+
}
1820

1921
@include break-small() {
2022
overflow: inherit;

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@
191191

192192
.is-dragging-components-draggable & {
193193
opacity: 0;
194-
// Use a minimal duration to delay hiding the element, see hide-during-dragging animation for more details.
195-
// It's essential to hide the toolbar/popover so that `dragEnter` events can pass through them to the underlying elements.
196-
animation: hide-during-dragging 1ms linear forwards;
194+
@media not ( prefers-reduced-motion ) {
195+
196+
// Use a minimal duration to delay hiding the element, see hide-during-dragging animation for more details.
197+
// It's essential to hide the toolbar/popover so that `dragEnter` events can pass through them to the underlying elements.
198+
animation: hide-during-dragging 1ms linear forwards;
199+
}
197200
}
198201

199202
.block-editor-block-parent-selector {

packages/block-editor/src/components/button-block-appender/content.scss

+2-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@
7979
background-color: var(--wp-admin-theme-color);
8080
box-shadow: inset 0 0 0 $border-width $light-gray-placeholder;
8181
color: $light-gray-placeholder;
82-
transition: background-color 0.2s ease-in-out;
83-
84-
@media ( prefers-reduced-motion: reduce ) {
85-
transition: none;
82+
@media not ( prefers-reduced-motion ) {
83+
transition: background-color 0.2s ease-in-out;
8684
}
8785
}
8886
}

packages/block-editor/src/components/colors-gradients/style.scss

+3-2
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ $swatch-gap: 12px;
129129
top: $grid-unit;
130130
margin: auto $grid-unit auto;
131131
opacity: 0;
132-
transition: opacity 0.1s ease-in-out;
133-
@include reduce-motion("transition");
132+
@media not ( prefers-reduced-motion ) {
133+
transition: opacity 0.1s ease-in-out;
134+
}
134135

135136
&.block-editor-panel-color-gradient-settings__reset {
136137
border-radius: $radius-small;

packages/block-editor/src/components/global-styles/style.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
box-sizing: border-box;
5454

5555
transform: scale(1);
56-
transition: transform 0.1s ease;
56+
@media not ( prefers-reduced-motion ) {
57+
transition: transform 0.1s ease;
58+
}
5759
will-change: transform;
5860

5961
&:focus {

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@
126126
right: $grid-unit-10;
127127
z-index: -1;
128128

129-
// Animate in.
130-
animation: components-button__appear-animation 0.1s ease;
131-
animation-fill-mode: forwards;
132-
@include reduce-motion("animation");
129+
@media not ( prefers-reduced-motion ) {
130+
// Animate in.
131+
animation: components-button__appear-animation 0.1s ease;
132+
animation-fill-mode: forwards;
133+
}
133134
}
134135

135136
// Don't show the focus inherited by the Button component.

packages/block-editor/src/components/iframe/content.scss

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
.block-editor-iframe__html {
66
transform-origin: top center;
7-
// Prevents a flash of background color change when entering/exiting zoom out
8-
transition: background-color 400ms;
7+
8+
@media not ( prefers-reduced-motion ) {
9+
// Prevents a flash of background color change when entering/exiting zoom out
10+
transition: background-color 400ms;
11+
}
912

1013
&.zoom-out-animation {
1114
$scroll-top: var(--wp-block-editor-iframe-zoom-out-scroll-top, 0);

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
cursor: pointer;
4444
background: transparent;
4545
word-break: break-word;
46-
transition: all 0.05s ease-in-out;
47-
@include reduce-motion("transition");
46+
@media not ( prefers-reduced-motion ) {
47+
transition: all 0.05s ease-in-out;
48+
}
4849
position: relative;
4950
height: auto;
5051

@@ -97,17 +98,19 @@
9798
.block-editor-block-types-list__item-icon {
9899
padding: 12px 20px;
99100
color: $gray-900;
100-
transition: all 0.05s ease-in-out;
101-
@include reduce-motion("transition");
101+
@media not ( prefers-reduced-motion ) {
102+
transition: all 0.05s ease-in-out;
103+
}
102104

103105
.block-editor-block-icon {
104106
margin-left: auto;
105107
margin-right: auto;
106108
}
107109

108110
svg {
109-
transition: all 0.15s ease-out;
110-
@include reduce-motion("transition");
111+
@media not ( prefers-reduced-motion ) {
112+
transition: all 0.15s ease-out;
113+
}
111114
}
112115

113116
.block-editor-block-types-list__list-item[draggable="true"] & {

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ $block-inserter-tabs-height: 44px;
8383
border: none;
8484
outline: none;
8585
padding: 0;
86-
transition: color 0.2s ease;
87-
@include reduce-motion("transition");
86+
@media not ( prefers-reduced-motion ) {
87+
transition: color 0.2s ease;
88+
}
8889
}
8990

9091
.block-editor-inserter__menu {
@@ -563,8 +564,9 @@ $block-inserter-tabs-height: 44px;
563564
outline-color: var(--wp-admin-theme-color);
564565
outline-width: var(--wp-admin-border-width-focus);
565566
outline-offset: calc((-1 * var(--wp-admin-border-width-focus)));
566-
transition: outline 0.1s linear;
567-
@include reduce-motion("transition");
567+
@media not ( prefers-reduced-motion ) {
568+
transition: outline 0.1s linear;
569+
}
568570
}
569571
}
570572

packages/block-editor/src/components/link-control/style.scss

+11-6
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@ $block-editor-link-control-number-of-actions: 1;
289289
right: 0;
290290
bottom: 0;
291291
border-radius: 100%;
292-
animation: loadingpulse 1s linear infinite;
293-
animation-delay: 0.5s; // avoid animating for fast network responses
292+
@media not ( prefers-reduced-motion ) {
293+
animation: loadingpulse 1s linear infinite;
294+
animation-delay: 0.5s; // avoid animating for fast network responses
295+
}
294296
}
295297
}
296298
}
@@ -381,16 +383,19 @@ $block-editor-link-control-number-of-actions: 1;
381383
// Point downwards when open (same as list view expander)
382384
&[aria-expanded="true"] svg {
383385
visibility: visible;
384-
transition: transform 0.1s ease;
386+
@media not ( prefers-reduced-motion ) {
387+
transition: transform 0.1s ease;
388+
}
385389
transform: rotate(90deg);
386-
@include reduce-motion("transition");
390+
387391
}
388392
// Point rightwards when closed (same as list view expander)
389393
&[aria-expanded="false"] svg {
390394
visibility: visible;
391395
transform: rotate(0deg);
392-
transition: transform 0.1s ease;
393-
@include reduce-motion("transition");
396+
@media not ( prefers-reduced-motion ) {
397+
transition: transform 0.1s ease;
398+
}
394399
}
395400
}
396401
}

0 commit comments

Comments
 (0)