Skip to content

refracto: theming#656

Open
AugustinMauroy wants to merge 2 commits intomainfrom
fix-theme-toggle
Open

refracto: theming#656
AugustinMauroy wants to merge 2 commits intomainfrom
fix-theme-toggle

Conversation

@AugustinMauroy
Copy link
Member

Description

refracto the way that we handle theming

Validation

Manual test on safari & chrome

Related Issues

Close #642

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

Copilot AI review requested due to automatic review settings March 7, 2026 23:07
@AugustinMauroy AugustinMauroy requested a review from a team as a code owner March 7, 2026 23:07
@vercel
Copy link

vercel bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Mar 7, 2026 11:18pm

Request Review

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.90%. Comparing base (1aef493) to head (bc6e7e7).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Mar 7, 2026

orama-db Generator

File Base Head Diff
orama-db.json 8.05 MB 8.05 MB +3.00 B (+0.00%)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 useTheme to support system | light | dark preferences, with localStorage persistence and system-change listeners.
  • Updated NavBar to pass the new theme preference API through to ThemeToggle.

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.

Comment on lines +27 to +31
const setStoredThemePreference = themePreference => {
try {
localStorage.setItem(THEME_STORAGE_KEY, themePreference);
} catch {
// Ignore storage failures and keep non-persistent in-memory preference.
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@ovflowd
Copy link
Member

ovflowd commented Mar 8, 2026

refracto the way that we handle theming

Could you please elaborate more why this PR is necessary? Why does it need to be refactored? Is this fixing any specific bug? 👀

@AugustinMauroy
Copy link
Member Author

refracto the way that we handle theming

Could you please elaborate more why this PR is necessary? Why does it need to be refactored? Is this fixing any specific bug? 👀

In the linked issue we realize that on safari theme didn't change on web generator when using the dropdown so after some thinkering I found this solution

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.

Theme Toggle Not Working

3 participants