11import type { Meta , StoryObj } from '@storybook/react' ;
2+ import NavigationLayoutMode from '@ui5/webcomponents-fiori/dist/types/NavigationLayoutMode.js' ;
23import menuIcon from '@ui5/webcomponents-icons/dist/menu.js' ;
34import '@ui5/webcomponents-icons/dist/home.js' ;
45import '@ui5/webcomponents-icons/dist/group.js' ;
@@ -13,7 +14,7 @@ import '@ui5/webcomponents-icons/dist/chain-link.js';
1314import '@ui5/webcomponents-icons/dist/document-text.js' ;
1415import '@ui5/webcomponents-icons/dist/compare.js' ;
1516import '@ui5/webcomponents-icons/dist/locked.js' ;
16- import { useEffect , useState } from 'react' ;
17+ import { useEffect , useRef , useState } from 'react' ;
1718import { Button } from '../Button/index.js' ;
1819import { ShellBar } from '../ShellBar/index.js' ;
1920import type { SideNavigationPropTypes } from '../SideNavigation/index.js' ;
@@ -23,6 +24,7 @@ import { SideNavigationItem } from '../SideNavigationItem/index.js';
2324import { SideNavigationSubItem } from '../SideNavigationSubItem/index.js' ;
2425import { Text } from '../Text/index.js' ;
2526import { Title } from '../Title/index.js' ;
27+ import type { NavigationLayoutDomRef } from './index.js' ;
2628import { NavigationLayout } from './index.js' ;
2729
2830const meta = {
@@ -33,7 +35,9 @@ const meta = {
3335 sideContent : { control : { disable : true } } ,
3436 children : { control : { disable : true } }
3537 } ,
36- args : { } ,
38+ args : {
39+ mode : NavigationLayoutMode . Auto
40+ } ,
3741 tags : [ 'package:@ui5/webcomponents-fiori' ]
3842} satisfies Meta < typeof NavigationLayout > ;
3943
@@ -43,28 +47,33 @@ type Story = StoryObj<typeof meta>;
4347export const Default : Story = {
4448 render : ( args ) => {
4549 const [ selectedContent , setSelectedContent ] = useState ( 'Home' ) ;
46- const [ collapsed , setCollapsed ] = useState ( false ) ;
50+ const [ mode , setMode ] = useState ( args . mode ) ;
51+ const navigationLayoutRef = useRef < NavigationLayoutDomRef > ( null ) ;
4752 const handleSelectionChange : SideNavigationPropTypes [ 'onSelectionChange' ] = ( e ) => {
4853 setSelectedContent ( e . detail . item . text ) ;
4954 } ;
5055
5156 useEffect ( ( ) => {
52- setCollapsed ( args . sideCollapsed ) ;
53- } , [ args . sideCollapsed ] ) ;
57+ setMode ( args . mode ) ;
58+ } , [ args . mode ] ) ;
5459
5560 return (
5661 < div style = { { position : 'relative' , height : '800px' } } >
5762 < NavigationLayout
5863 { ...args }
59- sideCollapsed = { collapsed }
64+ ref = { navigationLayoutRef }
65+ mode = { mode }
6066 header = {
6167 < ShellBar
6268 startButton = {
6369 < Button
6470 icon = { menuIcon }
65- tooltip = { `${ collapsed ? 'Expand' : 'Collapse' } Side-Bar` }
6671 onClick = { ( ) => {
67- setCollapsed ( ( prev ) => ! prev ) ;
72+ if ( navigationLayoutRef . current ?. isSideCollapsed ( ) ) {
73+ setMode ( NavigationLayoutMode . Expanded ) ;
74+ } else {
75+ setMode ( NavigationLayoutMode . Collapsed ) ;
76+ }
6877 } }
6978 />
7079 }
0 commit comments