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

Storybook: Add required styles for @automattic/components #98289

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

mirka
Copy link
Member

@mirka mirka commented Jan 13, 2025

Related to #76007 #75167

Proposed Changes

Add required stylesheets for the isolated @automattic/components Storybook.

Why are these changes being made?

@automattic/components needs to be usable in other A8C applications, not just in this wp-calypso repo. That means we need to ensure that component styles are sufficiently encapsulated for a non-Calypso consumer.

The current root-level Storybook loads a lot of stylesheets, including styles for the Calypso client and others that are not documented as required in the @automattic/components README. This makes it impossible to verify that @automattic/components is shipping with sufficient styles/instructions to render reliably in other environments.

Testing Instructions

yarn workspace @automattic/components run storybook and see that some components (e.g. Button or SearchableDropdown) and see that they are rendering closer to how they are intended.

Note that some styles are still missing — we'll need to start identifying them and filling the gaps. We'll need to figure out how to design our Storybook tooling so we can test that they render reliably in different environments.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@mirka mirka self-assigned this Jan 13, 2025
@mirka mirka requested review from okmttdhr and a team January 13, 2025 18:00
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 13, 2025
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

Comment on lines +31 to +33
Some components require CSS styles from `@wordpress/components`, which you will need to load in order for them to appear correctly. Within WordPress, add the `wp-components` stylesheet as a dependency of your plugin's stylesheet. See [wp_enqueue_style documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_style/#parameters) for how to specify dependencies.

In non-WordPress projects, import the `build-style/style.css` file directly, located at `node_modules/@wordpress/components/build-style/style.css`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this explanation, very much needed IMO

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice step towards correctly working on these components in isolation! 🚀

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks 👍

Before After
Screenshot 2025-01-14 at 14 50 07 Screenshot 2025-01-14 at 14 49 45

@mirka mirka merged commit b54cdd3 into trunk Jan 15, 2025
16 checks passed
@mirka mirka deleted the components-storybook-css branch January 15, 2025 14:39
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants