-
Notifications
You must be signed in to change notification settings - Fork 1
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
ensure css prop gets handled properly in storybook #35
Conversation
I also noticed, that our animations are not disabled in Chromatic. This is because of the Shadow DOM. I added this check in the base element, that animation-disabling is being loaded into every component when the ENV var The Chart component can also differ a few pixels because of highcharts. Disable this element for chromatic. |
|
||
export const ActionKeystrokes = [' ', 'Enter']; | ||
|
||
export default class BaseElement<EventsPayloadMap = Record<string, never>> extends LitElement { | ||
|
||
protected static globalStyles = unsafeCSS(global); | ||
protected static globalStyles = import.meta.env.VITE_IS_CHROMATIC |
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.
Idea:
i am not the biggest fan of doing this in the baseElement.
Could we do something like this in the .stories files to disable the animations?
var sheet = new CSSStyleSheet()
sheet.replaceSync( `.color { color: pink }`)
host.shadowRoot.adoptedStyleSheets.push(sheet)
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.
I don't like it too much either, but we need to be inside each components Shadow DOM. There is not a nice way to do this, if we have to place CSSStyleSheets on every story trying to reach into the Shadow DOM, it's going to be messy and we are going to miss some leading to unexpected errors.
In this way here we have every shadow DOM but only if at build time the env var IS_CHROMATIC
is present. So all our prod builds do not have these CSS styles included. Which I think is a nice compromise that is very maintainable.
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.
Fair enough 👍🏻 could we do something similar also with reduced motion? I don't think we have any big animations but could this also be something that we want to support? Or is this more on application level?
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.
That's a good point! For the reset.css we used this as a base: https://dev.to/hankchizljaw/a-modern-css-reset-6p3
As you can see, in the end it disables all animations for people that have reduced motion set. With our client we had the problem though, that they used virtual desktops which always had reduced motion on, so we never got any animations which led us to remove this CSS.
We then ended up setting it for the bigger animations on a per component base. You can see the loadingPlaceholder for example: https://github.com/Zuehlke/design-system-starter/blob/main/web-components/src/components/loadingPlaceholder/loadingPlaceholder.css
I noticed, that
@cssprop
are getting generated into the custom-elements-manifest which then leads to Storybook displaying it in the attributes table. But there it can't be handled. Added the additional type and used the original name to propery handle it in Storybook.Old:
![Screenshot 2024-05-26 at 19 45 23](https://private-user-images.githubusercontent.com/1119248/333899121-bd752304-4f52-4dcf-aecb-6d565def93f4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTc0MTAsIm5iZiI6MTczOTQ5NzExMCwicGF0aCI6Ii8xMTE5MjQ4LzMzMzg5OTEyMS1iZDc1MjMwNC00ZjUyLTRkY2YtYWVjYi02ZDU2NWRlZjkzZjQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDEzODMwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGNlMDgwMWZhYmZhNTZjYTY3ZThmNTVkNDk2ODUzMTk3M2VmMGU3OWMxNThiMDM4MDhhYTQxNjU5NTQwZTEzNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.cIwK24z05tk2IAJYI5BFm6regSqRGvVrvGXOtmO5xMo)
New:
![Screenshot 2024-05-26 at 19 45 46](https://private-user-images.githubusercontent.com/1119248/333899122-aaece40c-22c4-4211-a256-32893ea4e631.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTc0MTAsIm5iZiI6MTczOTQ5NzExMCwicGF0aCI6Ii8xMTE5MjQ4LzMzMzg5OTEyMi1hYWVjZTQwYy0yMmM0LTQyMTEtYTI1Ni0zMjg5M2VhNGU2MzEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDEzODMwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWFkNGRhNDA3ZWI4OTE5MTRhZTU4ZjQ4MWVjZTdhYjFmYzg0ZTE1MzBkMGFjMmU0N2ZhOWY4MWUxZjc0NjIxZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.6xwLjskh9FpK3bqZooC_Fl5ohE7iWaDsOttY24Tn9Ww)