-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Storybook: Declare stylesheet dependencies explicitly #49099
Conversation
|
||
stylesToUse.forEach( ( style ) => style.use() ); |
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.
Size Change: 0 B Total Size: 1.34 MB ℹ️ View Unchanged
|
Flaky tests detected in b60077e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4427685434
|
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 looks good and tests well for me, but definitely deeper into Storybook config than I'm accustomed so I'll let @ciampo look and approve :)
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 looks great, thank you @mirka !
Is it discoverable, clear, and documented enough? Let me know.
The code is well documented. At most, we could add a section / paragraph in the Storybook docs (if there are any).
Closes #49057
What?
Adds additional config to the Storybook
withRTL
decorator so only explicitly declared stylesheet dependencies will be loaded for a given story group.Why?
To properly isolate stories from problematic, leaky styles. There can sometimes be some overscoped styles in a given package's stylesheet, which can inadvertently affect an upstream or peer package's story. For example, if the
block-editor
package stylesheet contained a style like.components-modal { background: yellow; }
, we would not want to load that style for theModal
component story.How?
I tried to structure this in a way that would be clear for other devs how to extend the config when they want to add new story groups. Is it discoverable, clear, and documented enough? Let me know.
Testing Instructions
npm run storybook:dev
and a check some stories in each story group (e.g. Playground, BlockEditor, Components, etc). Try the RTL switcher. It should look the same as in trunk — if not, you may have found an isolation issue that was already there 😄See inline code comment to see where you can add a console.log statement to verify which stylesheets are loaded.