feat: add reverse timer

This commit is contained in:
MAZE
2024-08-31 19:39:31 +03:30
parent f3cea66847
commit 105f53ea02
8 changed files with 97 additions and 33 deletions

View File

@@ -0,0 +1,31 @@
import { Reverse } from './reverse';
import { padNumber } from '@/helpers/number';
import styles from './timer.module.css';
interface TimerProps {
reverse: number;
timer: number;
}
export function Timer({ reverse, timer }: TimerProps) {
let hours = Math.floor(timer / 3600);
let minutes = Math.floor((timer % 3600) / 60);
let seconds = timer % 60;
hours = isNaN(hours) ? 0 : hours;
minutes = isNaN(minutes) ? 0 : minutes;
seconds = isNaN(seconds) ? 0 : seconds;
const formattedHours = padNumber(hours);
const formattedMinutes = padNumber(minutes);
const formattedSeconds = padNumber(seconds);
return (
<div className={styles.timer}>
<Reverse time={reverse} />
{formattedHours}:{formattedMinutes}:{formattedSeconds}
</div>
);
}