-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Fix error that could occur when loading compiled CSS #68526
base: trunk
Are you sure you want to change the base?
Conversation
@media (prefers-reduced-motion: no-preference) { | ||
@media not (prefers-reduced-motion) { |
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 code was reverted in #68464 because it had errors in the trunk, but I've restored it in this PR since it should work correctly.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -23 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
See this comment: #68419 (comment)
What?
This PR fixes an issue where StoryBook may not be able to load compiled CSS when
@media not
queries are used.Why?
This issue was discovered during the work in #68282 to standardize the format for the
prefers-reduced-motion
media feature.For example, write the following SCSS:
This code will be compiled into the following CSS:
This media query format is valid, but when you run Storybook, you will get the following error:
Details
How?
I don't know the exact cause, but I suspect that the compiled CSS file is being imported as an SCSS file.
Therefore, I explicitly define the extension in the import statement. This seems to allow the media query that causes the error to work correctly.
Testing Instructions
npm run storybook:dev
.packages/components/src/button/style.scss
:Button
component.Screenshots or screencast
Style applied to the button by the
@media (min-width: 782px) and (not (prefers-reduced-motion))
query: