diff --git a/packages/base-styles/_animations.scss b/packages/base-styles/_animations.scss index ce1f935b7d4d5..8706d185aa221 100644 --- a/packages/base-styles/_animations.scss +++ b/packages/base-styles/_animations.scss @@ -1,5 +1,37 @@ -@mixin edit-post__fade-in-animation($speed: 0.08s, $delay: 0s) { - animation: edit-post__fade-in-animation $speed linear $delay; +@mixin keyframes($name) { + @keyframes #{$name} { + @content; + } +} + +@mixin animation__fade-in($speed: 0.08s, $delay: 0s) { + @include keyframes(__wp-base-styles-fade-in) { + from { + opacity: 0; + } + to { + opacity: 1; + } + } + + + animation: __wp-base-styles-fade-in $speed linear $delay; + animation-fill-mode: forwards; + @include reduce-motion("animation"); +} + +@mixin animation__fade-out($speed: 0.08s, $delay: 0s) { + @include keyframes(__wp-base-styles-fade-out) { + from { + opacity: 1; + } + to { + opacity: 0; + } + } + + + animation: __wp-base-styles-fade-out $speed linear $delay; animation-fill-mode: forwards; @include reduce-motion("animation"); } @@ -8,3 +40,9 @@ transition: all 0.5s cubic-bezier(0.65, 0, 0.45, 1); @include reduce-motion("transition"); } + +// Deprecated +@mixin edit-post__fade-in-animation($speed: 0.08s, $delay: 0s) { + @warn "The `edit-post__fade-in-animation` mixin is deprecated. Use `animation__fade-in` instead."; + @include animation__fade-in($speed, $delay); +} diff --git a/packages/block-editor/src/components/list-view/style.scss b/packages/block-editor/src/components/list-view/style.scss index 3d25597d2af90..05a04abfd110b 100644 --- a/packages/block-editor/src/components/list-view/style.scss +++ b/packages/block-editor/src/components/list-view/style.scss @@ -272,7 +272,7 @@ &.is-visible .block-editor-list-view-block-contents { opacity: 1; - @include edit-post__fade-in-animation; + @include animation__fade-in; } .block-editor-block-icon { diff --git a/packages/block-editor/src/utils/test/transform-styles.js b/packages/block-editor/src/utils/test/transform-styles.js index 3a68cc63c248e..efe92cea63d0f 100644 --- a/packages/block-editor/src/utils/test/transform-styles.js +++ b/packages/block-editor/src/utils/test/transform-styles.js @@ -293,7 +293,7 @@ describe( 'transformStyles', () => { it( 'should ignore keyframes', () => { const input = ` - @keyframes edit-post__fade-in-animation { + @keyframes __wp-base-styles-fade-in { from { opacity: 0; } diff --git a/packages/components/src/modal/style.scss b/packages/components/src/modal/style.scss index 8c7c8416f0190..3790e0b7368a6 100644 --- a/packages/components/src/modal/style.scss +++ b/packages/components/src/modal/style.scss @@ -8,8 +8,8 @@ background-color: rgba($black, 0.35); z-index: z-index(".components-modal__screen-overlay"); display: flex; - // This animates the appearance of the white background. - @include edit-post__fade-in-animation(); + // This animates the appearance of the backdrop. + @include animation__fade-in(); } // The modal window element. diff --git a/packages/edit-post/src/style.scss b/packages/edit-post/src/style.scss index f77c8122ca2e5..7230d7b2b15e6 100644 --- a/packages/edit-post/src/style.scss +++ b/packages/edit-post/src/style.scss @@ -3,22 +3,6 @@ @import "./components/meta-boxes/meta-boxes-area/style.scss"; @import "./components/welcome-guide/style.scss"; -/** - * Animations - */ - -// These keyframes should not be part of the _animations.scss mixins file. -// Because keyframe animations can't be defined as mixins properly, they are duplicated. -// Since hey are intended only for the editor, we add them here instead. -@keyframes edit-post__fade-in-animation { - from { - opacity: 0; - } - to { - opacity: 1; - } -} - body.js.block-editor-page { @include wp-admin-reset( ".block-editor" ); } diff --git a/packages/edit-site/src/style.scss b/packages/edit-site/src/style.scss index 473deaeedc590..4e9e1071e3a77 100644 --- a/packages/edit-site/src/style.scss +++ b/packages/edit-site/src/style.scss @@ -91,20 +91,4 @@ body.js.site-editor-php { } } -/** - * Animations - */ - -// These keyframes should not be part of the _animations.scss mixins file. -// Because keyframe animations can't be defined as mixins properly, they are duplicated. -// Since they are intended only for the editor, we add them here instead. -@keyframes edit-post__fade-in-animation { - from { - opacity: 0; - } - to { - opacity: 1; - } -} - @include wordpress-admin-schemes(); diff --git a/storybook/stories/playground/fullpage/style.lazy.scss b/storybook/stories/playground/fullpage/style.lazy.scss index 6d28c1d3c8163..0249011c3e960 100644 --- a/storybook/stories/playground/fullpage/style.lazy.scss +++ b/storybook/stories/playground/fullpage/style.lazy.scss @@ -46,19 +46,3 @@ display: block; } } - -/** - * Animations - */ - -// These keyframes should not be part of the _animations.scss mixins file. -// Because keyframe animations can't be defined as mixins properly, they are duplicated. -// Since hey are intended only for the editor, we add them here instead. -@keyframes edit-post__fade-in-animation { - from { - opacity: 0; - } - to { - opacity: 1; - } -}