Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- `BorderBoxControl` ([#79420](https://github.com/WordPress/gutenberg/pull/79420))
- `FontSizePicker` ([#79481](https://github.com/WordPress/gutenberg/pull/79481))

### Documentation

- Document the safe `clsx` pattern for conditional CSS Module classes ([#79490](https://github.com/WordPress/gutenberg/pull/79490)).

### Internal

- `Surface`: Migrate styles from Emotion to SCSS Modules and use WPDS tokens for migrated visual values ([#79445](https://github.com/WordPress/gutenberg/pull/79445)).
Expand Down
6 changes: 3 additions & 3 deletions packages/components/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ On the component's main named export, add a JSDoc comment that includes the main

All new components should be styled using SCSS Modules.

Place component-local styles in a `style.module.scss` file next to the component, import the module from JavaScript or TypeScript, and compose class names with `clsx`. Preserve existing public `components-*` class names where consumers may rely on them. For dynamic values, prefer inline CSS custom properties consumed by the SCSS module. For variants and state, prefer conditional module classes composed with `clsx`.
Place component-local styles in a `style.module.scss` file next to the component, import the module from JavaScript or TypeScript, and compose class names with `clsx`. Preserve existing public `components-*` class names where consumers may rely on them. For dynamic values, prefer inline CSS custom properties consumed by the SCSS module. For variants and state, prefer conditional module classes composed with `clsx`. When a conditional class comes from a CSS module, use `condition && styles.className` instead of a computed object key (`{ [ styles.className ]: condition }`), because CSS modules are mocked as empty objects in Jest tests, which result in a literal `undefined` class.

Legacy components may still use Emotion while they are being migrated, but new Emotion usage should not be added.

Expand All @@ -445,9 +445,9 @@ function MyComponent( { __nextHasNoOuterMargins = false, className } ) {
className={ clsx(
'components-my-component',
styles.root,
className,
! __nextHasNoOuterMargins &&
styles.deprecatedOuterMargins,
className
styles.deprecatedOuterMargins
Comment on lines +448 to +450

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Keeping the non-object form here, since the object form can produce undefined as an object key

) }
/>
);
Expand Down
Loading