-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: minimal example of a page transition
- Loading branch information
Showing
5 changed files
with
73 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { motion, useReducedMotion } from 'framer-motion'; | ||
import React, { PropsWithChildren, useEffect } from 'react'; | ||
|
||
import { Messages, readMessages } from './Messages'; | ||
|
||
export function PageTransition({ children }: PropsWithChildren) { | ||
const [messages, setMessages] = React.useState<Array<string>>([]); | ||
useEffect(() => { | ||
setMessages(readMessages()); | ||
}, []); | ||
return useReducedMotion() ? ( | ||
<main id="main-content"> | ||
<Messages messages={messages} /> | ||
{children} | ||
</main> | ||
) : ( | ||
<motion.main | ||
id="main-content" | ||
initial={{ opacity: 0 }} | ||
animate={{ opacity: 1 }} | ||
exit={{ opacity: 0 }} | ||
transition={{ | ||
type: 'spring', | ||
mass: 0.35, | ||
stiffness: 75, | ||
duration: 0.3, | ||
}} | ||
> | ||
<Messages messages={messages} /> | ||
{children} | ||
</motion.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import React from 'react'; | ||
|
||
import { PageTransition } from '../Molecules/PageTransition'; | ||
import { ContentHub as ContentHubOrganism } from '../Organisms/ContentHub'; | ||
|
||
export function ContentHub(props: { pageSize: number }) { | ||
return <ContentHubOrganism pageSize={props.pageSize} />; | ||
return ( | ||
<PageTransition> | ||
<ContentHubOrganism pageSize={props.pageSize} /> | ||
</PageTransition> | ||
); | ||
} |
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