@wordpress/ui: add Card and CollapsibleCard components#76252
Conversation
|
Size Change: 0 B Total Size: 6.88 MB ℹ️ View Unchanged
|
|
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. |
| <p | ||
| style={ { | ||
| margin: 0, | ||
| fontFamily: [ 'var(--wp', 'ds-font-family-body)' ].join( '' ), |
There was a problem hiding this comment.
This is a workaround to prevent Storybook breakage, due to how strings in the DS token fallback value (injected at build time) are not correctly escaped.
Fix here: #76254
|
Flaky tests detected in 0778f7b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22775256572
|
aduth
left a comment
There was a problem hiding this comment.
Handful of minor comments and observations, but no blockers. Looks great 👍
| @@ -0,0 +1,28 @@ | |||
| import { Collapsible } from '@base-ui/react/collapsible'; | |||
There was a problem hiding this comment.
For future: This might be nice to expose as its own standalone component.
There was a problem hiding this comment.
Added as a follow-up in the PR description
| * Whether the collapsible panel is initially open (uncontrolled). | ||
| * @default false | ||
| */ | ||
| defaultOpen?: boolean; |
There was a problem hiding this comment.
Observation: Separately, we should probably document these conventions in components with x + defaultX + onXChange (recognizing that it likely follows from DOM/React defaultValue/defaultChecked naming). Seems similar to other patterns we have with value + onChange + onValueChange.
|
I wonder if |
IMO, I think it should be left to the consumer, since we can't assume that |
…ss/ui README Document the `defaultX` / `x` / `onXChange` prop naming pattern used across interactive components in the package. Covers uncontrolled vs controlled modes, difference from native `onChange`, and guidelines for component authors. Ref: #76252 (comment) Made-with: Cursor
…wordpress/ui` (#76281) * Docs: add controlled/uncontrolled prop naming conventions to @wordpress/ui README Document the `defaultX` / `x` / `onXChange` prop naming pattern used across interactive components in the package. Covers uncontrolled vs controlled modes, difference from native `onChange`, and guidelines for component authors. Ref: #76252 (comment) Made-with: Cursor * Docs: cross-reference controlled/uncontrolled conventions from Tabs best practices Add a note at the top of the Tabs best practices page linking to the package-wide controlled/uncontrolled prop naming conventions documented in the README. Made-with: Cursor * Docs: address review feedback on controlled/uncontrolled conventions - Use `@wordpress/element` import instead of `react` for consistency with the rest of the README and package source - Clarify that `onXChange` receives the new value as its "first" argument (some Base UI-derived components pass additional arguments) - Document behavior when neither `x` nor `defaultX` is provided Made-with: Cursor * Revert "Docs: cross-reference controlled/uncontrolled conventions from Tabs best practices" This reverts commit e061ff2. --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
…wordpress/ui` (#76281) * Docs: add controlled/uncontrolled prop naming conventions to @wordpress/ui README Document the `defaultX` / `x` / `onXChange` prop naming pattern used across interactive components in the package. Covers uncontrolled vs controlled modes, difference from native `onChange`, and guidelines for component authors. Ref: WordPress/gutenberg#76252 (comment) Made-with: Cursor * Docs: cross-reference controlled/uncontrolled conventions from Tabs best practices Add a note at the top of the Tabs best practices page linking to the package-wide controlled/uncontrolled prop naming conventions documented in the README. Made-with: Cursor * Docs: address review feedback on controlled/uncontrolled conventions - Use `@wordpress/element` import instead of `react` for consistency with the rest of the README and package source - Clarify that `onXChange` receives the new value as its "first" argument (some Base UI-derived components pass additional arguments) - Document behavior when neither `x` nor `defaultX` is provided Made-with: Cursor * Revert "Docs: cross-reference controlled/uncontrolled conventions from Tabs best practices" This reverts commit e061ff2509a32dde8461bfd7c90eb6a012a478a6. --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Source: WordPress/gutenberg@f92c6e8
What?
Add
CardandCollapsibleCardcomponents to@wordpress/uiWhy?
We're building a new set of UI primitives, see #71196
How?
Create components from scratch using DS tokens, use Base UI's
Collapsiblefor expand/collapse featureTesting Instructions
Check code, unit tests, smoke test in Storybook
Screenshots or screencast
Click to expand
CollapsibleCardvs regularCardCollapsibleCardin closed state, different header content heights:CollapsibleCardin opened state, different header content heights:FullBleed content:
Next Steps
@wordpress/ui#76281CollapsibleCard: add animations #76378Textand DS tokens once finalized