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

ensure css prop gets handled properly in storybook #35

Merged
merged 4 commits into from
May 29, 2024

Conversation

r3dDoX
Copy link
Member

@r3dDoX r3dDoX commented May 26, 2024

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

New:
Screenshot 2024-05-26 at 19 45 46

@r3dDoX r3dDoX requested a review from culas May 26, 2024 17:46
@r3dDoX
Copy link
Member Author

r3dDoX commented May 28, 2024

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 IS_CHROMATIC is set.

The Chart component can also differ a few pixels because of highcharts. Disable this element for chromatic.
In the Table we have used the <marquee> tag, which also produces slightly differing snapshots and is also deprecated.

@r3dDoX r3dDoX requested a review from Cybertron01Z May 28, 2024 07:23

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
Copy link
Collaborator

@Cybertron01Z Cybertron01Z May 28, 2024

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) 

Copy link
Member Author

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.

Copy link
Collaborator

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?

Copy link
Member Author

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

@r3dDoX r3dDoX requested a review from Cybertron01Z May 28, 2024 14:52
@r3dDoX r3dDoX merged commit 3a536b0 into main May 29, 2024
3 checks passed
@r3dDoX r3dDoX deleted the feature/handle-css-props branch May 29, 2024 04:34
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.

2 participants