-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Showing
10 changed files
with
219 additions
and
33 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/(pages)/(components)/page-transition/transition.context.js
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,25 @@ | ||
'use client' | ||
|
||
import gsap from 'gsap' | ||
import { createContext, useState } from 'react' | ||
|
||
const TransitionContext = createContext({}) | ||
|
||
const TransitionProvider = ({ children }) => { | ||
const [timeline, setTimeline] = useState(() => | ||
gsap.timeline({ paused: true }), | ||
) | ||
|
||
return ( | ||
<TransitionContext.Provider | ||
value={{ | ||
timeline, | ||
setTimeline, | ||
}} | ||
> | ||
{children} | ||
</TransitionContext.Provider> | ||
) | ||
} | ||
|
||
export { TransitionContext, TransitionProvider } |
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,29 +1,37 @@ | ||
import cn from 'clsx' | ||
import { Lenis } from 'libs/lenis' | ||
import { Canvas } from 'libs/webgl/components/canvas' | ||
import { forwardRef } from 'react' | ||
import { Footer } from '../footer' | ||
import { Navigation } from '../navigation' | ||
import s from './wrapper.module.scss' | ||
|
||
export function Wrapper({ | ||
children, | ||
theme = 'light', | ||
lenis = true, | ||
lenisOptions = {}, | ||
webgl = false, | ||
className, | ||
}) { | ||
return ( | ||
<> | ||
{lenis && <Lenis root options={lenisOptions} />} | ||
{webgl && <Canvas root />} | ||
<div className={cn(s.wrapper, `theme-${theme}`, className)}> | ||
<Navigation /> | ||
<main role="main" className={s.main}> | ||
{children} | ||
</main> | ||
<Footer /> | ||
</div> | ||
</> | ||
) | ||
} | ||
export const Wrapper = forwardRef( | ||
( | ||
{ | ||
children, | ||
theme = 'light', | ||
lenis = true, | ||
lenisOptions = {}, | ||
webgl = false, | ||
className, | ||
}, | ||
ref, | ||
) => { | ||
return ( | ||
<> | ||
{lenis && <Lenis root options={lenisOptions} />} | ||
<div className={cn(s.wrapper, `theme-${theme}`, className)}> | ||
<Navigation /> | ||
<main ref={ref} role="main" className={s.main}> | ||
{webgl && <Canvas root />} | ||
{children} | ||
</main> | ||
<Footer /> | ||
</div> | ||
</> | ||
) | ||
}, | ||
) | ||
|
||
Wrapper.displayName = 'Wrapper' |
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,4 +1,18 @@ | ||
.page { | ||
text-transform: uppercase; | ||
font-family: var(--font-ibm-plex-mono); | ||
|
||
.inner { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
width: 50%; | ||
margin: auto; | ||
|
||
@include mobile { | ||
padding: 0 mobile-vw(16px); | ||
} | ||
} | ||
} |
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,10 +1,52 @@ | ||
'use client' | ||
|
||
import { useGSAP } from '@gsap/react' | ||
import gsap from 'gsap' | ||
import { useContext, useRef } from 'react' | ||
import { TransitionContext } from '../(components)/page-transition/transition.context' | ||
import { Wrapper } from '../(components)/wrapper' | ||
import s from './home.module.scss' | ||
|
||
gsap.registerPlugin(useGSAP) | ||
|
||
export default function Home() { | ||
const { timeline } = useContext(TransitionContext) | ||
const container = useRef(null) | ||
|
||
useGSAP( | ||
() => { | ||
gsap.fromTo( | ||
'p', | ||
{ y: 30, opacity: 0 }, | ||
{ y: 0, opacity: 1, stagger: 0.25 }, | ||
) | ||
timeline.add(gsap.to(container.current, { opacity: 0 })) | ||
}, | ||
{ scope: container }, | ||
) | ||
|
||
return ( | ||
<Wrapper theme="red" className={s.page}> | ||
{/* content */} | ||
<Wrapper ref={container} theme="red" className={s.page}> | ||
<section className={s.inner}> | ||
<p> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. | ||
Necessitatibus, nobis. Adipisci debitis maiores dolorem optio | ||
architecto omnis dolor dolores autem. Vel doloribus, placeat ipsam | ||
harum quasi velit cumque dignissimos doloremque? | ||
</p> | ||
<p> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. | ||
Necessitatibus, nobis. Adipisci debitis maiores dolorem optio | ||
architecto omnis dolor dolores autem. Vel doloribus, placeat ipsam | ||
harum quasi velit cumque dignissimos doloremque? | ||
</p> | ||
<p> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. | ||
Necessitatibus, nobis. Adipisci debitis maiores dolorem optio | ||
architecto omnis dolor dolores autem. Vel doloribus, placeat ipsam | ||
harum quasi velit cumque dignissimos doloremque? | ||
</p> | ||
</section> | ||
</Wrapper> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,5 +1,30 @@ | ||
import { PageTransition } from 'app/(pages)/(components)/page-transition' | ||
'use client' | ||
|
||
export default function Template({ children }) { | ||
return <PageTransition>{children}</PageTransition> | ||
import { useGSAP } from '@gsap/react' | ||
|
||
import gsap from 'gsap' | ||
|
||
import { useContext, useEffect, useState } from 'react' | ||
import { TransitionContext } from './(components)/page-transition/transition.context' | ||
|
||
gsap.registerPlugin(useGSAP) | ||
|
||
export default function Template(props) { | ||
const { children } = props | ||
const [displayChildren, setDisplayChildren] = useState(children) | ||
const { timeline } = useContext(TransitionContext) | ||
|
||
useEffect(() => { | ||
console.log('pause', props) | ||
timeline.pause().clear() | ||
return () => { | ||
console.log('play', props) | ||
timeline.play().then(() => { | ||
window.scrollTo(0, 0) | ||
setDisplayChildren(children) | ||
}) | ||
} | ||
}, [children]) | ||
|
||
return displayChildren | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.