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

feat(storybook): add theme toggle to storybook #18123

Merged
merged 13 commits into from
Oct 26, 2023
Merged

Conversation

thmsobrmlr
Copy link
Contributor

@thmsobrmlr thmsobrmlr commented Oct 20, 2023

Problem

We want to test components in all theme variants with storybook.

Changes

This PR adds a theme toggle via Storybook globals to Storybook. The toggle code is not super clean (it also doesn't use themeLogic and instead sets the theme by updating the theme property on body accordingly), but works in most cases.

2023-10-20 22 23 13

How did you test this code?

Ran Storybook locally

@thmsobrmlr thmsobrmlr requested a review from a team October 20, 2023 20:24
@thmsobrmlr thmsobrmlr force-pushed the storybook-theme-control branch from aac7fb0 to af21858 Compare October 20, 2023 20:30
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

10 snapshot changes in total. 0 added, 10 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

This is super cool. Clicked around locally and everything seemed to work as expected

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this needs to be changed (or removed) as we now do this via the theme picker?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think for the purpose of snapshots we still need the decorator.

BTW looks like the now-unused dark mode and light mode snapshots weren't deleted, we might want to do some pruning of unused snapshots at some point. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I'd like to address this by adding an option to testOptions where you can specify wether "legacy", "3000" or "all" themes should be captured.

I was hoping Storybook would provide a way to set globals for a specific story, so that we could override the theme there, but that doesn't seem to be the case.

@thmsobrmlr thmsobrmlr marked this pull request as ready for review October 23, 2023 09:26
Twixes
Twixes previously requested changes Oct 24, 2023
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

This is great, but we do need to keep the 3000 navigation stories, since the story we have now just shows the classic navigation

thmsobrmlr and others added 3 commits October 25, 2023 15:24
# Conflicts:
#	frontend/__snapshots__/scenes-app-notebooks--headings.png
#	frontend/__snapshots__/scenes-app-notebooks--recordings-playlist.png
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@thmsobrmlr
Copy link
Contributor Author

This is great, but we do need to keep the 3000 navigation stories, since the story we have now just shows the classic navigation

I'm forcing these stories to use the feature flag now (see visual regression tests). Also I've added one for the "base 3000 nav".

@thmsobrmlr thmsobrmlr requested a review from Twixes October 25, 2023 15:08
# Conflicts:
#	frontend/__snapshots__/posthog-3000-sidebar--feature-flags.png
@thmsobrmlr thmsobrmlr dismissed Twixes’s stale review October 26, 2023 11:04

Fixed in the follow up commits

@thmsobrmlr thmsobrmlr enabled auto-merge (squash) October 26, 2023 11:04
@thmsobrmlr thmsobrmlr merged commit d6d259a into master Oct 26, 2023
73 checks passed
@thmsobrmlr thmsobrmlr deleted the storybook-theme-control branch October 26, 2023 11:27
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.

4 participants