feat(studio): add system theme option and theme the loading shell#103
feat(studio): add system theme option and theme the loading shell#103
Conversation
Replace the light/dark toggle in the admin header with a System/Light/Dark dropdown and switch the Studio default theme to System so it follows the user's OS preference. The bootstrap loading shell now resolves the theme from localStorage + prefers-color-scheme and renders with matching dark palette overrides so there's no light flash while the runtime loads.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDefault theme changed from "light" to "system"; a three-option ThemePickerMenu replaced the single toggle; shell theme resolution, persistence, and system-preference listeners were added and the resolved theme is applied via Changes
Sequence DiagramsequenceDiagram
participant User
participant PageHeader as Theme Picker UI
participant ThemeProvider as ThemeProvider
participant Storage as localStorage
participant Studio as Studio (useResolvedShellTheme)
participant System as SystemPrefs (prefers-color-scheme)
participant ShellDOM as Shell DOM
User->>PageHeader: Select theme (system/light/dark)
PageHeader->>ThemeProvider: setTheme(selected)
ThemeProvider->>Storage: persist preference
ThemeProvider->>Studio: context update / notify
Studio->>Storage: read stored preference
Studio->>System: query prefers-color-scheme
Studio->>Studio: resolveShellAppliedTheme(stored, system)
Studio->>ShellDOM: set `data-mdcms-theme` (light/dark)
System->>Studio: preference change event
Studio->>Studio: recompute applied theme
Studio->>ShellDOM: update `data-mdcms-theme`
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Comment |
Summary
light→systemso Studio follows the user's OS preference out of the box.Loading Studio): it now resolves the applied theme synchronously fromlocalStorage+prefers-color-schemeand renders a matching dark palette, so there's no light flash while the runtime loads. The shell also reacts to OS theme changes while loading.Notes
ThemePickerMenuis a small new component exported frompage-header.tsx; the existingenableSystemflag onThemeProvideris unchanged.StudioShellFramenow accepts an optionalshellThemeprop (defaulted to"light"). The parentStudiocomponent resolves the theme with a hook soStudioShellFrameitself remains pure and its existing unit tests (which call it as a plain function) keep working.Test plan
bun test --cwd packages/studio ./src/lib/runtime-ui/adapters/next-themes.test.ts ./src/lib/studio.test.ts ./src/lib/runtime-ui/components/layout/page-header.test.tsx(passes locally)Summary by CodeRabbit
New Features
Improvements
Tests
Chores