Skip to content

Refactor: Split timer UI, state, and hooks - #17

Merged
Kyo-s-s merged 4 commits into
mainfrom
refactor-timer
Mar 11, 2026
Merged

Kyo-s-s merged 4 commits into
mainfrom
refactor-timer

Conversation

@Kyo-s-s

@Kyo-s-s Kyo-s-s commented Mar 11, 2026 •

Copy link
Copy Markdown
Owner

概要

タイマー表示ロジックと UI を分離し、設定/UI 状態/計測ロジックをそれぞれ独立した hooks・components に整理しました。

変更内容

  • content script を entry のみに整理
  • NumaTimer / NumaTimerRoot を components に分離
  • 設定/表示状態/計測の hooks を hooks 配下へ移動(差分更新対応)
  • deepMerge を共通 util として切り出し
  • 設定・UI 状態の storage 正規化を hooks 側に集約
  • lib/numa-timer を lib/config にリネーム

Resolve #15

@Kyo-s-s Kyo-s-s changed the title Refactor: Timer components split Refactor: Split timer UI, state, and hooks Mar 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useStorage usage in UI entrypoints with useSettings / useUiState hooks that normalize persisted state via deepMerge.
  • Extracts content-script timer UI into components/NumaTimerRoot + components/NumaTimer and timer tracking into hooks/useTimer.
  • Renames/moves shared constants/utilities into lib/config and introduces lib/deepMerge as 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.

Comment thread hooks/useSettings.ts Outdated
Comment thread hooks/useUiState.ts Outdated
Comment thread hooks/useTimer.ts
Comment thread components/NumaTimer.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/deepMerge.ts
Comment thread hooks/useTimer.ts
Comment thread hooks/useTimer.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread hooks/useTimer.ts Outdated
Comment thread lib/deepMerge.ts
@Kyo-s-s
Kyo-s-s merged commit 7c00a46 into main Mar 11, 2026
2 checks passed
@Kyo-s-s
Kyo-s-s deleted the refactor-timer branch March 11, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: 表示するか否かのチェックとタイマー自体のコンポーネントを分離させる

2 participants