1111 */
1212
1313import { action } from '@storybook/addon-actions' ;
14- import { Breadcrumb , Breadcrumbs } from '../src' ;
14+ import { Breadcrumb , Breadcrumbs , BreadcrumbsProps } from '../src' ;
1515import type { Meta , StoryObj } from '@storybook/react' ;
1616
1717const meta : Meta < typeof Breadcrumbs > = {
@@ -57,24 +57,31 @@ export const Example: Story = {
5757 )
5858} ;
5959
60- let items = [
60+ interface Item {
61+ id : string ,
62+ name : string
63+ }
64+ let items : Item [ ] = [
6165 { id : 'home' , name : 'Home' } ,
6266 { id : 'react-aria' , name : 'React Aria' } ,
6367 { id : 'breadcrumbs' , name : 'Breadcrumbs' }
6468] ;
65- export const WithActions : Story = {
66- render : ( args : any ) => (
67- < Breadcrumbs onAction = { action ( 'onAction' ) } items = { items } { ...args } >
68- { item => (
69- < Breadcrumb href = { item . href } >
70- { item . name }
71- </ Breadcrumb >
72- ) }
73- </ Breadcrumbs >
74- )
69+
70+ const BreadcrumbsExampleDynamic = ( args : BreadcrumbsProps < Item > ) => (
71+ < Breadcrumbs onAction = { action ( 'onAction' ) } items = { items } { ...args } >
72+ { item => (
73+ < Breadcrumb >
74+ { item . name }
75+ </ Breadcrumb >
76+ ) }
77+ </ Breadcrumbs >
78+ ) ;
79+
80+ export const WithActions : StoryObj < typeof BreadcrumbsExampleDynamic > = {
81+ render : BreadcrumbsExampleDynamic
7582} ;
7683
77- let manyItems = [
84+ let manyItems : Item [ ] = [
7885 { id : 'Folder 1' , name : 'The quick brown fox jumps over' } ,
7986 { id : 'Folder 2' , name : 'My Documents' } ,
8087 { id : 'Folder 3' , name : 'Kangaroos jump high' } ,
@@ -83,9 +90,9 @@ let manyItems = [
8390 { id : 'Folder 6' , name : 'Wattle trees' } ,
8491 { id : 'Folder 7' , name : 'April 7' }
8592] ;
86-
87- export const Many : Story = {
88- render : ( args : any ) => (
93+ export type IMany = typeof BreadcrumbsExampleDynamic ;
94+ export const Many : StoryObj < typeof BreadcrumbsExampleDynamic > = {
95+ render : ( args : BreadcrumbsProps < Item > ) => (
8996 < div style = { { width : '400px' , resize : 'horizontal' , overflow : 'hidden' , padding : '4px' } } >
9097 < Breadcrumbs items = { manyItems } { ...args } >
9198 { item => (
@@ -98,7 +105,10 @@ export const Many: Story = {
98105 )
99106} ;
100107
101- let manyItemsWithLinks = [
108+ interface ItemWithLink extends Item {
109+ href : string
110+ }
111+ let manyItemsWithLinks : ItemWithLink [ ] = [
102112 { id : 'Folder 1' , name : 'The quick brown fox jumps over' , href : '/folder1' } ,
103113 { id : 'Folder 2' , name : 'My Documents' , href : '/folder2' } ,
104114 { id : 'Folder 3' , name : 'Kangaroos jump high' , href : '/folder3' } ,
@@ -108,16 +118,16 @@ let manyItemsWithLinks = [
108118 { id : 'Folder 7' , name : 'April 7' , href : '/folder7' }
109119] ;
110120
111- export const ManyWithLinks : Story = {
112- render : ( args : any ) => (
113- < div style = { { width : '400px' , resize : 'horizontal' , overflow : 'hidden' , padding : '4px' } } >
114- < Breadcrumbs items = { manyItemsWithLinks } { ... args } >
115- { item => (
116- < Breadcrumb href = { item . href } >
117- { item . name }
118- </ Breadcrumb >
119- ) }
120- </ Breadcrumbs >
121- </ div >
122- )
121+ const BreadcrumbsExampleDynamicWithLinks = ( args : BreadcrumbsProps < ItemWithLink > ) => (
122+ < Breadcrumbs onAction = { action ( 'onAction' ) } items = { manyItemsWithLinks } { ... args } >
123+ { item => (
124+ < Breadcrumb href = { item . href } >
125+ { item . name }
126+ </ Breadcrumb >
127+ ) }
128+ </ Breadcrumbs >
129+ ) ;
130+
131+ export const ManyWithLinks : StoryObj < typeof BreadcrumbsExampleDynamicWithLinks > = {
132+ render : BreadcrumbsExampleDynamicWithLinks
123133} ;
0 commit comments