Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tech: add a default background to newly initialized storybooks #20982

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Feb 7, 2023

Closes we likely have an issue for this?

When you init a storybook on a system with dark-mode enabled. The demo components will be presented on a dark background. This is OK for the primary button component, but everything else just doesn't show well on a dark background.

We could make these demo components all respond to the system preference, but these components are throw away for the user, they are just there to not start with an completely empty storybook.

So here's an easy work-around: we set the default background to light, as this is how these demo components are intended to be shown on.

In addition this instructs to user how to leverage backgrounds.

What I did

  • Add a backgrounds paramater to the preview.*-file generated by sb init.
  • This parameter sets the background to light, because that's what our demo components need to be shown proper.

This also acts as a learning instrument, so users know this backgrounds feature exists, and makes it easier for them to customize.

How to test

  1. Ensure your system preferences are in dark-mode
  2. Run a sandbox for template, e.g. yarn task --task sandbox --start-from auto --template react-vite/default-ts
  3. Open Storybook in your browser
  4. Look at the Page story, this should now have a light background, and the background toolbar should be active immediatly.

@ndelangen ndelangen requested review from shilman and yannbf February 7, 2023 11:04
@ndelangen ndelangen self-assigned this Feb 7, 2023
@ndelangen ndelangen added ui maintenance User-facing maintenance tasks labels Feb 7, 2023
Copy link
Contributor

@sheriffMoose sheriffMoose left a comment

Choose a reason for hiding this comment

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

LGTM

@ndelangen ndelangen changed the title add a default background to newly initialized storybooks Tech: add a default background to newly initialized storybooks Feb 7, 2023
@ndelangen ndelangen added the cli label Feb 7, 2023
@ndelangen ndelangen merged commit 6c46a3d into next Feb 7, 2023
@ndelangen ndelangen deleted the norbert/default-background branch February 7, 2023 13:17
JReinhold added a commit that referenced this pull request Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli maintenance User-facing maintenance tasks ui
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants