From 69659f00be1c314c7d1c1a3f16c974149f276291 Mon Sep 17 00:00:00 2001 From: ethan-CCY Date: Mon, 22 Dec 2025 15:04:02 +0800 Subject: [PATCH 1/2] Update countdown visuals and controls --- src/App.jsx | 16 ++++-- src/components/Controls.jsx | 4 +- src/components/TimeDisplay.jsx | 11 +++-- src/components/WaterGauge.jsx | 27 +++++----- src/styles.css | 90 +++++++++++++++++++++++++++++----- 5 files changed, 111 insertions(+), 37 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 752fc09..2526f83 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -12,7 +12,7 @@ import { useCountdown, useStopwatch } from "./lib/hooks.js"; export default function App() { const [mode, setMode] = useState("stopwatch"); // "stopwatch" | "countdown" const sw = useStopwatch(); - const cd = useCountdown(5 * 60 * 1000); + const cd = useCountdown(0); const [laps, setLaps] = useState([]); @@ -53,6 +53,8 @@ export default function App() { mode === "stopwatch" ? formatHMS(sw.elapsedMs, { showMs: true }) : formatHMS(cd.remainingMs, { showMs: true }); + const isCountdownFinalSeconds = + mode === "countdown" && cd.totalMs > 0 && cd.remainingMs <= 5000; const onReset = () => { if (mode === "stopwatch") { @@ -134,7 +136,11 @@ export default function App() {
{viz.title}
- +
@@ -155,14 +161,14 @@ export default function App() {
+
+ 按多次可累加時間,或按「清除」重新設定。 +
-
- 按多次可累加時間,或按「清除」重新設定。 -
diff --git a/src/components/Controls.jsx b/src/components/Controls.jsx index f8f9c2a..cad50a1 100644 --- a/src/components/Controls.jsx +++ b/src/components/Controls.jsx @@ -19,8 +19,8 @@ export default function Controls({ > {isRunning ? "暫停" : "開始"} - {extraRight} diff --git a/src/components/TimeDisplay.jsx b/src/components/TimeDisplay.jsx index 2c84fa2..b39b36a 100644 --- a/src/components/TimeDisplay.jsx +++ b/src/components/TimeDisplay.jsx @@ -1,11 +1,16 @@ import React from "react"; -export default function TimeDisplay({ primary, secondary }) { +export default function TimeDisplay({ + primary, + secondary, + className = "", + primaryClassName = "", +}) { const [main, ms] = String(primary || "").split("."); return ( -
-
+
+
{main} {ms ? .{ms} : null}
diff --git a/src/components/WaterGauge.jsx b/src/components/WaterGauge.jsx index 80d8118..649fa56 100644 --- a/src/components/WaterGauge.jsx +++ b/src/components/WaterGauge.jsx @@ -3,34 +3,29 @@ import { clamp } from "../lib/time.js"; /** * WaterGauge: soothing water level + slow wave drift (countdown), - * or static dark plate for stopwatch. + * or static wavy water for stopwatch. * level: 0..1 (1 = full) for animated mode */ export default function WaterGauge({ level = 0.5, variant = "countdown", size = 220 }) { - if (variant === "stopwatch") { - return ( -