Add EmptyState component to @wordpress/ui#74719
Conversation
|
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. |
|
Size Change: 0 B Total Size: 7.66 MB ℹ️ View Unchanged
|
compound component with Root, Visual, Icon, Title, Description, Actions
remove docblock comments, use semantic CSS tokens
d48ee8f to
cf55b85
Compare
|
Flaky tests detected in 3a93b01. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23353966154
|
|
@retrofox Can you check the lint errors on this one? I'd be curious if we can demonstrate a use-case for this in Gutenberg. I feel like this is a perfect fit for |
cf55b85 to
992df0d
Compare
|
@retrofox I took over this PR and pushed a couple of small commits (including lint fixes). @aduth re. whether this component belongs to the Having said that, I believe there is a need for such component across wordpress-related UIs. Maybe it could make sense to start moving it to dataviews and only abstract it if necessary? cc @WordPress/gutenberg-components @WordPress/gutenberg-design for feedback on the matter. |
|
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. |
I'm a little less torn on it being part of |
992df0d to
85a2ea7
Compare
|
@WordPress/gutenberg-design maybe you can help us understand better if there's a real need for this component to be part of the DS, where it's going to used, and what's in your opinion the best place for it — dataviews, ui package, etc |
|
Starting in DataViews seems reasonable to me. I'm struggling to think of a use case for |
|
I was just exploring it for the Analytics section, but it might not be needed actually. |
I'd prefer this too. "If can live somewhere else, it should" might be my rule of thumb for |
|
Let's make sure we have a clear understanding of the usages of |
85a2ea7 to
378689c
Compare
|
If not in components, then In that case, it might make sense to also add prop in
|
It was defined in the design, just in case. |
I think Separately, this does raise the need for more clarity on what |
|
Dashboards and Analytics seem like a valid use case outside of DataViews. My feeling was that |
aduth
left a comment
There was a problem hiding this comment.
Based on what's discussed with how this is needed across both admin interface use-cases as well as DataViews, I think it makes sense to introduce this to the lower-level @wordpress/ui package, as proposed.
There are a couple minor things that need to be addressed per the review comments, but otherwise it looks good to me 👍
packages/ui/src/empty-state/icon.tsx
Outdated
| @@ -0,0 +1,24 @@ | |||
| import clsx from 'clsx'; | |||
| import { forwardRef } from '@wordpress/element'; | |||
| import { Icon as IconComponent } from '../icon'; | |||
There was a problem hiding this comment.
We don't document common import conventions yet (we should), but typically I've seen this shadowing avoidance being implemented with underscore:
| import { Icon as IconComponent } from '../icon'; | |
| import { Icon as _Icon } from '../icon'; |
Granted, most of that existing usage is specifically aliasing BaseUI imports and not our own, but I think it could extend here as well.
| flex-direction: column; | ||
| align-items: center; | ||
| text-align: center; | ||
| gap: var( --wpds-dimension-gap-xs ); |
There was a problem hiding this comment.
Per flagged errors, these need to be formatted without the spacing in the parentheses, per CSS guidelines.
use _Icon import convention, remove CSS var() spacing
|
Regarding discussion of |
| padding: var(--wpds-dimension-padding-surface-xs); | ||
| border: 1px solid var(--wpds-color-stroke-surface-neutral-weak); | ||
| border-radius: 50%; | ||
| background-color: var(--wpds-color-bg-surface-neutral); |
There was a problem hiding this comment.
I just want to note that if #76548 is merged and EmptyState is rendered directly on the Page (as I assume is intended) then the icon background will effectively be invisible. We might want to consider using --wpds-color-bg-surface-neutral-weak instead, or drop the background altogether.
| } | ||
|
|
||
| .description { | ||
| max-width: 350px; |
There was a problem hiding this comment.
We could use a token here e.g. --wpds-dimension-surface-width-sm.
There was a problem hiding this comment.
I wonder if this style should be applied to the container. I'm guessing we wouldn't want really wide titles.
| font-size: var(--wpds-font-size-lg); | ||
| line-height: var(--wpds-font-line-height-sm); |
avoids invisible icon background when rendered on Page surfaces after #76548
replaces hardcoded 350px on description with --wpds-dimension-surface-width-sm on container
delegates typography styles to Text variants instead of manual font-size/weight/line-height declarations





What?
Adds a new
EmptyStatecompound component to the@wordpress/uipackage. This component displays placeholder content when a page or section has no data to show.Why?
EmptyState is a common UI pattern that provides visual feedback and guidance when content is absent. This component is being migrated from the design-system to Gutenberg as part of the ongoing UI component consolidation effort.
How?
The component follows the compound component pattern (like
Tooltip), providing flexible composition:Sub-components
EmptyState.Root- Container with centered flex layoutEmptyState.Visual- Generic visual container (for custom illustrations)EmptyState.Icon- Styled icon with circular border treatmentEmptyState.Title- Heading text (h2)EmptyState.Description- Supporting descriptive textEmptyState.Actions- Container for action buttons (responsive layout)Implementation details
@base-ui/reactprimitives (useRender,mergeProps)--wpds-dimension-gap-xs,--wpds-dimension-padding-surface-xs, etc.)@wordpress/uiconventions: no docblock comments for imports, CSS modules with layer orderingTesting