-
-
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: FRON-11 showcase next upcoming event (#26)
- Loading branch information
1 parent
5261264
commit c6b2629
Showing
12 changed files
with
232 additions
and
99 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,36 @@ | ||
'use client'; | ||
|
||
import { useAtom } from 'jotai'; | ||
|
||
import { nextEventAtom, nextEventLiveAtom } from '@/atoms/nextEvent'; | ||
import { formatSessionUrl } from '@/utils/transformers'; | ||
|
||
import { EventCountDown } from '../ui/EventCountdown'; | ||
|
||
export const LandingNextEvent = () => { | ||
const [nextEvent] = useAtom(nextEventAtom); | ||
const [liveEvent] = useAtom(nextEventLiveAtom); | ||
|
||
return ( | ||
<div className='flex bg-base-300 px-4 py-8'> | ||
{nextEvent && ( | ||
<div className='mx-auto'> | ||
<h2 className='text-4xl font-bold'>{nextEvent.name}</h2> | ||
<p className='text-2xl'> | ||
{liveEvent ? ( | ||
nextEvent.session + ' Live Now' | ||
) : ( | ||
<> | ||
{formatSessionUrl(nextEvent.session).toUpperCase()} in{' '} | ||
<EventCountDown /> | ||
</> | ||
)} | ||
</p> | ||
<button className='btn btn-secondary btn-sm my-2'> | ||
Previous Results | ||
</button> | ||
</div> | ||
)} | ||
</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
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,18 @@ | ||
import clsx from 'clsx'; | ||
|
||
import { formatDuration } from '@/utils/helpers'; | ||
|
||
export const Countdown = ({ | ||
time, | ||
className, | ||
}: { | ||
time: number; | ||
className?: string; | ||
}) => { | ||
return ( | ||
<span className={clsx(className)}> | ||
{/* Remove last 4 characters which as milliseconds */} | ||
{formatDuration(time).slice(0, -4)} | ||
</span> | ||
); | ||
}; |
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,10 @@ | ||
import { useAtom } from 'jotai'; | ||
|
||
import { nextEventTimeAtom } from '@/atoms/nextEvent'; | ||
|
||
import { Countdown } from './Countdown'; | ||
|
||
export const EventCountDown = () => { | ||
const [nextEventCountdown] = useAtom(nextEventTimeAtom); | ||
return <Countdown time={nextEventCountdown} />; | ||
}; |
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.
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,15 @@ | ||
import { atom } from 'jotai'; | ||
import { atomEffect } from 'jotai-effect'; | ||
|
||
// Next Event | ||
export const nextEventLiveAtom = atom(false); | ||
export const nextEventAtom = atom<NextEventProps | null>(null); | ||
export const nextEventTimeAtom = atom(0); | ||
export const nextEventEffect = atomEffect((get, set) => { | ||
if (get(nextEventTimeAtom) !== 0) { | ||
const intervalId = setInterval(() => { | ||
set(nextEventTimeAtom, (prev: number) => prev - 1000); | ||
}, 1000); | ||
return () => clearInterval(intervalId); | ||
} | ||
}); |
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
Oops, something went wrong.