Skip to content

Commit 4bf34d6

Browse files
committed
feat: add tooltipContent on AnimatedTimer
1 parent b9c9bb2 commit 4bf34d6

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

src/Shared/Components/AnimatedTimer/AnimatedTimer.component.tsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useEffect } from 'react'
22
import { animate, motion, useMotionValue, useTransform } from 'framer-motion'
33

4+
import { Tooltip } from '@Common/Tooltip'
5+
46
import { CX, CY, END_ANGLE, RADIUS, START_ANGLE } from './constants'
57
import { 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

src/Shared/Components/AnimatedTimer/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { animate } from 'framer-motion'
22

3+
import { TooltipProps } from '@Common/Tooltip'
34
import { IconBaseSizeType } from '@Shared/index'
45

56
export interface AnimatedTimerProps extends Pick<Parameters<typeof animate>[2], 'onComplete'> {
@@ -12,4 +13,5 @@ export interface AnimatedTimerProps extends Pick<Parameters<typeof animate>[2],
1213
* @default 24
1314
*/
1415
size?: IconBaseSizeType
16+
tooltipContent?: TooltipProps['content']
1517
}

0 commit comments

Comments
 (0)