Skip to content

feat: theme toggle - #8128

Open
talissoncosta wants to merge 5 commits into
mainfrom
feat/theme-toggle-nav-7702
Open

feat: theme toggle#8128
talissoncosta wants to merge 5 commits into
mainfrom
feat/theme-toggle-nav-7702

Conversation

@talissoncosta

@talissoncosta talissoncosta commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #7702

Adds a one-click light/dark toggle to the top bar, behind the dark_mode_nav_toggle flag (created, default off).

  • darkMode.ts becomes a small reactive theme store. With no stored choice the theme follows the OS (prefers-color-scheme, live); the first explicit choice pins it. Legacy dark_mode storage migrates.
  • Already-open tabs update immediately via a storage listener.
  • The onboarding ThemeToggle is promoted to components/ThemeToggle; onboarding reuses it. The Account Settings dark-mode switch shares the same store, so neither control goes stale.

Note on #7702's criteria: "system" here is the default behaviour rather than a selectable option (a deliberate simplification, one-click beats a menu). If a returnable "System" choice is required, the store supports adding it in Account Settings later. Flagging for the issue author to confirm before this closes #7702.

Behaviour change to be aware of: users who never chose a theme now follow their OS, so dark-OS users get dark mode on first load after this ships.

How did you test this code?

  • tsc: 0 new errors vs main; eslint: clean.
  • Storybook: ThemeToggle story (flips the canvas theme live).

Smoke test (enable dark_mode_nav_toggle for your identity in the Staging environment of Flagsmith Website, then hard-refresh; run the dev server from this branch):

  • Toggle appears in the top bar; clicking flips the theme instantly
  • Fresh profile (no stored theme) follows the OS appearance, live
  • Account Settings dark-mode switch and the nav toggle stay in sync
  • Second browser tab reflects a theme change made in the first
  • Onboarding flow toggle still works (now the shared component)
  • Flag off: top bar unchanged

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview Aug 3, 2026 1:39pm
flagsmith-frontend-staging Ready Ready Preview Aug 3, 2026 1:39pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Aug 3, 2026 1:39pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0672f5d6-1305-45b3-8eb9-053eef80724c

📥 Commits

Reviewing files that changed from the base of the PR and between a7e78ba and 6b3a6dd.

📒 Files selected for processing (1)
  • frontend/web/project/darkMode.ts

📝 Walkthrough

Walkthrough

The change centralises dark-mode state in darkMode.ts with explicit persistence, system preference fallback, reactive updates, and cross-tab synchronisation. It adds a shared ThemeToggle component, updates existing theme controls, and enables the toggle in the top navigation behind a feature flag. The onboarding flow now imports the shared component. Storybook documentation covers the new component.

Estimated code review effort: 3 (Moderate) | ~20 minutes


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: af7fdd78-7bf8-470b-8b44-c1b62131a8a1

📥 Commits

Reviewing files that changed from the base of the PR and between 4d5fff8 and a5dc874.

📒 Files selected for processing (8)
  • frontend/documentation/components/ThemeToggle.stories.tsx
  • frontend/web/components/DarkModeSwitch.tsx
  • frontend/web/components/ThemeToggle/ThemeToggle.tsx
  • frontend/web/components/ThemeToggle/index.ts
  • frontend/web/components/navigation/navbars/TopNavbar.tsx
  • frontend/web/components/pages/onboarding/OnboardingFlow/OnboardingFlow.tsx
  • frontend/web/components/pages/onboarding/ThemeToggle/ThemeToggle.tsx
  • frontend/web/project/darkMode.ts
💤 Files with no reviewable changes (1)
  • frontend/web/components/pages/onboarding/ThemeToggle/ThemeToggle.tsx

Comment thread frontend/web/components/ThemeToggle/ThemeToggle.tsx
Comment thread frontend/web/project/darkMode.ts Outdated
Comment thread frontend/web/project/darkMode.ts
talissoncosta and others added 4 commits July 29, 2026 14:02
darkMode.ts becomes a small reactive theme store: light/dark/system
(system follows prefers-color-scheme), legacy dark_mode storage
migrates, and a storage listener updates already-open tabs. The
onboarding ThemeToggle is promoted to components/ThemeToggle and gains
a labelled Light/Dark/System menu (the icon set has no system glyph,
so a menu beats a blind three-state cycle). The account-settings
switch shares the same store so neither control goes stale.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drops the Light/Dark/System menu: the OS preference decides the theme
until the user makes an explicit choice, and the nav control is a
plain sun/moon flip like onboarding's. Deviates from #7702's second
criterion as written (no selectable system option); flagged on the PR
for the issue author.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@talissoncosta
talissoncosta marked this pull request as ready for review July 31, 2026 16:31
@talissoncosta
talissoncosta requested a review from a team as a code owner July 31, 2026 16:31
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-8128 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-8128 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-8128 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8128 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8128 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-8128 Finished ✅ Results

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 31, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6756fa97-636b-4bd8-82fe-84d3876752f9

📥 Commits

Reviewing files that changed from the base of the PR and between a5dc874 and a7e78ba.

📒 Files selected for processing (8)
  • frontend/documentation/components/ThemeToggle.stories.tsx
  • frontend/web/components/DarkModeSwitch.tsx
  • frontend/web/components/ThemeToggle/ThemeToggle.tsx
  • frontend/web/components/ThemeToggle/index.ts
  • frontend/web/components/navigation/navbars/TopNavbar.tsx
  • frontend/web/components/pages/onboarding/OnboardingFlow/OnboardingFlow.tsx
  • frontend/web/components/pages/onboarding/ThemeToggle/ThemeToggle.tsx
  • frontend/web/project/darkMode.ts
💤 Files with no reviewable changes (1)
  • frontend/web/components/pages/onboarding/ThemeToggle/ThemeToggle.tsx

Comment thread frontend/web/project/darkMode.ts
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #18954 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  1 minute, 8 seconds
commit  6b3a6dd
info  🔄 Run: #18954 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-16 — run #18954 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32.8 seconds
commit  6b3a6dd
info  🔄 Run: #18954 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18954 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.4 seconds
commit  6b3a6dd
info  🔄 Run: #18954 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18954 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.1 seconds
commit  6b3a6dd
info  🔄 Run: #18954 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #18920 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 2 seconds
commit  a7e78ba
info  🔄 Run: #18920 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #18920 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  5 passed

Details

stats  5 tests across 4 suites
duration  19 seconds
commit  a7e78ba
info  🔄 Run: #18920 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18920 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.7 seconds
commit  a7e78ba
info  🔄 Run: #18920 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18920 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.4 seconds
commit  a7e78ba
info  🔄 Run: #18920 (attempt 1)

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dark Mode isn't friendly to find

2 participants