Skip to content

feat: sandbox-only color scheme switch#838

Open
50rayn wants to merge 2 commits into
histoire-dev:mainfrom
50rayn:feat/sandbox-theme
Open

feat: sandbox-only color scheme switch#838
50rayn wants to merge 2 commits into
histoire-dev:mainfrom
50rayn:feat/sandbox-theme

Conversation

@50rayn

@50rayn 50rayn commented May 2, 2026

Copy link
Copy Markdown
Contributor

Why I started this

When I work on a component I usually want to test it in light, dark, and OS-preferred mode. The only way today is to flip the whole Histoire chrome — which is annoying because I lose my chrome preference every time.

So this PR decouples the sandbox color scheme from the chrome. Same UX I filed in #398 back in 2022 (with a PoC video).

What changed

  • 3 buttons at the top of the Background popper: System / Light / Dark
  • new colorScheme: 'auto' | 'light' | 'dark' on PreviewSettings, default 'auto'
  • sandbox uses its own setting via usePreferredDark(); the chrome toggle only flips chrome

Heads-up: sandbox used to follow chrome. Now it defaults to OS preference. If your chrome and OS match (most cases), nothing visibly changes.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify

netlify Bot commented May 2, 2026

Copy link
Copy Markdown

Deploy Preview for histoire-examples-svelte3 ready!

Name Link
🔨 Latest commit 23b781b
🔍 Latest deploy log https://app.netlify.com/projects/histoire-examples-svelte3/deploys/69f646fe96fdb70008800bb7
😎 Deploy Preview https://deploy-preview-838--histoire-examples-svelte3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented May 2, 2026

Copy link
Copy Markdown

Deploy Preview for histoire-controls ready!

Name Link
🔨 Latest commit 23b781b
🔍 Latest deploy log https://app.netlify.com/projects/histoire-controls/deploys/69f646fe4b531900087bbce8
😎 Deploy Preview https://deploy-preview-838--histoire-controls.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented May 2, 2026

Copy link
Copy Markdown

Deploy Preview for histoire-examples-vue3 ready!

Name Link
🔨 Latest commit 23b781b
🔍 Latest deploy log https://app.netlify.com/projects/histoire-examples-vue3/deploys/69f646feead3dd0008f0233f
😎 Deploy Preview https://deploy-preview-838--histoire-examples-vue3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented May 2, 2026

Copy link
Copy Markdown

Deploy Preview for histoire-site ready!

Name Link
🔨 Latest commit 23b781b
🔍 Latest deploy log https://app.netlify.com/projects/histoire-site/deploys/69f646feec8fc40008e3f3dc
😎 Deploy Preview https://deploy-preview-838--histoire-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a color scheme selector (Auto, Light, Dark) to the sandbox toolbar, allowing users to toggle between light, dark, and system-preferred themes. The changes include updates to the preview settings store, the sandbox rendering logic, and the UI components. A review comment identifies that the addition of these new buttons will cause existing E2E tests to fail because they expect a specific number of buttons in the toolbar; these tests will need to be updated to reflect the new UI structure.

Comment on lines +53 to +56
<button
v-for="option in colorSchemeOptions"
:key="option.value"
class="htw-flex-1 htw-px-3 htw-py-1.5 htw-rounded htw-flex htw-items-center htw-justify-center htw-gap-1.5 htw-cursor-pointer htw-text-sm"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Adding these 3 buttons to the background-popper will cause the existing E2E tests in examples/vue3/cypress/e2e/toolbar-background.cy.js to fail. The tests at lines 30, 41, and 51 explicitly check for a button count of 6 (the number of background presets). Please update the tests to account for the 3 new color scheme buttons.

@pkg-pr-new

pkg-pr-new Bot commented May 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

histoire

npm i https://pkg.pr.new/histoire@838

@histoire/app

npm i https://pkg.pr.new/@histoire/app@838

@histoire/controls

npm i https://pkg.pr.new/@histoire/controls@838

@histoire/plugin-nuxt

npm i https://pkg.pr.new/@histoire/plugin-nuxt@838

@histoire/plugin-percy

npm i https://pkg.pr.new/@histoire/plugin-percy@838

@histoire/plugin-screenshot

npm i https://pkg.pr.new/@histoire/plugin-screenshot@838

@histoire/plugin-svelte

npm i https://pkg.pr.new/@histoire/plugin-svelte@838

@histoire/plugin-vue

npm i https://pkg.pr.new/@histoire/plugin-vue@838

@histoire/shared

npm i https://pkg.pr.new/@histoire/shared@838

@histoire/vendors

npm i https://pkg.pr.new/@histoire/vendors@838

commit: 23b781b

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