-
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.
- Loading branch information
Showing
21 changed files
with
184 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,47 @@ | ||
import Title from '@/components/Title/Title'; | ||
import clsx from 'clsx'; | ||
import Link from 'next/link'; | ||
import AppearInViewport from '@/components/AppearInViewport/AppearInViewport'; | ||
import MainPageVideoPlayer from '@/components/MainPageVideoPlayer/MainPageVideoPlayer'; | ||
|
||
const containerCn = clsx('relative', 'z-10', 'flex', 'flex-col', 'items-center', 'grow'); | ||
const titleCn = clsx('font-light', 'text-8xl'); | ||
const subtitleCn = clsx('text-1.5xl', 'font-light', 'tracking-widest', 'text-center'); | ||
const titleContainerCn = clsx('font-sans', 'select-none'); | ||
const exploreCn = clsx('text-center', 'text-2xl', 'mt-auto'); | ||
const exploreLinkCn = clsx('tracking-wider', 'animated-link'); | ||
|
||
const exploreLinkVariants = { | ||
visible: {opacity: 1, y: 0, scale: 1}, | ||
hidden: {opacity: 0, y: '2rem', scale: 0.9}, | ||
}; | ||
|
||
/** | ||
* @returns React component. | ||
*/ | ||
export default function Home() { | ||
return ( | ||
<div className="container"> | ||
<Title /> | ||
</div> | ||
<> | ||
<div className={containerCn}> | ||
<AppearInViewport className={titleContainerCn}> | ||
<h1 className={titleCn}> | ||
SALSA<span className="font-extrabold">VIVA</span> | ||
</h1> | ||
<h6 className={subtitleCn}>SOCIAL DANCE SCHOOL</h6> | ||
</AppearInViewport> | ||
<AppearInViewport | ||
transition={{delay: 1.2}} | ||
className={exploreCn} | ||
variants={exploreLinkVariants} | ||
> | ||
<Link | ||
href="/about" | ||
className={exploreLinkCn} | ||
> | ||
EXPLORE | ||
</Link> | ||
</AppearInViewport> | ||
</div> | ||
<MainPageVideoPlayer /> | ||
</> | ||
); | ||
} |
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,35 @@ | ||
'use client'; | ||
|
||
import clsx from 'clsx'; | ||
import {AnimatePresence} from 'framer-motion'; | ||
import {useState} from 'react'; | ||
import bgVideoConfig from './bgVideosConfig'; | ||
import VideoBackground from './VideoBackground'; | ||
|
||
const containerCn = clsx('fixed', 'top-0', 'left-0', 'w-full', 'h-full'); | ||
|
||
/** | ||
* @returns React component. | ||
*/ | ||
export default function MainPageVideoPlayer() { | ||
const [vidIndex, setVidIndex] = useState(0); | ||
// eslint-disable-next-line jsdoc/require-jsdoc | ||
const incrementVidIndex = () => | ||
vidIndex < bgVideoConfig.length - 1 ? setVidIndex(vidIndex + 1) : setVidIndex(0); | ||
const {src, type} = bgVideoConfig[vidIndex]; | ||
|
||
return ( | ||
<div className={containerCn}> | ||
<AnimatePresence mode="wait"> | ||
{ | ||
<VideoBackground | ||
key={src} | ||
src={src} | ||
type={type} | ||
onBeforeEnded={incrementVidIndex} | ||
/> | ||
} | ||
</AnimatePresence> | ||
</div> | ||
); | ||
} |
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,52 @@ | ||
import clsx from 'clsx'; | ||
import {m} from 'framer-motion'; | ||
import {usePageVisibility} from 'react-page-visibility'; | ||
import {useEffect} from 'react'; | ||
import useVideoBeforeEnd from './useVideoBeforeEnd'; | ||
|
||
/** | ||
* Props. | ||
*/ | ||
type VideoBackgroundProps = { | ||
src: string; | ||
type: string; | ||
onBeforeEnded: () => void; | ||
}; | ||
|
||
const videoCn = clsx('w-full', 'h-full', 'object-cover'); | ||
|
||
/** | ||
* @param {VideoBackgroundProps} props Props. | ||
* @returns React component. | ||
*/ | ||
export default function VideoBackground({src, type, onBeforeEnded}: VideoBackgroundProps) { | ||
const [ref] = useVideoBeforeEnd(onBeforeEnded, 1.5); | ||
const isVisible = usePageVisibility(); | ||
|
||
useEffect(() => { | ||
if (isVisible) { | ||
ref.current?.play(); | ||
} else { | ||
ref.current?.pause(); | ||
} | ||
}, [isVisible, ref]); | ||
|
||
return ( | ||
<m.video | ||
muted | ||
autoPlay | ||
className={videoCn} | ||
initial={{opacity: 0, scale: 1.5}} | ||
animate={{opacity: 1, scale: 1}} | ||
exit={{opacity: 0, scale: 1.3}} | ||
transition={{duration: 0.75, type: 'easeOut'}} | ||
ref={ref} | ||
> | ||
<source | ||
src={src} | ||
type={type} | ||
/> | ||
<track kind="captions" /> | ||
</m.video> | ||
); | ||
} |
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,12 @@ | ||
/** | ||
* Config for the background videos. | ||
*/ | ||
const bgVideoConfig = [ | ||
{src: '/videos/main.0.mp4', type: 'video/mp4'}, | ||
{src: '/videos/main.1.mp4', type: 'video/mp4'}, | ||
{src: '/videos/main.2.mp4', type: 'video/mp4'}, | ||
{src: '/videos/main.3.mp4', type: 'video/mp4'}, | ||
{src: '/videos/main.4.mp4', type: 'video/mp4'}, | ||
] as const; | ||
|
||
export default bgVideoConfig; |
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,30 @@ | ||
import {useEffect, useRef} from 'react'; | ||
|
||
/** | ||
* Run callback when video is about to end. | ||
* @param onBeforeEnd Callback to run when video is about to end. | ||
* @param timeBeforeEnd Time before end in seconds. | ||
* @returns Ref to the video element. | ||
*/ | ||
export default function useVideoBeforeEnd(onBeforeEnd: () => void, timeBeforeEnd: number) { | ||
const ref = useRef<HTMLVideoElement>(null); | ||
|
||
useEffect(() => { | ||
const video = ref.current!; | ||
// eslint-disable-next-line jsdoc/require-jsdoc | ||
const handleTimeUpdate = () => { | ||
if (video.currentTime > video.duration - timeBeforeEnd) { | ||
onBeforeEnd(); | ||
} | ||
}; | ||
|
||
if (video) { | ||
video.addEventListener('timeupdate', handleTimeUpdate); | ||
return () => { | ||
video.removeEventListener('timeupdate', handleTimeUpdate); | ||
}; | ||
} | ||
}, [ref, onBeforeEnd, timeBeforeEnd]); | ||
|
||
return [ref]; | ||
} |
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
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 was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.