-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigator: use CSS animations instead of framer-motion (#56909)
* Move navigator provider styles to separate file * Move navigator screen styles to separate file, use CSS animations instead of framer motion * Remove unused import * Spacing * Use standard ease-in-out easing function * Remove stale comments * Remove animation-specific tests (as they can't be tested in jsdom) * CHANGELOG * Add comment * Avoid running the `css` function when unnecessary
- Loading branch information
Showing
5 changed files
with
90 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { css, keyframes } from '@emotion/react'; | ||
|
||
export const navigatorProviderWrapper = css` | ||
/* Prevents horizontal overflow while animating screen transitions */ | ||
overflow-x: hidden; | ||
/* Mark this subsection of the DOM as isolated, providing performance benefits | ||
* by limiting calculations of layout, style, paint, size, or any combination | ||
* to a DOM subtree rather than the entire page. | ||
*/ | ||
contain: strict; | ||
`; | ||
|
||
const fadeInFromRight = keyframes( { | ||
'0%': { | ||
opacity: 0, | ||
transform: `translateX( 50px )`, | ||
}, | ||
'100%': { opacity: 1, transform: 'none' }, | ||
} ); | ||
|
||
const fadeInFromLeft = keyframes( { | ||
'0%': { | ||
opacity: 0, | ||
transform: `translateX( -50px )`, | ||
}, | ||
'100%': { opacity: 1, transform: 'none' }, | ||
} ); | ||
|
||
type NavigatorScreenAnimationProps = { | ||
isInitial?: boolean; | ||
isBack?: boolean; | ||
isRTL: boolean; | ||
}; | ||
|
||
const navigatorScreenAnimation = ( { | ||
isInitial, | ||
isBack, | ||
isRTL, | ||
}: NavigatorScreenAnimationProps ) => { | ||
if ( isInitial && ! isBack ) { | ||
return; | ||
} | ||
|
||
const animationName = | ||
( isRTL && isBack ) || ( ! isRTL && ! isBack ) | ||
? fadeInFromRight | ||
: fadeInFromLeft; | ||
|
||
return css` | ||
animation-duration: 0.14s; | ||
animation-timing-function: ease-in-out; | ||
will-change: transform, opacity; | ||
animation-name: ${ animationName }; | ||
@media ( prefers-reduced-motion ) { | ||
animation-duration: 0s; | ||
} | ||
`; | ||
}; | ||
|
||
export const navigatorScreen = ( props: NavigatorScreenAnimationProps ) => css` | ||
/* Ensures horizontal overflow is visually accessible */ | ||
overflow-x: auto; | ||
/* In case the root has a height, it should not be exceeded */ | ||
max-height: 100%; | ||
${ navigatorScreenAnimation( props ) } | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dc4f3e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in dc4f3e6.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7194828287
📝 Reported issues:
/test/e2e/specs/site-editor/navigation-editor.spec.js
/test/e2e/specs/site-editor/font-library.spec.js