Skip to content

Theme picker improvements and playground preview override#147

Open
johnleider wants to merge 11 commits intomasterfrom
feat/theme-component
Open

Theme picker improvements and playground preview override#147
johnleider wants to merge 11 commits intomasterfrom
feat/theme-component

Conversation

@johnleider
Copy link
Member

Summary

  • feat(Theme): [data-theme] rules now set color: var(--v0-on-background) so scoped themes inherit correct text colors (e.g. light theme inside dark parent)
  • docs(DocsExample): Theme picker previews on hover, commits on click. Mouse leave reverts to committed theme.
  • docs(Playground): Combined Editor/Preview theme popover with segmented toggle. Editor tab mirrors the full theme selector. Preview tab overrides just the repl iframe with hover-to-preview. Repl main.ts now generates all themes from the shared theme definitions.

Test plan

  • Toggle docs to dark mode, override a DocsExample to light — verify text is readable
  • Hover themes in DocsExample picker — preview should apply immediately, revert on mouse leave
  • Click a theme in DocsExample — should persist after mouse leaves
  • Open playground, use Editor tab to change page theme
  • Switch to Preview tab, hover themes — iframe should update live
  • Click a theme in Preview — should persist, "PREVIEW" badge shows on activator
  • Click "Same as editor" — preview override clears

Renders a div (configurable via Atom's `as` prop) with `data-theme`
attribute for CSS variable scoping. Provides derived ThemeContext to
descendants, overriding the active theme selection while reusing the
parent's registered themes.
Each example now has a theme picker button in the preview area that
lets users override the theme for that specific example. Uses the new
Theme component to scope CSS variables and context to the preview.
Adds provider docs page with basic, nested, and slot-props examples
demonstrating scoped theme overrides.
- Replace <p> elements with <div>/<span> to avoid default margins
- Use branded themes (Polaris, Nebula, Blackguard, Odyssey) instead
  of just light/dark for more interesting examples
- Add bg-background to Theme wrappers so colors display correctly
- Move Slot Props and Polymorphic Rendering under Recipes header
- Remove class="dark-area" from polymorphic example
- Triple-nested theme example with distinct branded themes
Replace three static examples with one polished interactive demo.
A notifications settings card re-themes in place as users click
through all registered themes. Removes nested/slot-props example
files in favor of inline code snippets under Recipes.
The per-example theme picker already handles theme switching. The
example itself is now just the settings card — no duplicate UI.
Theme picker is now in the toolbar bar alongside the code toggle,
visible for both peek and non-peek examples. Shows selected theme
name when an override is active.
When a Theme component scopes a different theme (e.g. light inside
dark), text color was inherited from the parent instead of using the
scoped theme's on-background token. The adapter now emits
`color: var(--v0-on-background)` in every `[data-theme]` rule.
Theme picker now previews on hover and commits on click. Mouse leave
reverts to the committed theme.
Replace AppThemeToggle with a combined theme popover featuring an
Editor/Preview segmented toggle. Editor tab mirrors the full theme
selector. Preview tab allows overriding the repl iframe theme
independently with hover-to-preview and click-to-persist.

The repl main.ts now generates all themes from the shared theme
definitions instead of hardcoding light/dark.
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.

1 participant