Adopt surface-width design tokens for Dialog, Notice, and Modal widths#76494
Adopt surface-width design tokens for Dialog, Notice, and Modal widths#76494jameskoster wants to merge 2 commits intotrunkfrom
Conversation
Align component width constraints with the --wpds-dimension-surface-width-* tokens from @wordpress/theme, replacing hardcoded pixel values in the UI Dialog and updating SCSS variables for the components Modal to match the token scale. Made-with: Cursor
Made-with: Cursor
|
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. |
|
Flaky tests detected in 178f98e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23057432486
|
| ### Enhancements | ||
|
|
||
| - `DateCalendar`, `DateRangeCalendar`: Add `showOutsideDays` and `fixedWeeks` props and style outside-month days ([#76199](https://github.com/WordPress/gutenberg/pull/76199)). | ||
| - `Modal`: Align size presets with `--wpds-dimension-surface-width-*` design tokens ([#76494](https://github.com/WordPress/gutenberg/pull/76494)). |
There was a problem hiding this comment.
Any reason you opted to keep using the Sass variables instead of using the theme tokens directly? Also for the usages in block-editor and edit-site.
There was a problem hiding this comment.
Should we remove this comment now?
gutenberg/packages/components/src/modal/style.scss
Lines 91 to 93 in d660ae4
| * - `'small'` — max-width of 400px. | ||
| * - `'medium'` — max-width of 560px. | ||
| * - `'large'` — max-width of 960px. |
There was a problem hiding this comment.
I feel like we should stop mentioning exact pixel values in documentation. The values aren't part of the contract, and are variable by nature.
Follow-up to #76047.
What
Adopt
--wpds-dimension-surface-width-*design tokens for component width constraints in the UI and components packages.Why
The
@wordpress/themepackage recently added asurface-widthtoken scale to standardize surface/container widths across the design system. Several components -- Dialog, Notice, and Modal -- were using hardcoded pixel values for their width constraints. Aligning these with the token scale ensures consistency, makes future width adjustments easier to coordinate, and reduces the risk of drift between the newer UI package and the legacy components package.How
packages/ui/src/dialog/style.module.css): Replaced five hardcoded pixel values withvar(--wpds-dimension-surface-width-*)custom properties. Updated JSDoc intypes.tsaccordingly.packages/ui/src/notice/style.module.css): Resolved a TODO about replacing320pxwith a theme token. Since container queries don't supportvar()(womp womp), the value remains hardcoded with a comment documenting its alignment with--wpds-dimension-surface-width-sm.packages/base-styles/_variables.scss): Updated the$modal-width-*SCSS variables to match the token scale values. Added comments referencing the corresponding tokens. Downstream consumers (link-control, url-popover, page-patterns) inherit these changes with minor visual adjustments.Dialog/Modal width changes
--wpds-dimension-surface-width-sm--wpds-dimension-surface-width-md--wpds-dimension-surface-width-lg--wpds-dimension-surface-width-2xlNote
I can go either way between mapping
largetoxl(720px) or2xl(960px), with a slight preference for2xl.Note: Other components in the
componentspackage (e.g. Snackbar, Guide) also have hardcoded widths that could potentially align with this token scale. I'm open to adopting the tokens for these components in this PR too, we'll just need to decide on the values.Testing instructions
npm run storybook:dev