Skip to content

Commit b0e10ac

Browse files
committed
feat: MissionTimer에 툴팁 추가 및 애니메이션 효과 적용
1 parent 8b7f945 commit b0e10ac

File tree

2 files changed

+64
-29
lines changed

2 files changed

+64
-29
lines changed

src/routes/mission/-components/MissionTimer.tsx

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
22
import { useNavigate } from "@tanstack/react-router";
3+
import { motion } from "motion/react";
4+
import { Tooltip } from "radix-ui";
35
import { useEffect, useRef, useState } from "react";
46
import { Timer } from "@/components/timer/Timer";
57
import {
@@ -14,10 +16,14 @@ import StopIcon from "../../../components/icons/StopIcon";
1416

1517
const HOLD_MS = 1000;
1618

19+
const MotionTooltipContent = motion.create(Tooltip.Content);
20+
1721
export default function MissionTimer({
1822
showMockStopButton,
23+
isTooltipOpen,
1924
}: {
2025
showMockStopButton: boolean;
26+
isTooltipOpen: boolean;
2127
}) {
2228
const queryClient = useQueryClient();
2329
const navigate = useNavigate();
@@ -133,33 +139,60 @@ export default function MissionTimer({
133139
seconds={time}
134140
className="t-p-42-b text-neutral-100 tracking-[-1.05px] leading-[54.6px]"
135141
/>
136-
<button
137-
type="button"
138-
onClick={handleToggle}
139-
onMouseDown={startHoldToStop}
140-
onMouseUp={cancelHoldToStop}
141-
onMouseLeave={cancelHoldToStop}
142-
onTouchStart={startHoldToStop}
143-
onTouchEnd={cancelHoldToStop}
144-
onContextMenu={(e) => e.preventDefault()}
145-
id={showStopButton ? "timer-stop-button" : "timer-play-button"}
146-
className={`w-10 h-10 rounded-full flex items-center justify-center transition-transform duration-1000 ease-in ${
147-
isHolding && showStopButton
148-
? "scale-150 bg-neutral-200"
149-
: "bg-neutral-100"
150-
}`}
151-
aria-label={showStopButton ? "정지하기" : "시작하기"}
152-
>
153-
{showStopButton ? (
154-
<StopIcon
155-
variant={isHolding ? "red" : "dark"}
156-
width={16}
157-
height={16}
158-
/>
159-
) : (
160-
<PlayIcon variant="dark" width={16} height={16} />
161-
)}
162-
</button>
142+
<Tooltip.Provider>
143+
<Tooltip.Root open={isTooltipOpen}>
144+
<Tooltip.Trigger asChild>
145+
<button
146+
type="button"
147+
onClick={handleToggle}
148+
onMouseDown={startHoldToStop}
149+
onMouseUp={cancelHoldToStop}
150+
onMouseLeave={cancelHoldToStop}
151+
onTouchStart={startHoldToStop}
152+
onTouchEnd={cancelHoldToStop}
153+
onContextMenu={(e) => e.preventDefault()}
154+
id={showStopButton ? "timer-stop-button" : "timer-play-button"}
155+
className={`w-10 h-10 rounded-full flex items-center justify-center transition-transform duration-1000 ease-in ${
156+
isHolding && showStopButton
157+
? "scale-150 bg-neutral-200"
158+
: "bg-neutral-100"
159+
}`}
160+
aria-label={showStopButton ? "정지하기" : "시작하기"}
161+
>
162+
{showStopButton ? (
163+
<StopIcon
164+
variant={isHolding ? "red" : "dark"}
165+
width={16}
166+
height={16}
167+
/>
168+
) : (
169+
<PlayIcon variant="dark" width={16} height={16} />
170+
)}
171+
</button>
172+
</Tooltip.Trigger>
173+
<Tooltip.Portal>
174+
<MotionTooltipContent
175+
initial={{ opacity: 0, y: 10 }}
176+
animate={{
177+
opacity: 1,
178+
y: [0, -4, 0],
179+
scale: [1, 1, 1],
180+
}}
181+
exit={{ opacity: 0, y: 10 }}
182+
transition={{
183+
duration: 2,
184+
repeat: Infinity,
185+
ease: "easeInOut",
186+
}}
187+
className="select-none rounded-[8px] bg-white px-[15px] py-2 text-[15px] leading-none text-violet11 shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] will-change-[transform,opacity] data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade"
188+
sideOffset={5}
189+
>
190+
<p className="t-p-14-sb text-blue-500">시작</p>
191+
<Tooltip.Arrow className="fill-white" />
192+
</MotionTooltipContent>
193+
</Tooltip.Portal>
194+
</Tooltip.Root>
195+
</Tooltip.Provider>
163196
</div>
164197
);
165198
}

src/routes/mission/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ function Mission() {
262262
)}
263263
</div>
264264
)}
265-
266-
<MissionTimer showMockStopButton={showMockStopButton} />
265+
<MissionTimer
266+
showMockStopButton={showMockStopButton}
267+
isTooltipOpen={!isSessionStarted}
268+
/>
267269
</div>
268270
);
269271
}

0 commit comments

Comments
 (0)