-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
styles.ts
71 lines (61 loc) · 1.58 KB
/
styles.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 and paint to a DOM subtree rather
* than the entire page.
*/
contain: content;
`;
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 ) }
`;