diff --git a/sample-apps/react/react-dogfood/components/Countdown.tsx b/sample-apps/react/react-dogfood/components/Countdown.tsx deleted file mode 100644 index c92290d71d..0000000000 --- a/sample-apps/react/react-dogfood/components/Countdown.tsx +++ /dev/null @@ -1,131 +0,0 @@ -import { useEffect, useState } from 'react'; -import { Box, Stack } from '@mui/material'; - -const PUNCHLINES = [ - 'Countdown to Launching Video. Let’s go! πŸš€', - 'Less than 24 hours until launch. Keep Pushing! πŸ’ͺ', - 'Video has been launched! πŸŽ‰πŸš€ Keep Pushing! πŸ’ͺ', -]; - -const formatValue = (value: number) => - value < 10 ? `0${value}` : value.toString(); - -const divMod = (dividend: number, divisor: number) => [ - Math.floor(dividend / divisor), - dividend % divisor, -]; -const calculateTimeLeft = (deadline: number) => { - const now = new Date().getTime(); - const totalSecondsLeft = Math.round((deadline - now) / 1000); - - if (totalSecondsLeft <= 0) - return { totalSecondsLeft: 0, days: 0, hours: 0, minutes: 0, seconds: 0 }; - const [days, minusDaysLeft] = divMod(totalSecondsLeft, 24 * 3600); - const [hours, minusHoursLeft] = divMod(minusDaysLeft, 3600); - const [minutes, seconds] = divMod(minusHoursLeft, 60); - - return { - totalSecondsLeft, - days, - hours, - minutes, - seconds, - }; -}; - -type CountdownProps = { - deadlineTimestamp: number; -}; - -export const Countdown = ({ deadlineTimestamp }: CountdownProps) => { - const [left, setLeft] = useState(calculateTimeLeft(deadlineTimestamp)); - - useEffect(() => { - const interval = setInterval( - () => setLeft(calculateTimeLeft(deadlineTimestamp)), - 1000, - ); - return () => { - clearInterval(interval); - }; - }, [deadlineTimestamp]); - - return ( - - - {left.totalSecondsLeft <= 0 - ? PUNCHLINES[2] - : left.days === 0 - ? PUNCHLINES[1] - : PUNCHLINES[0]} - - 0 ? '#212326' : '#005FFF', - }} - > - - - - - - - ); -}; - -type CounterBoxProps = { - amount: number; - unit: 'days' | 'hours' | 'minutes' | 'seconds'; -}; - -const CounterBox = ({ amount, unit }: CounterBoxProps) => ( - - - {formatValue(amount)} - - - {unit} - - -);