Skip to content

Commit 04965e3

Browse files
authored
fix: header's right panel storybook fix (#19363)
1 parent ef2134e commit 04965e3

File tree

1 file changed

+66
-31
lines changed

1 file changed

+66
-31
lines changed

packages/react/src/components/UIShell/UIShell.HeaderBase.stories.js

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -505,37 +505,72 @@ export const HeaderWSideNav = () => (
505505

506506
HeaderWSideNav.storyName = 'Header w/ SideNav';
507507

508-
export const HeaderWActionsAndRightPanel = (args) => (
509-
<>
510-
<Header aria-label="IBM Platform Name">
511-
<HeaderName href="#" prefix="IBM">
512-
[Platform]
513-
</HeaderName>
514-
<HeaderGlobalBar>
515-
<HeaderGlobalAction
516-
aria-label="Search"
517-
onClick={action('search click')}>
518-
<Search size={20} />
519-
</HeaderGlobalAction>
520-
<HeaderGlobalAction
521-
aria-label="Notifications"
522-
badgeCount={args.badgeCount}
523-
isActive
524-
onClick={action('notification click')}>
525-
<Notification size={20} />
526-
</HeaderGlobalAction>
527-
<HeaderGlobalAction
528-
aria-label="App Switcher"
529-
onClick={action('app-switcher click')}
530-
tooltipAlignment="end">
531-
<SwitcherIcon size={20} />
532-
</HeaderGlobalAction>
533-
</HeaderGlobalBar>
534-
<HeaderPanel expanded />
535-
</Header>
536-
<StoryContent />
537-
</>
538-
);
508+
export const HeaderWActionsAndRightPanel = (args) => {
509+
// Add state to control panel expansion
510+
const [isPanelExpanded, setIsPanelExpanded] = useState(false);
511+
512+
// Function to toggle panel
513+
const togglePanel = () => {
514+
setIsPanelExpanded(!isPanelExpanded);
515+
};
516+
517+
// Function to close panel specifically
518+
const closePanel = () => {
519+
setIsPanelExpanded(false);
520+
};
521+
522+
return (
523+
<>
524+
<Header aria-label="IBM Platform Name">
525+
<HeaderName href="#" prefix="IBM">
526+
[Platform]
527+
</HeaderName>
528+
<HeaderGlobalBar>
529+
<HeaderGlobalAction
530+
aria-label="Search"
531+
onClick={action('search click')}>
532+
<Search size={20} />
533+
</HeaderGlobalAction>
534+
<HeaderGlobalAction
535+
aria-label="Notifications"
536+
badgeCount={args.badgeCount}
537+
isActive
538+
onClick={action('notification click')}>
539+
<Notification size={20} />
540+
</HeaderGlobalAction>
541+
<HeaderGlobalAction
542+
aria-label={isPanelExpanded ? 'Close panel' : 'Open panel'}
543+
isActive={isPanelExpanded}
544+
onClick={togglePanel}
545+
tooltipAlignment="end"
546+
id="switcher-button">
547+
<SwitcherIcon size={20} />
548+
</HeaderGlobalAction>
549+
</HeaderGlobalBar>
550+
<HeaderPanel
551+
expanded={isPanelExpanded}
552+
onHeaderPanelFocus={closePanel}
553+
addFocusListeners={true}
554+
href="#switcher-button">
555+
{/* Add panel content here */}
556+
<Switcher aria-label="Switcher Container" expanded={isPanelExpanded}>
557+
<SwitcherItem aria-label="Link 1" href="#">
558+
Link 1
559+
</SwitcherItem>
560+
<SwitcherDivider />
561+
<SwitcherItem href="#" aria-label="Link 2">
562+
Link 2
563+
</SwitcherItem>
564+
<SwitcherItem href="#" aria-label="Link 3">
565+
Link 3
566+
</SwitcherItem>
567+
</Switcher>
568+
</HeaderPanel>
569+
</Header>
570+
<StoryContent />
571+
</>
572+
);
573+
};
539574

540575
HeaderWActionsAndRightPanel.storyName = 'Header w/ Actions and Right Panel';
541576

0 commit comments

Comments
 (0)