diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b947077 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ diff --git a/README.md b/README.md index e2fa34f..08a341e 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,4 @@ npm run dev - 倒數結束:加提示音(並可開關) - localStorage:記住上次模式與倒數秒數 - 視覺:波紋更慢、呼吸週期可調 -- 統計:今日累積專注時間 / 完成次數 +- 統計:今日累積專注時間 / 完成次數 diff --git a/src/App.jsx b/src/App.jsx index 69b2e95..d9aecb1 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([]); @@ -25,27 +25,36 @@ export default function App() { const progress = clamp(cd.remainingMs / total, 0, 1); return { ringProgress: progress, - waterLevel: progress, - title: "倒數", - subtitle: `總長 ${formatHMS(cd.totalMs)}`, + waterLevel: 1 - progress, + waterVariant: "countdown", + title: `倒數時長 ${formatHMS(cd.totalMs).slice(0, 5)}`, + subtitle: "", + flashKey: null, }; } // Stopwatch: make it feel calm by looping visuals each minute - const loop = 60 * 1000; + const loop = 10 * 1000; const phase = (sw.elapsedMs % loop) / loop; return { ringProgress: phase, - waterLevel: 0.15 + phase * 0.7, // keep some padding (never fully empty/full) - title: "碼表", - subtitle: sw.isRunning ? "流動中…" : "休息一下也很好", + waterLevel: 0.5, + waterVariant: "stopwatch", + title: "碼錶", + subtitle: sw.isRunning ? "流動中…" : "跑跑跑~向前跑~", + flashKey: + sw.isRunning && sw.elapsedMs >= 10000 + ? Math.floor(sw.elapsedMs / 10000) + : null, }; }, [mode, sw.elapsedMs, sw.isRunning, cd.remainingMs, cd.totalMs]); const primaryTime = mode === "stopwatch" ? formatHMS(sw.elapsedMs, { showMs: true }) - : formatHMS(cd.remainingMs); + : formatHMS(cd.remainingMs, { showMs: true }); + const isCountdownFinalSeconds = + mode === "countdown" && cd.totalMs > 0 && cd.remainingMs <= 10000; const onReset = () => { if (mode === "stopwatch") { @@ -62,15 +71,19 @@ export default function App() { }; const onPickPreset = (ms) => { - cd.setTotalWhileStopped(ms); + cd.addTotalWhileStopped(ms); + }; + + const onClearPreset = () => { + cd.clearTotalWhileStopped(); }; return ( -
+
Tide Timer
-
療癒型碼表 / 倒數
+
療癒型碼錶 / 倒數
{ // stop running when switching modes (keeps mental model simple) @@ -80,70 +93,86 @@ export default function App() { }} />
-
-
-
- - -
-
{viz.title}
- -
-
- - {mode === "countdown" ? ( -
- -
- 小提示:使用快速鍵,依點擊次數,初始時間可累加,或按 "清除" 重新設定。 +
+ {mode === "stopwatch" ? ( +
+
+
+ + + {mode === "stopwatch" && viz.flashKey !== null ? ( +
+ ) : null} +
+
{viz.title}
+ +
-
- ) : null} - - - Lap - - ) : null - } - /> - - {mode === "stopwatch" ? : null} - - {mode === "countdown" && cd.remainingMs === 0 ? ( -
- 完成 ✨ -
- ) : null} -
- -
-
-
你可以接著練的功能
-
    -
  • 倒數自訂:分鐘/秒輸入、滑桿、+10s/-10s
  • -
  • 音效開關(完成提示音)
  • -
  • localStorage:記住上次模式與倒數秒數
  • -
  • 更療癒:水波更慢、呼吸週期可調
  • -
  • 統計:今日累積專注時間 / 完成次數
  • -
+ + + 記錄 + + } + /> +
+ +
+ ) : ( +
+
+
+ + +
+
{viz.title}
+ +
+
-
-
部署到 GitHub Pages
-
    -
  1. 把整包檔案推到你的 GitHub repo
  2. -
  3. Repo Settings → Pages → Source 選 GitHub Actions
  4. -
  5. 等待 Actions 跑完,就會自動發佈
  6. -
+ + + {mode === "countdown" && cd.remainingMs === 0 ? ( +
+ 完成 ✨ +
+ ) : null} +
+ +
+
+
+ 按多次可累加時間,或按「清除」重新設定。 +
+ +
+
-
+ )}