Skip to content

Commit 638da7d

Browse files
committed
refactor(reduced-motion): rename mixins and streamline motion preference handling
1 parent 4208e51 commit 638da7d

2 files changed

Lines changed: 17 additions & 21 deletions

File tree

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
/**
2-
* Reduced-motion for animations
2+
* Motion preference helpers for animations
33
*
44
* Driven by `html.js-animation` / `html.no-js-animation` (toggled from
55
* prefers-reduced-motion in header.php, and by the a11y access config plugin).
66
*
77
* @author Paolo Tesei
88
*
9-
* @param $reduce
10-
*
119
* Examples :
1210
*
1311
* @include reduced-motion { ... }
1412
* → html.no-js-animation & { ... }
1513
*
16-
* you can add heavy animation using :
17-
*
18-
* @include reduced-motion (false) { ... }
14+
* @include allows-motion { ... }
1915
* → html.js-animation & { ... }
2016
*
2117
*/
2218

23-
@mixin reduced-motion($reduce: true) {
24-
$class: if($reduce, "no-js-animation", "js-animation");
25-
19+
@mixin _html-animation-class($class) {
2620
@if not & {
2721
html.#{$class} {
2822
@content;
@@ -33,3 +27,17 @@
3327
}
3428
}
3529
}
30+
31+
// Styles when motion is reduced (`html.no-js-animation`).
32+
@mixin reduced-motion {
33+
@include _html-animation-class("no-js-animation") {
34+
@content;
35+
}
36+
}
37+
38+
// Styles when animations are allowed (`html.js-animation`).
39+
@mixin allows-motion {
40+
@include _html-animation-class("js-animation") {
41+
@content;
42+
}
43+
}

‎src/scss/03-base/_variables-css.scss‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,11 @@
4343
--paragraph--line-height-small: 1.4;
4444
--paragraph--line-height-default: 1.4;
4545

46-
/*
47-
* Animation speeds
48-
*/
49-
--speed: 1s;
50-
5146
/*
5247
* Admin bar
5348
*/
5449
--wp-admin-bar-height: var(--wp-admin--admin-bar--height, 0rem);
5550

56-
/*
57-
* A11y reduced motion
58-
*/
59-
@include reduced-motion {
60-
--speed: 0s;
61-
}
62-
6351
/*
6452
* Global breakpoints
6553
*/

0 commit comments

Comments
 (0)