diff --git a/packages/components/src/modal/stories/index.story.tsx b/packages/components/src/modal/stories/index.story.tsx index 60a53947116fa..28a25886547ba 100644 --- a/packages/components/src/modal/stories/index.story.tsx +++ b/packages/components/src/modal/stories/index.story.tsx @@ -1,13 +1,14 @@ /** * External dependencies */ +import type { CSSProperties } from 'react'; import type { StoryFn, Meta } from '@storybook/react'; /** * WordPress dependencies */ -import { useState } from '@wordpress/element'; -import { starEmpty, starFilled } from '@wordpress/icons'; +import { useId, useState } from '@wordpress/element'; +import { chevronLeft, close, starEmpty, starFilled } from '@wordpress/icons'; /** * Internal dependencies @@ -16,6 +17,13 @@ import Button from '../../button'; import InputControl from '../../input-control'; import Modal from '../'; import type { ModalProps } from '../types'; +import { + NavigatorProvider, + NavigatorScreen, + NavigatorButton, + NavigatorToParentButton, + useNavigator, +} from '../../navigator'; const meta: Meta< typeof Modal > = { component: Modal, @@ -123,3 +131,148 @@ WithHeaderActions.args = { WithHeaderActions.parameters = { ...Default.parameters, }; + +export const WithNavigator: StoryFn< typeof Modal > = () => { + const fonts = new Map( [ + [ 'a', { name: 'Font A', variants: [ 'Italic 100', 'Regular 400' ] } ], + [ 'b', { name: 'Font B', variants: [ 'Regular 100', 'Regular 400' ] } ], + [ 'c', { name: 'Font C', variants: [ 'Regular 100', 'Bold 100' ] } ], + ] ); + + const [ isOpen, setOpen ] = useState( false ); + const openModal = () => setOpen( true ); + const closeModal = () => setOpen( false ); + const modalHeaderId = useId(); + const headerStyle: CSSProperties = { display: 'flex' }; + const titleStyle: CSSProperties = { margin: 0 }; + const listStyle: CSSProperties = { + listStyle: 'none', + margin: '1em 0', + padding: 0, + }; + const itemStyle: CSSProperties = { + display: 'flex', + padding: '6px 12px', + fontSize: 14, + alignItems: 'stretch', + boxSizing: 'border-box', + justifyContent: 'space-between', + }; + + function FontNavigator() { + return ( + + + + + + + + + + ); + } + + function FontList() { + return ( +
+
+

+ Font Manager +

+
+
    + { Array.from( fonts.entries(), ( [ id, { name } ] ) => ( +
  1. + + { name } + +
  2. + ) ) } +
+
+ ); + } + + function FontPage() { + const { + params: { font: id }, + } = useNavigator(); + const font = fonts.get( id.toString() ); + + if ( ! font ) { + return ( +
+
+ +

+ Not found +

+
+
+ ); + } + + const { name, variants } = font; + + return ( +
+
+ +

+ { name } +

+
+ +
+ ); + } + + return ( + <> + + { isOpen && ( + + +