11import { useEffect } from 'react'
22import { animate , motion , useMotionValue , useTransform } from 'framer-motion'
33
4+ import { Tooltip } from '@Common/Tooltip'
5+
46import { CX , CY , END_ANGLE , RADIUS , START_ANGLE } from './constants'
57import { AnimatedTimerProps } from './types'
68
@@ -26,7 +28,7 @@ const describeArcPath = (cx: number, cy: number, r: number, endAngle: number) =>
2628 `
2729}
2830
29- const AnimatedTimer = ( { duration, onComplete, size = 24 } : AnimatedTimerProps ) => {
31+ const AnimatedTimer = ( { duration, onComplete, size = 24 , tooltipContent } : AnimatedTimerProps ) => {
3032 const angle = useMotionValue < number > ( START_ANGLE )
3133 const d = useTransform ( angle , ( currentAngle ) => describeArcPath ( CX , CY , RADIUS , currentAngle ) )
3234 useEffect ( ( ) => {
@@ -39,23 +41,27 @@ const AnimatedTimer = ({ duration, onComplete, size = 24 }: AnimatedTimerProps)
3941 } , [ duration ] )
4042
4143 return (
42- < svg
43- width = { CX * 2 }
44- height = { CY * 2 }
45- viewBox = { `0 0 ${ CX * 2 } ${ CY * 2 } ` }
46- fill = "none"
47- xmlns = "http://www.w3.org/2000/svg"
48- className = { `icon-dim-${ size } ` }
49- >
50- < path
51- fillRule = "evenodd"
52- clipRule = "evenodd"
53- d = "M12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12Z"
54- fill = "var(--O500)"
55- />
56-
57- < motion . path fill = "var(--O200)" d = { d } />
58- </ svg >
44+ < Tooltip alwaysShowTippyOnHover = { ! ! tooltipContent } content = { tooltipContent } >
45+ < div >
46+ < svg
47+ width = { CX * 2 }
48+ height = { CY * 2 }
49+ viewBox = { `0 0 ${ CX * 2 } ${ CY * 2 } ` }
50+ fill = "none"
51+ xmlns = "http://www.w3.org/2000/svg"
52+ className = { `icon-dim-${ size } ` }
53+ >
54+ < path
55+ fillRule = "evenodd"
56+ clipRule = "evenodd"
57+ d = "M12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12Z"
58+ fill = "var(--O500)"
59+ />
60+
61+ < motion . path fill = "var(--O200)" d = { d } />
62+ </ svg >
63+ </ div >
64+ </ Tooltip >
5965 )
6066}
6167
0 commit comments