Skip to content

Commit

Permalink
Navigation: Soft deprecate component (#59182)
Browse files Browse the repository at this point in the history
* Navigation: Soft deprecate component

* Set up redirect

* Add deprecation notice in Storybook

* Add changelog

Co-authored-by: mirka <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people authored Apr 15, 2024
1 parent 2cebea7 commit b06dbb9
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Deprecation

- `Navigation`: Soft deprecate component ([#59182](https://github.com/WordPress/gutenberg/pull/59182)).

### Enhancements

- `ExternalLink`: Use unicode arrow instead of svg icon ([#60255](https://github.com/WordPress/gutenberg/pull/60255)).
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/navigation/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Navigation

<div class="callout callout-alert">
This component is deprecated. Consider using `Navigator` instead.
</div>

<div class="callout callout-alert">
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
</div>
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/navigation/back-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ function UnforwardedNavigationBackButton(
);
}

/**
* @deprecated Use `Navigator` instead.
*/
export const NavigationBackButton = forwardRef(
UnforwardedNavigationBackButton
);
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/navigation/group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import type { NavigationGroupProps } from '../types';

let uniqueId = 0;

/**
* @deprecated Use `Navigator` instead.
*/
export function NavigationGroup( {
children,
className,
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const noop = () => {};
/**
* Render a navigation list with optional groupings and hierarchy.
*
* @deprecated Use `Navigator` instead.
*
* ```jsx
* import {
* __experimentalNavigation as Navigation,
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/navigation/item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import type { NavigationItemProps } from '../types';

const noop = () => {};

/**
* @deprecated Use `Navigator` instead.
*/
export function NavigationItem( props: NavigationItemProps ) {
const {
badge,
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/navigation/menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { MenuUI } from '../styles/navigation-styles';

import type { NavigationMenuProps } from '../types';

/**
* @deprecated Use `Navigator` instead.
*/
export function NavigationMenu( props: NavigationMenuProps ) {
const {
backButtonLabel,
Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/navigation/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ import { MoreExamplesStory } from './utils/more-examples';
import { HideIfEmptyStory } from './utils/hide-if-empty';
import './style.css';

/**
* Render a navigation list with optional groupings and hierarchy.
*
* This component is deprecated. Consider using `Navigator` instead.
*/
const meta: Meta< typeof Navigation > = {
title: 'Components (Experimental)/Navigation',
title: 'Components (Deprecated)/Navigation',
id: 'components-navigation',
component: Navigation,
subcomponents: {
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
Expand Down
9 changes: 9 additions & 0 deletions storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<script>
( function redirectIfStoryMoved() {
const PREVIOUSLY_EXPERIMENTAL_COMPONENTS = [ 'navigation' ];
const REDIRECTS = [
{
from: /\/components-deprecated-/,
to: '/components-',
},
{
from: new RegExp(
`\/components-experimental-(?=${ PREVIOUSLY_EXPERIMENTAL_COMPONENTS.map(
( str ) => `${ str }\\b`
).join( '|' ) })`
),
to: '/components-',
},
];

const params = new URLSearchParams( window.location.search );
Expand Down

0 comments on commit b06dbb9

Please sign in to comment.