Skip to content
Open
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
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 @@ -2,6 +2,10 @@

## Unreleased

### Breaking Changes

- `Page`: The `breadcrumbs` prop now takes an array of `{ label, href }` items in place of a `Breadcrumbs` element. Links render through `components.link`, like `navigation`, so pass your router's link component there. The page region takes its name from the last item when it has no `ariaLabel` or string `title`. The `Breadcrumbs` component is no longer exported, and the package no longer depends on `@wordpress/route` ([#86982](https://github.com/WordPress/gutenberg/pull/86982)).

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.

Could we show or link to the href-to-to adapter in the migration note? Passing Link from @wordpress/route directly as components.link fails typechecking because it requires to. Example from this PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Could we show or link to the href-to-to adapter in the migration note? Passing Link from @wordpress/route directly as components.link fails typechecking because it requires to. Example from this PR

Yeah, I share your concern here about the downstream impact potential, and commented similarly in #87050 (comment) and the following comment. I think we should find a way to "soften" the migration impact by having @wordpress/boot continue to handle this wiring as much as possible, for the common use-case. One option we could consider here is to continue depending on @wordpress/route for Breadcrumb while still applying the configuration API update. That's kicking the can down the road a bit, but at least could help make some progress.


### Internal

- Update Storybook development dependencies to 10.6.8 ([#87255](https://github.com/WordPress/gutenberg/pull/87255)).
Expand Down
23 changes: 0 additions & 23 deletions packages/admin-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,6 @@ RTL versions of the stylesheets are available in the same paths, but with `-rtl`

<!-- START TOKEN(Autogenerated API docs) -->

### Breadcrumbs

Renders a breadcrumb navigation trail.

All items except the last one must provide a `to` prop for navigation. In development mode, an error is thrown when a non-last item is missing `to`. The last item represents the current page and its `to` prop is optional. Only the last item (when it has no `to` prop) is rendered as an `h1`.

_Usage_

```jsx
<Breadcrumbs
items={ [
{ label: 'Home', to: '/' },
{ label: 'Settings', to: '/settings' },
{ label: 'General' },
] }
/>
```

_Parameters_

- _props_ `BreadcrumbsProps`:
- _props.items_ `BreadcrumbsProps[ 'items' ]`: The breadcrumb items to display.

### getAdminThemeColors

Reads the active WordPress admin color scheme from the `admin-color-*` body class and returns its primary and background colors. Intended to seed a `ThemeProvider` (`color` prop) so the design system matches the user's chosen admin color scheme.
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 @@
"@wordpress/element": "file:../element",
"@wordpress/i18n": "file:../i18n",
"@wordpress/private-apis": "file:../private-apis",

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.

The deleted story decorator was the only caller of src/lock-unlock.ts. Could we remove that helper and its ESLint suppression, then drop the direct @wordpress/private-apis dependency from the manifest, lockfile, and TypeScript project references?

"@wordpress/route": "file:../route",
"@wordpress/style-runtime": "file:../style-runtime",
"@wordpress/ui": "file:../ui",
"clsx": "^2.1.1"
Expand Down
67 changes: 22 additions & 45 deletions packages/admin-ui/src/breadcrumbs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@
import { Link as RouterLink } from '@wordpress/route';
import { _x } from '@wordpress/i18n';
import { Link, Stack, Text } from '@wordpress/ui';
import type { BreadcrumbsProps } from './types';
import styles from './style.module.css';

/**
* Renders a breadcrumb navigation trail.
* Renders a breadcrumb navigation trail. All items except the last one link to
* their `href`. The last item is the current page and is the page heading.
*
* All items except the last one must provide a `to` prop for navigation.
* In development mode, an error is thrown when a non-last item is missing `to`.
* The last item represents the current page and its `to` prop is optional.
* Only the last item (when it has no `to` prop) is rendered as an `h1`.
*
* @param props
* @param props.items The breadcrumb items to display.
*
* @example
* ```jsx
* <Breadcrumbs
* items={ [
* { label: 'Home', to: '/' },
* { label: 'Settings', to: '/settings' },
* { label: 'General' },
* ] }
* />
* ```
* Internal to the package: configured through the `Page` `breadcrumbs` prop.
*/
export const Breadcrumbs = ( { items }: BreadcrumbsProps ) => {
export const Breadcrumbs = ( {
items,
headingLevel,
linkComponent,
}: BreadcrumbsProps ) => {
if ( ! items.length ) {
return null;
}

const LinkComponent = linkComponent ?? 'a';
const HeadingTag = `h${ headingLevel }` as const;
const precedingItems = items.slice( 0, -1 );
const lastItem = items[ items.length - 1 ];

if ( process.env.NODE_ENV !== 'production' ) {
const invalidItem = precedingItems.find( ( item ) => ! item.to );
const invalidItem = precedingItems.find( ( item ) => ! item.href );
if ( invalidItem ) {
throw new Error(
`Breadcrumbs: item "${ invalidItem.label }" is missing a \`to\` prop. All items except the last one must have a \`to\` prop.`
`Breadcrumbs: item "${ invalidItem.label }" is missing an \`href\` prop. All items except the last one must have an \`href\` prop.`
);
}
}
Expand All @@ -58,7 +47,9 @@ export const Breadcrumbs = ( { items }: BreadcrumbsProps ) => {
render={
<Link
tone="neutral"
render={ <RouterLink to={ item.to } /> }
render={
<LinkComponent href={ item.href! } />
}
/>
}
>
Expand All @@ -74,27 +65,13 @@ export const Breadcrumbs = ( { items }: BreadcrumbsProps ) => {
</li>
) ) }
<li>
{ lastItem.to ? (
<Text
variant="body-lg"
render={
<Link
tone="neutral"
render={ <RouterLink to={ lastItem.to } /> }
/>
}
>
{ lastItem.label }
</Text>
) : (
<Text
variant="heading-lg"
render={ <h1 /> }
className={ styles.current }
>
{ lastItem.label }
</Text>
) }
<Text
variant="heading-lg"
render={ <HeadingTag /> }
className={ styles.current }
>
{ lastItem.label }
</Text>
</li>
</Stack>
</nav>
Expand Down
39 changes: 0 additions & 39 deletions packages/admin-ui/src/breadcrumbs/stories/index.story.tsx

This file was deleted.

Loading
Loading