-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use storybook's addon-contexts to allow for theme toggling #2281
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
Conversation
|
uugh failures.
|
Bump up the text darkness imo |
|
Just poked at it a bit more—the a11y test for disabled select is not exactly right as it calculates the text contrast against the body instead of the select background. Regardless, it still fails with a 2.62 instead of a 2.52. Looks like we’d need to update the color to #647380 (or something close in our palette) for this to pass (4.5) against the body, although it would really be 4.61. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this! Went ahead a pushed a fix for the disabled select a11y failure.
Other than a changelog entry for the strict mode change (we haven’t been adding changelog entries for anything related to global theming) and fixing the types, I’m good with this 👍
danrosenthal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic! Thanks so much for doing this @BPScott, it's going to have a big impact on this project.
Regarding the disabled contrast check failure, I'm a bit surprised that even fails. WCAG's own documentation states that disabled UI elements don't need to meet contrast ratios. That said, the color change seems like a fine solution from my perspective.
Also, a special request. It would be incredibly powerful to be able to have a couple of CI checks run with these provider settings in place. In particular, it would be useful to have a non-blocking pally check run for color contrast on both light mode and dark mode. It would also be great to have non-blocking Percy checks for both modes as well. This would help with review, and help us deliver an accessible themed experience. Thoughts on that as a possibility?
I get why it was failing then. The display content is not part of the |
7fa6480 to
674646a
Compare
|
Great sleuthing on the select stuff. To fix the type issue I've reverted back to storybook 5.2.1 (same as master). We're still blocked on updating to newer versions, but we don't need to update right now anyway. |
105f221 to
60b0840
Compare
- Add addon-contexts and remove addon-backgrounds - Configure context to allow toggling React strict mode on/off - Configure context to allow configuring theme setups. There is a choice of default, global theming light mode and global theming dark mode
60b0840 to
5821826
Compare
Strong agree that being able to test these things would be very powerful. The good news is that contexts works by adding a query string to the preview pane so we can hit https://polaris-react.herokuapp.com/iframe.html?id=playground-playground--playground&contexts=Themes=Global%20Theming%20Enabled%20-%20Light%20Mode to give us the playground in light mode for instance, so these urls are available to be used. I'm a bit wary of what you mean by "non-blocking check run" do you mean:
Got to admit, I don't really like either of those options, I'd rather stick with failing when we encounter problems and making sure they get fixed. Adding these checks to the existing pa11y check should be pretty easy - we'd need to rejig how we built the list of urls to check to include adding the extra context variations we desire. Adding these checks to Percy will be a bit more tricky as it currently doesn't support those arbitrary extra params for each story. I'll raise an issue with them - supporting an official addon that is a general-case solution to their existing "rtl" solution seems like something they'd go for. |
|
I'm in agreement with you on the |
|
Percy issue created: percy/percy-storybook#146 |

WHY are these changes introduced?
Preliminary theming work is rad. Having an easy way to preview it on existing stories would be even radder.
And while I'm playing with contexts, being able to disable react strict mode so I can get accurate counts of how often things get rerendered when debugging would be super useful too.
WHAT is this pull request doing?
Use storybook's addon-contexts addon to allow for theme toggling, and react strict mode toggling
choice of default, global theming light mode and global theming dark
mode
How to 🎩
Themes
Visit a story of a component that is themed, e.g. Banner. Click through the options available in the theme button (the paintbrush in the Storybook topbar, sorry I can't fix the the mystery meat navigation) and marvel at new colors.
Alternatively use this playground that has lots of them on:
Copy-paste this code in
playground/Playground.tsx:Strict mode
To test the React strict mode toggle works, use the following sandbox: When in strict mode (the default) clicking the increment button should result in two console logs from the render method (as strict mode double invokes render() calls in class components.
Click the strict mode context toggle (the speedometer looking thing in the storybook ui, next to the zoom buttons, alas I can't fix the mystery meat navigation). and disable strict mode. Clicking the increment button should now console log one item.
Copy-paste this code in
playground/Playground.tsx:🎩 checklist
README.mdwith documentation changes