feat: add reatomThemePreference reusable#18
Open
Guria wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Reatom reusable reatomThemePreference that models a persisted three-state theme preference ('system' | 'light' | 'dark') and exposes a derived resolved computed ('light' | 'dark') based on (prefers-color-scheme: dark) when the preference is 'system'.
Changes:
- Introduces
reatomThemePreferencefactory with localStorage persistence and aresolvedcomputed. - Adds browser tests, usage example, and documentation for the new reusable.
- Registers the reusable in
registry.jsonvia a corresponding*.meta.tsentry.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/reusables/theme/reatom-theme-preference.ts | Implements the persisted theme preference atom and resolved computed. |
| src/reusables/theme/reatom-theme-preference.browser.test.ts | Adds browser-focused tests covering defaults, persistence, coercion, and resolution behavior. |
| src/reusables/theme/reatom-theme-preference.md | Documents API, usage, and DOM-application patterns for the resolved theme. |
| src/reusables/theme/reatom-theme-preference.example.ts | Provides a runnable usage example demonstrating persistence and DOM updates. |
| src/reusables/theme/reatom-theme-preference.meta.ts | Declares the reusable’s registry metadata (files, roles). |
| registry.json | Adds the new reusable entry to the generated registry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
/rebuild-registry |
|
ℹ️ |
A factory that creates a persisted three-state theme-preference atom
('system' | 'light' | 'dark') backed by localStorage, extended with a
'resolved' computed that maps the 'system' preference through the
(prefers-color-scheme: dark) media query to a concrete 'light' | 'dark'
theme. Invalid persisted values coerce back to 'system'.
(gate run via 'corepack pnpm'; pre-commit hook uses bare 'pnpm' which the
mise shim cannot resolve in this worktree)
Guria
force-pushed
the
feat/reatom-theme-preference
branch
from
July 13, 2026 23:48
d426dbd to
318809e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
reatomThemePreference— a factory for the ubiquitous'system' | 'light' | 'dark'theme preference model.reatomEnumpersisted viawithLocalStorage(configurablekey, invalid snapshots coerce to'system').resolvedcomputed maps'system'throughreatomMediaQuery('(prefers-color-scheme: dark)')to a concrete'light' | 'dark'; explicit preferences pass through.src/shared/model/theme.ts).🤖 Generated with Claude Code