-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d3c391
commit 60076ba
Showing
8 changed files
with
129 additions
and
41 deletions.
There are no files selected for viewing
File renamed without changes.
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
60 changes: 60 additions & 0 deletions
60
src/app/features/approver/components/approver-animation.tsx
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,60 @@ | ||
import { motion, stagger, useAnimate } from 'framer-motion'; | ||
import { css } from 'leather-styles/css'; | ||
|
||
import type { HasChildren } from '@app/common/has-children'; | ||
import { useOnMount } from '@app/common/hooks/use-on-mount'; | ||
|
||
const animationSelector = '& > *:not(.skip-animation)'; | ||
|
||
export const childElementInitialAnimationState = css({ | ||
[animationSelector]: { opacity: 0, transform: 'translateY(-16px)' }, | ||
}); | ||
|
||
const staggerMenuItems = stagger(0.06, { startDelay: 0.32 }); | ||
|
||
export function useApproverChildrenEntryAnimation() { | ||
const [scope, animate] = useAnimate(); | ||
|
||
useOnMount(() => { | ||
// Animation throws if there are no children | ||
try { | ||
animate( | ||
animationSelector, | ||
{ opacity: 1, transform: 'translateY(0)' }, | ||
{ | ||
duration: 0.36, | ||
delay: staggerMenuItems, | ||
ease: 'easeOut', | ||
} | ||
); | ||
} catch (e) {} | ||
}); | ||
|
||
return scope; | ||
} | ||
|
||
const initialState = { x: -20, opacity: 0 } as const; | ||
const animateState = { x: 0, opacity: 1, transition: { duration: 0.32 } } as const; | ||
|
||
interface ApproverHeaderAnimationProps extends HasChildren { | ||
delay?: number; | ||
} | ||
export function ApproverHeaderAnimation({ delay = 0, ...props }: ApproverHeaderAnimationProps) { | ||
return ( | ||
<motion.div | ||
initial={initialState} | ||
animate={{ ...animateState, transition: { ...animateState, delay } }} | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
export function ApproverActionsAnimation(props: HasChildren) { | ||
return ( | ||
<motion.div | ||
initial={{ opacity: 0 }} | ||
animate={{ ...animateState, transition: { ...animateState.transition, delay: 0.64 } }} | ||
{...props} | ||
/> | ||
); | ||
} |
41 changes: 41 additions & 0 deletions
41
src/app/features/approver/components/approver-container.tsx
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,41 @@ | ||
import { css } from 'leather-styles/css'; | ||
import { Flex, styled } from 'leather-styles/jsx'; | ||
|
||
import type { HasChildren } from '@app/common/has-children'; | ||
|
||
import { | ||
childElementInitialAnimationState, | ||
useApproverChildrenEntryAnimation, | ||
} from './approver-animation'; | ||
|
||
const applyMarginsToLastApproverSection = css({ | ||
'& .approver-section:last-child': { mb: 'space.03' }, | ||
}); | ||
|
||
export function ApproverContainer({ children }: HasChildren) { | ||
const scope = useApproverChildrenEntryAnimation(); | ||
|
||
return ( | ||
<styled.main | ||
display="flex" | ||
flexDir="column" | ||
pos="relative" | ||
minH="100%" | ||
maxW="640px" | ||
mx="auto" | ||
className={applyMarginsToLastApproverSection} | ||
alignItems="center" | ||
boxShadow="0px 12px 24px 0px rgba(18, 16, 15, 0.08), 0px 4px 8px 0px rgba(18, 16, 15, 0.08), 0px 0px 2px 0px rgba(18, 16, 15, 0.08)" | ||
> | ||
<Flex | ||
className={childElementInitialAnimationState} | ||
ref={scope} | ||
flexDir="column" | ||
flex={1} | ||
background="ink.background-secondary" | ||
> | ||
{children} | ||
</Flex> | ||
</styled.main> | ||
); | ||
} |
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