Repository navigation
Refactor: Split timer UI, state, and hooks - #17
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the timer feature by separating storage-backed state (settings/UI state), timer measurement logic, and UI rendering into dedicated hooks/components, and consolidates config/utilities under lib/config and lib/deepMerge.
Changes:
- Replaces direct
useStorageusage in UI entrypoints withuseSettings/useUiStatehooks that normalize persisted state viadeepMerge. - Extracts content-script timer UI into
components/NumaTimerRoot+components/NumaTimerand timer tracking intohooks/useTimer. - Renames/moves shared constants/utilities into
lib/configand introduceslib/deepMergeas a shared util.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| popup.tsx | Switches popup settings UI to use the new useSettings hook and ~lib/config. |
| content.tsx | Simplifies content script entry to render NumaTimerRoot. |
| components/NumaTimerRoot.tsx | New root component wiring settings + UI state to the timer UI. |
| components/NumaTimer.tsx | New presentational timer UI component with collapse toggle + duration display. |
| hooks/useTimer.ts | New hook implementing ticking, visibility/focus handling, and periodic storage flushing. |
| hooks/useSettings.ts | New hook for settings storage with deep-merge normalization and partial updates. |
| hooks/useUiState.ts | New hook for UI state storage with deep-merge normalization and partial updates. |
| lib/deepMerge.ts | Adds reusable deep merge + DeepPartial type for partial state updates. |
| lib/config.ts | Consolidates config/constants and removes normalize* helpers (now handled by hooks). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
概要
タイマー表示ロジックと UI を分離し、設定/UI 状態/計測ロジックをそれぞれ独立した hooks・components に整理しました。
変更内容
Resolve #15