Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/admin-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

- Increase page header vertical padding. [#77152](https://github.com/WordPress/gutenberg/pull/77152)

### Internal

- `Breadcrumbs`: Migrate from `@wordpress/components` to `Link`, `Stack`, and `Text` from `@wordpress/ui`. [#77012](https://github.com/WordPress/gutenberg/pull/77012)

## 1.11.0 (2026-04-01)

### Bug Fixes
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"src/**/*.module.css"
],
"dependencies": {
"@wordpress/base-styles": "file:../base-styles",
"@wordpress/components": "file:../components",
"@wordpress/element": "file:../element",
"@wordpress/i18n": "file:../i18n",
Expand Down
57 changes: 42 additions & 15 deletions packages/admin-ui/src/breadcrumbs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/**
* WordPress dependencies
*/
import { Link } from '@wordpress/route';
import { Link as RouterLink } from '@wordpress/route';
import { __ } from '@wordpress/i18n';
import {
__experimentalHeading as Heading,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { Link, Stack, Text } from '@wordpress/ui';

/**
* Internal dependencies
Expand Down Expand Up @@ -55,28 +52,58 @@ export const Breadcrumbs = ( { items }: BreadcrumbsProps ) => {

return (
<nav aria-label={ __( 'Breadcrumbs' ) }>
<HStack
as="ul"
<Stack
render={ <ul /> }
direction="row"
align="center"
className={ styles.list }
spacing={ 0 }
justify="flex-start"
alignment="center"
>
{ precedingItems.map( ( item, index ) => (
<li key={ index }>
<Link to={ item.to }>{ item.label }</Link>
<Text
variant="body-lg"
render={
<Link
tone="neutral"
render={ <RouterLink to={ item.to } /> }
/>
}
>
{ item.label }
</Text>
Comment on lines +63 to +73

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have we discussed or landed on consensus around Link component from @wordpress/route using Link from @wordpress/ui ?

(Something to address separately)

<Text
variant="body-lg"
aria-hidden="true"
className={ styles.separator }
>
/
</Text>
</li>
) ) }
<li>
{ lastItem.to ? (
<Link to={ lastItem.to }>{ lastItem.label }</Link>
<Text
variant="body-lg"
render={
<Link
tone="neutral"
render={ <RouterLink to={ lastItem.to } /> }
/>
}
>
{ lastItem.label }
</Text>
) : (
<Heading level={ 1 } truncate>
<Text
variant="heading-lg"
render={ <h1 /> }
className={ styles.current }
>
{ lastItem.label }
</Heading>
</Text>
) }
</li>
</HStack>
</Stack>
</nav>
);
};
Expand Down
42 changes: 26 additions & 16 deletions packages/admin-ui/src/breadcrumbs/style.module.css

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe we can un-nest the .current and .separator styles from within .list, since CSS modules now ensures class name uniqueness

Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
.list {
/* @TODO: use Text component from UI when available. */
font-family: var(--wpds-typography-font-family-heading);
font-size: var(--wpds-typography-font-size-lg);
font-weight: var(--wpds-typography-font-weight-medium);
line-height: var(--wpds-typography-line-height-lg);
list-style: none;
padding: 0;
margin: 0;
/* gap prop don't seem to be working properly. */
gap: 0;
min-height: 32px;
/* @TODO: Replace with a `size` token once that category exists in the theme package. */
min-height: calc(var(--wpds-dimension-base) * 8);
}

/*
* Preceding items keep their intrinsic width; only the last (current) item
* is allowed to shrink so that the truncation styles on `.current` engage.
*/
.list > li {
flex-shrink: 0;
}

li:not(:last-child)::after {
content: "/";
margin: 0 var(--wpds-dimension-gap-sm);
}
.list > li:last-child {
flex-shrink: 1;
min-width: 0;
}

/* @TODO: Remove truncation styles once `Text` supports truncation natively. */
.current {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

h1 {
font-size: inherit;
line-height: inherit;
}
.separator {
color: var(--wpds-color-stroke-surface-neutral);
margin: 0 var(--wpds-dimension-gap-sm);
user-select: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ ruleTester.run( 'use-recommended-components', rule, {

// Allowed @wordpress/ui components.
"import { Badge } from '@wordpress/ui';",
"import { Link } from '@wordpress/ui';",
"import { Stack } from '@wordpress/ui';",
"import { Badge, Stack } from '@wordpress/ui';",
"import { Text } from '@wordpress/ui';",
"import { Badge, Link, Stack, Text } from '@wordpress/ui';",
],

invalid: [
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/rules/use-recommended-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const ALLOWLIST = {
'Card',
'Collapsible',
'CollapsibleCard',
'Link',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should probably get a separate CHANGELOG entry in @wordpress/ui, too?

Also, looping @mirka in to make sure we're ready to mark it as allowed, and/or if we're happy to do it as part of this PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The only remaining issue with Link is what @aduth noted here. I wouldn't say this is a serious blocker for a component like Link, so I'll leave it up to @jameskoster to decide whether these discrepancies are fine for now, and can be fixed later.

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.

I think this is a minor point that can be addressed in a follow-up.

'Stack',
'Text',
'VisuallyHidden',
Expand Down
5 changes: 0 additions & 5 deletions tools/eslint/suppressions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"packages/admin-ui/src/breadcrumbs/index.tsx": {
"@wordpress/use-recommended-components": {
"count": 2
}
},
"packages/block-editor/src/components/background-image-control/index.js": {
"@wordpress/use-recommended-components": {
"count": 2
Expand Down
Loading