Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refactor menu stories and add keyboard shortcuts story
  • Loading branch information
ghengeveld committed Jun 25, 2025
commit 2ced0e9cb774ddb480ffb59b2d27cc45eb98f395
63 changes: 57 additions & 6 deletions code/core/src/manager/components/sidebar/Menu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ export const Expanded: Story = {
globals: { sb_theme: 'light' },
render: () => {
const menu = useMenu(
{ whatsNewData: { status: 'SUCCESS', disableWhatsNewNotifications: false } } as State,
{ whatsNewData: undefined } as State,
{
// @ts-expect-error (Converted from ts-ignore)
getShortcutKeys: () => ({}),
getAddonsShortcuts: () => ({}),
versionUpdateAvailable: () => false,
isWhatsNewUnread: () => true,
isWhatsNewUnread: () => false,
getDocsUrl: () => 'https://storybook.js.org/docs/',
},
false,
Expand All @@ -73,7 +73,7 @@ export const Expanded: Story = {
);
return (
<DoubleThemeRenderingHack>
<SidebarMenu menu={menu} isHighlighted />
<SidebarMenu menu={menu} />
</DoubleThemeRenderingHack>
);
},
Expand All @@ -96,14 +96,27 @@ export const Expanded: Story = {
],
};

export const ExpandedWithoutWhatsNew: Story = {
export const ExpandedWithShortcuts: Story = {
...Expanded,
render: () => {
const menu = useMenu(
{ whatsNewData: undefined } as State,
{
// @ts-expect-error (invalid)
getShortcutKeys: () => ({}),
getShortcutKeys: () => ({
shortcutsPage: ['⌘', '⇧​', ','],
toggleNav: ['⌥', 'S'],
togglePanel: ['⌥', 'A'],
toolbar: ['⌥', 'T'],
panelPosition: ['⌥', 'D'],
fullScreen: ['⌥', 'F'],
search: ['⌥', 'K'],
prevComponent: ['⌥', '↑'],
nextComponent: ['⌥', '↓'],
prevStory: ['⌥', '←'],
nextStory: ['⌥', '→'],
collapseAll: ['⌥', '⇧', '↑'],
}),
getAddonsShortcuts: () => ({}),
versionUpdateAvailable: () => false,
isWhatsNewUnread: () => false,
Expand All @@ -113,7 +126,7 @@ export const ExpandedWithoutWhatsNew: Story = {
false,
false,
false,
false
true
);

return (
Expand All @@ -133,3 +146,41 @@ export const ExpandedWithoutWhatsNew: Story = {
await expect(releaseNotes).not.toBeInTheDocument();
},
};

export const ExpandedWithWhatsNew: Story = {
...Expanded,
render: () => {
const menu = useMenu(
{ whatsNewData: { status: 'SUCCESS', disableWhatsNewNotifications: false } } as State,
{
// @ts-expect-error (invalid)
getShortcutKeys: () => ({}),
getAddonsShortcuts: () => ({}),
versionUpdateAvailable: () => false,
isWhatsNewUnread: () => true,
getDocsUrl: () => 'https://storybook.js.org/docs/',
},
false,
false,
false,
false,
false
);

return (
<DoubleThemeRenderingHack>
<SidebarMenu menu={menu} isHighlighted />
</DoubleThemeRenderingHack>
);
},
play: async (context) => {
const canvas = within(context.canvasElement);
await new Promise((res) => {
setTimeout(res, 500);
});
// @ts-expect-error (non strict)
await Expanded.play(context);
const releaseNotes = await canvas.queryByText(/What's new/);
await expect(releaseNotes).not.toBeInTheDocument();
},
};