Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify reduce-motion mixin so that it works for transitions too. #15850

Merged
merged 6 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/stylesheets/_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
@mixin edit-post__fade-in-animation($speed: 0.2s, $delay: 0s) {
animation: edit-post__fade-in-animation $speed ease-out $delay;
animation-fill-mode: forwards;
@include reduce-motion;
@include reduce-motion("animation");
}
24 changes: 21 additions & 3 deletions assets/stylesheets/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
transition: box-shadow 0.1s linear;
border-radius: $radius-round-rectangle;
border: $border-width solid $dark-gray-150;
@include reduce-motion("transition");
}

@mixin input-style__focus() {
Expand Down Expand Up @@ -337,10 +338,27 @@
* Allows users to opt-out of animations via OS-level preferences.
*/

@mixin reduce-motion {
@media (prefers-reduced-motion: reduce) {
animation-duration: 1ms !important;
@mixin reduce-motion($property: "") {

@if $property == "transition" {
@media (prefers-reduced-motion: reduce) {
transition-duration: 0s;
}
}

@else if $property == "animation" {
@media (prefers-reduced-motion: reduce) {
animation-duration: 1ms;
}
}

@else {
@media (prefers-reduced-motion: reduce) {
transition-duration: 0s;
animation-duration: 1ms;
}
}

}

/**
Expand Down
6 changes: 5 additions & 1 deletion packages/block-editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@
border: $border-width solid transparent;
border-left: none;
box-shadow: none;
transition: border-color 0.1s linear, box-shadow 0.1s linear;
pointer-events: none;
transition: border-color 0.1s linear, box-shadow 0.1s linear;
@include reduce-motion("transition");

// Include a transparent outline for Windows High Contrast mode.
outline: $border-width solid transparent;
Expand Down Expand Up @@ -160,6 +161,7 @@
&.is-focus-mode:not(.is-multi-selected) {
opacity: 0.5;
transition: opacity 0.1s linear;
@include reduce-motion("transition");

&:not(.is-focused) .block-editor-block-list__block,
&.is-focused {
Expand Down Expand Up @@ -752,6 +754,7 @@
// Hide both the button until hovered.
opacity: 0;
transition: opacity 0.1s linear;
@include reduce-motion("transition");

&:hover,
&.is-visible {
Expand Down Expand Up @@ -815,6 +818,7 @@
font-size: $text-editor-font-size;
line-height: 150%;
transition: padding 0.2s linear;
@include reduce-motion("transition");

&:focus {
box-shadow: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
display: flex;
align-items: center;
transition: all 0.1s cubic-bezier(0.165, 0.84, 0.44, 1);
@include reduce-motion("transition");
}

// Add a dropdown arrow indicator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
width: 100%;
overflow: auto; // Allow horizontal scrolling on mobile.
position: relative;
transition: border-color 0.1s linear, box-shadow 0.1s linear;
border-left: $border-width solid $light-gray-800;
transition: border-color 0.1s linear, box-shadow 0.1s linear;
@include reduce-motion("transition");

@include break-small() {
// Allow overflow on desktop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
width: 100%;
outline: $border-width solid transparent;
transition: 0.2s outline;
@include reduce-motion("transition");
resize: none;
margin-top: $default-block-margin;
margin-bottom: $default-block-margin;
Expand All @@ -32,6 +33,7 @@
.block-editor-inserter__toggle:not([aria-expanded="true"]) {
opacity: 0;
transition: opacity 0.2s;
@include reduce-motion("transition");
will-change: opacity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
border-radius: $radius-round-rectangle;
border: $border-width solid transparent;
transition: all 0.05s ease-in-out;
@include reduce-motion("transition");
position: relative;

&:disabled {
Expand Down Expand Up @@ -71,6 +72,7 @@
border-radius: $radius-round-rectangle;
color: $dark-gray-500;
transition: all 0.05s ease-in-out;
@include reduce-motion("transition");

.block-editor-block-icon {
margin-left: auto;
Expand All @@ -79,6 +81,7 @@

svg {
transition: all 0.15s ease-out;
@include reduce-motion("transition");
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $block-inserter-search-height: 38px;
border: none;
outline: none;
transition: color 0.2s ease;
@include reduce-motion("transition");
}

.block-editor-inserter__menu {
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/url-input/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $input-size: 300px;
.block-editor-url-input__suggestions {
max-height: 200px;
transition: all 0.15s ease-in-out;
@include reduce-motion("transition");
padding: 4px 0;
// To match the url-input width: input width + padding + 2 buttons.
width: $input-size + 2;
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/classic/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
div[data-type="core/freeform"] {
.block-editor-block-list__block-edit::before {
transition: border-color 0.1s linear, box-shadow 0.1s linear;
@include reduce-motion("transition");
border: $border-width solid $light-gray-500;

// Windows High Contrast mode will show this outline.
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/animate/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.components-animate__appear {
animation: components-animate__appear-animation 0.1s cubic-bezier(0, 0, 0.2, 1) 0s;
animation-fill-mode: forwards;
@include reduce-motion;
@include reduce-motion("animation");

&.is-from-top,
&.is-from-top.is-from-left {
Expand Down Expand Up @@ -31,7 +31,7 @@
.components-animate__slide-in {
animation: components-animate__slide-in-animation 0.1s cubic-bezier(0, 0, 0.2, 1);
animation-fill-mode: forwards;
@include reduce-motion;
@include reduce-motion("animation");

&.is-from-left {
transform: translateX(+100%);
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
transition-property: border, background, color;
transition-duration: 0.05s;
transition-timing-function: ease-in-out;
@include reduce-motion("transition");

&:hover,
&:active {
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/color-palette/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $color-palette-circle-spacing: 14px;
vertical-align: top;
transform: scale(1);
transition: 100ms transform ease;
@include reduce-motion("transition");
&:hover {
transform: scale(1.2);
}
Expand All @@ -42,6 +43,7 @@ $color-palette-circle-spacing: 14px;
background: transparent;
box-shadow: inset 0 0 0 ($color-palette-circle-size / 2);
transition: 100ms box-shadow ease;
@include reduce-motion("transition");
cursor: pointer;

&.is-active {
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/color-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
.components-color-picker__hue-pointer,
.components-color-picker__saturation-pointer {
transition: box-shadow 0.1s linear;
@include reduce-motion("transition");
}

.components-color-picker__saturation-pointer:focus {
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/drop-zone/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
visibility: hidden;
opacity: 0;
transition: 0.3s opacity, 0.3s background-color, 0s visibility 0.3s;
@include reduce-motion("transition");
border: 2px solid $blue-dark-900;
border-radius: 2px;

&.is-active {
opacity: 1;
visibility: visible;
transition: 0.3s opacity, 0.3s background-color;
@include reduce-motion("transition");
}

&.is-dragging-over-element {
Expand All @@ -33,6 +35,7 @@
text-align: center;
color: $white;
transition: transform 0.2s ease-in-out;
@include reduce-motion("transition");
}

.components-drop-zone.is-dragging-over-element .components-drop-zone__content {
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/form-toggle/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ $toggle-border-width: 2px;
height: $toggle-height;
border-radius: $toggle-height / 2;
transition: 0.2s background ease;
@include reduce-motion("transition");
}

.components-form-toggle__thumb {
Expand All @@ -48,6 +49,7 @@ $toggle-border-width: 2px;
height: $toggle-height - ($toggle-border-width * 4);
border-radius: 50%;
transition: 0.1s transform ease;
@include reduce-motion("transition");
background-color: $dark-gray-300;
border: 5px solid $dark-gray-300; // Has explicit border to act as a fill in Windows High Contrast Mode.
}
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/form-token-field/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
line-height: 24px;
background: $light-gray-500;
transition: all 0.2s cubic-bezier(0.4, 1, 0.4, 1);
@include reduce-motion;
}

.components-form-token-field__token-text {
Expand Down Expand Up @@ -164,6 +165,7 @@
max-height: 9em;
overflow-y: scroll;
transition: all 0.15s ease-in-out;
@include reduce-motion("transition");
list-style: none;
border-top: $border-width solid $dark-gray-300;
margin: $grid-size-small (-$grid-size-small) (-$grid-size-small);
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/modal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// Animate the modal frame/contents appearing on the page.
animation: components-modal__appear-animation 0.1s ease-out;
animation-fill-mode: forwards;
@include reduce-motion;
@include reduce-motion("animation");
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
margin-top: 0;
margin-bottom: 0;
transition: 0.1s background ease-in-out;
@include reduce-motion("transition");
}
.components-panel__body.is-opened > .components-panel__body-title {
margin: -1 * $panel-padding;
Expand All @@ -86,6 +87,7 @@
color: $dark-gray-900;
@include menu-style__neutral;
transition: 0.1s background ease-in-out;
@include reduce-motion("transition");

&:focus:not(:disabled):not([aria-disabled="true"]) {
@include menu-style__focus;
Expand All @@ -99,6 +101,7 @@
color: $dark-gray-900;
fill: currentColor;
transition: 0.1s color ease-in-out;
@include reduce-motion("transition");
}

// mirror the arrow horizontally in RTL languages
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/resizable-box/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
top: calc(50% - 4px);
right: calc(50% - 4px);
transition: transform 0.1s ease-in;
@include reduce-motion("transition");
opacity: 0;
}

Expand Down Expand Up @@ -87,7 +88,7 @@
.components-resizable-box__side-handle.components-resizable-box__handle-bottom:active::before {
animation: components-resizable-box__top-bottom-animation 0.1s ease-out 0s;
animation-fill-mode: forwards;
@include reduce-motion;
@include reduce-motion("animation");
}

.components-resizable-box__side-handle.components-resizable-box__handle-left:hover::before,
Expand All @@ -96,7 +97,7 @@
.components-resizable-box__side-handle.components-resizable-box__handle-right:active::before {
animation: components-resizable-box__left-right-animation 0.1s ease-out 0s;
animation-fill-mode: forwards;
@include reduce-motion;
@include reduce-motion("animation");
}

@keyframes components-resizable-box__top-bottom-animation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ body.js.is-fullscreen-mode {
.edit-post-header {
transform: translateY(-100%);
animation: edit-post-fullscreen-mode__slide-in-animation 0.1s forwards;
@include reduce-motion;
@include reduce-motion("animation");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
border-left: $border-width solid $light-gray-500;
transform: translateX(+100%);
animation: edit-post-post-publish-panel__slide-in-animation 0.1s forwards;
@include reduce-motion;
@include reduce-motion("animation");

body.is-fullscreen-mode & {
top: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
color: $dark-gray-900;
@include square-style__neutral;
transition: box-shadow 0.1s linear;
@include reduce-motion("transition");

// This pseudo-element "duplicates" the tab label and sets the text to bold.
// This ensures that the tab doesn't change width when selected.
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/src/components/sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
font-weight: 400;
@include square-style__neutral;
transition: box-shadow 0.1s linear;
@include reduce-motion("transition");

&.is-active {
box-shadow: inset 0 -3px theme(outlines);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
width: 100%;
padding: 0;
transition: all 0.1s ease-out;
@include reduce-motion("transition");
box-shadow: 0 0 0 0 $blue-medium-500;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/post-title/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
line-height: $default-line-height;
color: $dark-gray-900;
transition: border 0.1s ease-out, box-shadow 0.1s linear;
@include reduce-motion("transition");
padding: #{ $block-padding + 5px } $block-padding;
word-break: keep-all;

Expand Down Expand Up @@ -94,6 +95,7 @@
&.is-focus-mode .editor-post-title__input {
opacity: 0.5;
transition: opacity 0.1s linear;
@include reduce-motion("transition");

&:focus {
opacity: 1;
Expand Down