add basic timer that always is showing

This commit is contained in:
Vikeo
2025-02-23 23:42:01 +01:00
parent c6039c2a53
commit e7e5882859
8 changed files with 381 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
import { useStopwatch } from 'react-timer-hook';
import { TimerStyle, TimerWrapper } from './Timer';
import { Time } from './Time';
export const NegativeStopWatch = ({
autoStart = false,
}: {
autoStart?: boolean;
}) => {
// Initialize the timer using the useTimer hook.
const { seconds, minutes, hours, isRunning, start, pause } = useStopwatch({
autoStart,
});
return (
<TimerWrapper>
<TimerStyle>
{'-'}
<Time time={{ hours, minutes, seconds }} />
<div>
{/* Only show Start if the timer is not running */}
{!isRunning && <button onClick={start}>Start</button>}
{isRunning && <button onClick={pause}>Pause</button>}
</div>
</TimerStyle>
</TimerWrapper>
);
};