Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #656 +/- ##
=======================================
Coverage 75.90% 75.90%
=======================================
Files 145 145
Lines 13735 13735
Branches 992 992
=======================================
Hits 10426 10426
Misses 3303 3303
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
| File | Base | Head | Diff |
|---|---|---|---|
orama-db.json |
8.05 MB | 8.05 MB | +3.00 B (+0.00%) |
There was a problem hiding this comment.
Pull request overview
Refactors the web generator UI theming to track a theme preference (including system) and keep the applied document theme synced with OS color-scheme changes, updating the NavBar integration accordingly.
Changes:
- Reworked
useThemeto supportsystem | light | darkpreferences, with localStorage persistence and system-change listeners. - Updated
NavBarto pass the new theme preference API through toThemeToggle.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/generators/web/ui/hooks/useTheme.mjs |
Introduces theme preference model (system/light/dark), storage helpers, and OS theme change syncing. |
src/generators/web/ui/components/NavBar.jsx |
Switches NavBar theme toggle wiring to the new useTheme return values/props. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * | ||
| */ | ||
| const getSystemTheme = () => | ||
| matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; |
There was a problem hiding this comment.
Several newly added JSDoc blocks are empty (e.g., for getSystemTheme and others below). Given eslint's jsdoc/require-jsdoc is enabled for .mjs files, please add a brief description of purpose/behavior (and params/returns where relevant) so these comments provide value rather than being placeholders.
| const setStoredThemePreference = themePreference => { | ||
| try { | ||
| localStorage.setItem(THEME_STORAGE_KEY, themePreference); | ||
| } catch { | ||
| // Ignore storage failures and keep non-persistent in-memory preference. |
There was a problem hiding this comment.
Storing the literal value 'system' under the generic localStorage key 'theme' changes the key’s semantics. The legacy generator (src/generators/legacy-html/assets/api.js) treats a missing key (null) as “use system preference” and does not understand 'system', so selecting 'system' here could force legacy pages into light mode until the user toggles again. Consider representing 'system' by removing the 'theme' key (removeItem) or using a separate key (e.g. 'themePreference') to avoid cross-generator conflicts.
Could you please elaborate more why this PR is necessary? Why does it need to be refactored? Is this fixing any specific bug? 👀 |
Description
refracto the way that we handle theming
Validation
Manual test on safari & chrome
Related Issues
Close #642
Check List
node --run testand all tests passed.node --run format&node --run lint.