|
@@ -1,8 +1,11 @@
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
|
import s from './TimerPresentation.module.css';
|
|
|
+interface ITimerPresentationProps {
|
|
|
+ seconds: number;
|
|
|
+}
|
|
|
|
|
|
-const TimerPresentation = () => {
|
|
|
+const TimerPresentation = ({ seconds }: ITimerPresentationProps) => {
|
|
|
useEffect(() => {
|
|
|
function setRotation(el: HTMLDivElement, rotationRatio: number) {
|
|
|
el.style.setProperty('--rotation', String(rotationRatio * 360));
|
|
@@ -17,7 +20,7 @@ const TimerPresentation = () => {
|
|
|
'[data-second-hand]',
|
|
|
) as HTMLDivElement;
|
|
|
function setClock() {
|
|
|
- const currentDate = new Date();
|
|
|
+ const currentDate = new Date(seconds * 1000);
|
|
|
const secondsRatio = currentDate.getSeconds() / 60;
|
|
|
const minutesRatio = (secondsRatio + currentDate.getMinutes()) / 60;
|
|
|
const hoursRatio = (minutesRatio + currentDate.getHours()) / 12;
|
|
@@ -28,7 +31,7 @@ const TimerPresentation = () => {
|
|
|
setClock();
|
|
|
const idInterval = setInterval(setClock, 1000);
|
|
|
return () => clearInterval(idInterval);
|
|
|
- }, []);
|
|
|
+ }, [seconds]);
|
|
|
|
|
|
return (
|
|
|
<div className={s.clock}>
|