1- import { createSignal , onCleanup } from 'solid-js' ;
1+ import { onCleanup } from 'solid-js' ;
22
33import { ClockLine as ClockHand } from '@/ClockLine' ;
4- import { hours , rotate , seconds } from '@/common ' ;
4+ import { time } from '@/time ' ;
55import { getTestId } from '@/utilities' ;
66
7- const getSecondsSinceMidnight = ( ) : number =>
8- ( Date . now ( ) - new Date ( ) . setHours ( 0 , 0 , 0 , 0 ) ) / 1000 ;
9-
107export const ClockHands = ( ) => {
11- const [ time , setTime ] = createSignal ( getSecondsSinceMidnight ( ) ) ;
12-
13- const subsecond = ( ) => rotate ( time ( ) % 1 , 0 ) ;
14- const second = ( ) => rotate ( ( time ( ) % seconds ) / seconds ) ;
15- const minute = ( ) => rotate ( ( ( time ( ) / seconds ) % seconds ) / seconds ) ;
16- const hour = ( ) => rotate ( ( ( time ( ) / seconds ** 2 ) % hours ) / hours ) ;
17-
188 let frame = requestAnimationFrame ( function loop ( ) {
19- setTime ( getSecondsSinceMidnight ( ) ) ;
9+ time . update ( ) ;
2010 frame = requestAnimationFrame ( loop ) ;
2111 } ) ;
2212
@@ -30,22 +20,22 @@ export const ClockHands = () => {
3020 class = "stroke-zinc-200 stroke-3 dark:stroke-zinc-600"
3121 data-testid = { getTestId ( 'subsecond' ) }
3222 length = { 82 }
33- transform = { subsecond ( ) }
23+ transform = { time . milisecond }
3424 />
3525 < ClockHand
3626 class = "stroke-zinc-600 stroke-4 dark:stroke-zinc-200"
3727 length = { 46 }
38- transform = { hour ( ) }
28+ transform = { time . hour }
3929 />
4030 < ClockHand
4131 class = "stroke-zinc-400 stroke-3"
4232 length = { 64 }
43- transform = { minute ( ) }
33+ transform = { time . minute }
4434 />
4535 < ClockHand
4636 class = "stroke-solid-light stroke-2 dark:stroke-solid"
4737 length = { 76 }
48- transform = { second ( ) }
38+ transform = { time . second }
4939 />
5040 </ >
5141 ) ;
0 commit comments