Skip to content

Commit

Permalink
Move exports to legacy.ts file, including JSDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Sep 26, 2024
1 parent 63c35c8 commit a07d388
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export {
NavigatorBackButton as __experimentalNavigatorBackButton,
NavigatorToParentButton as __experimentalNavigatorToParentButton,
useNavigator as __experimentalUseNavigator,
} from './navigator';
} from './navigator/legacy';
export { default as Notice } from './notice';
export { default as __experimentalNumberControl } from './number-control';
export { default as NoticeList } from './notice/list';
Expand Down
6 changes: 0 additions & 6 deletions packages/components/src/navigator/index.ts

This file was deleted.

172 changes: 172 additions & 0 deletions packages/components/src/navigator/legacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/**
* Internal dependencies
*/
import { Navigator as InternalNavigator } from './navigator/component';
import { NavigatorScreen as InternalNavigatorScreen } from './navigator-screen/component';
import { NavigatorButton as InternalNavigatorButton } from './navigator-button/component';
import { NavigatorBackButton as InternalNavigatorBackButton } from './navigator-back-button/component';
import { NavigatorToParentButton as InternalNavigatorToParentButton } from './navigator-to-parent-button/component';
export { useNavigator } from './use-navigator';

/**
* The `NavigatorProvider` component allows rendering nested views/panels/menus
* (via the `NavigatorScreen` component and navigate between these different
* view (via the `NavigatorButton` and `NavigatorBackButton` components or the
* `useNavigator` hook).
*
* ```jsx
* import {
* __experimentalNavigatorProvider as NavigatorProvider,
* __experimentalNavigatorScreen as NavigatorScreen,
* __experimentalNavigatorButton as NavigatorButton,
* __experimentalNavigatorBackButton as NavigatorBackButton,
* } from '@wordpress/components';
*
* const MyNavigation = () => (
* <NavigatorProvider initialPath="/">
* <NavigatorScreen path="/">
* <p>This is the home screen.</p>
* <NavigatorButton path="/child">
* Navigate to child screen.
* </NavigatorButton>
* </NavigatorScreen>
*
* <NavigatorScreen path="/child">
* <p>This is the child screen.</p>
* <NavigatorBackButton>
* Go back
* </NavigatorBackButton>
* </NavigatorScreen>
* </NavigatorProvider>
* );
* ```
*/
export const NavigatorProvider = Object.assign( InternalNavigator, {
displayName: 'NavigatorProvider',
} );

/**
* The `NavigatorScreen` component represents a single view/screen/panel and
* should be used in combination with the `NavigatorProvider`, the
* `NavigatorButton` and the `NavigatorBackButton` components (or the `useNavigator`
* hook).
*
* @example
* ```jsx
* import {
* __experimentalNavigatorProvider as NavigatorProvider,
* __experimentalNavigatorScreen as NavigatorScreen,
* __experimentalNavigatorButton as NavigatorButton,
* __experimentalNavigatorBackButton as NavigatorBackButton,
* } from '@wordpress/components';
*
* const MyNavigation = () => (
* <NavigatorProvider initialPath="/">
* <NavigatorScreen path="/">
* <p>This is the home screen.</p>
* <NavigatorButton path="/child">
* Navigate to child screen.
* </NavigatorButton>
* </NavigatorScreen>
*
* <NavigatorScreen path="/child">
* <p>This is the child screen.</p>
* <NavigatorBackButton>
* Go back
* </NavigatorBackButton>
* </NavigatorScreen>
* </NavigatorProvider>
* );
* ```
*/
export const NavigatorScreen = Object.assign( InternalNavigatorScreen, {
displayName: 'NavigatorScreen',
} );

/**
* The `NavigatorButton` component can be used to navigate to a screen and should
* be used in combination with the `NavigatorProvider`, the `NavigatorScreen`
* and the `NavigatorBackButton` components (or the `useNavigator` hook).
*
* @example
* ```jsx
* import {
* __experimentalNavigatorProvider as NavigatorProvider,
* __experimentalNavigatorScreen as NavigatorScreen,
* __experimentalNavigatorButton as NavigatorButton,
* __experimentalNavigatorBackButton as NavigatorBackButton,
* } from '@wordpress/components';
*
* const MyNavigation = () => (
* <NavigatorProvider initialPath="/">
* <NavigatorScreen path="/">
* <p>This is the home screen.</p>
* <NavigatorButton path="/child">
* Navigate to child screen.
* </NavigatorButton>
* </NavigatorScreen>
*
* <NavigatorScreen path="/child">
* <p>This is the child screen.</p>
* <NavigatorBackButton>
* Go back
* </NavigatorBackButton>
* </NavigatorScreen>
* </NavigatorProvider>
* );
* ```
*/
export const NavigatorButton = Object.assign( InternalNavigatorButton, {
displayName: 'NavigatorButton',
} );

/**
* The `NavigatorBackButton` component can be used to navigate to a screen and
* should be used in combination with the `NavigatorProvider`, the
* `NavigatorScreen` and the `NavigatorButton` components (or the `useNavigator`
* hook).
*
* @example
* ```jsx
* import {
* __experimentalNavigatorProvider as NavigatorProvider,
* __experimentalNavigatorScreen as NavigatorScreen,
* __experimentalNavigatorButton as NavigatorButton,
* __experimentalNavigatorBackButton as NavigatorBackButton,
* } from '@wordpress/components';
*
* const MyNavigation = () => (
* <NavigatorProvider initialPath="/">
* <NavigatorScreen path="/">
* <p>This is the home screen.</p>
* <NavigatorButton path="/child">
* Navigate to child screen.
* </NavigatorButton>
* </NavigatorScreen>
*
* <NavigatorScreen path="/child">
* <p>This is the child screen.</p>
* <NavigatorBackButton>
* Go back (to parent)
* </NavigatorBackButton>
* </NavigatorScreen>
* </NavigatorProvider>
* );
* ```
*/
export const NavigatorBackButton = Object.assign( InternalNavigatorBackButton, {
displayName: 'NavigatorBackButton',
} );

/**
* _Note: this component is deprecated. Please use the `NavigatorBackButton`
* component instead._
*
* @deprecated
*/
export const NavigatorToParentButton = Object.assign(
InternalNavigatorToParentButton,
{
displayName: 'NavigatorToParentButton',
}
);
2 changes: 1 addition & 1 deletion packages/components/src/navigator/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
NavigatorButton,
NavigatorBackButton,
useNavigator,
} from '..';
} from '../legacy';
import { HStack } from '../../h-stack';

const meta: Meta< typeof NavigatorProvider > = {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/navigator/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
NavigatorBackButton,
NavigatorToParentButton,
useNavigator,
} from '..';
} from '../legacy';
import type { NavigateOptions } from '../types';

const INVALID_HTML_ATTRIBUTE = {
Expand Down

0 comments on commit a07d388

Please sign in to comment.