Skip to content
Closed
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
64 changes: 64 additions & 0 deletions src/components/LeftNavBar/LeftNavbar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Meta, StoryObj } from "@storybook/react"

import LeftNavBar from "."

const meta: Meta<typeof LeftNavBar> = {
title: "Molecules / Navigation / LeftNavBar",
component: LeftNavBar,
parameters: {
layout: "centered",
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, we use the satisfies keyword as the most up-to-date approach in typing the meta object to ensure that required args aren't missing (not just invalid).

We also should better emulated how we expect this component to be rendered in context. We should allow the story layout to be fullscreen, and create a decorator around the rendering with a max width that matches the max width LeftNavBar is given on a page. Here, that max width is 400px. (See Roadmap page for example)

Suggested change
const meta: Meta<typeof LeftNavBar> = {
title: "Molecules / Navigation / LeftNavBar",
component: LeftNavBar,
parameters: {
layout: "centered",
},
}
const meta = {
title: "Molecules / Navigation / LeftNavBar",
component: LeftNavBar,
parameters: {
layout: "fullscreen",
},
decorators: [
(Story) => (
<div className="max-w-[496px]">
<Story />
</div>
),
],
} satisfies Meta<typeof LeftNavBar>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TylerAPfledderer no worries really. I know they been busy, and thank you for reviewing it. It makes sense what you say so I will update that. :)


export default meta

type Story = StoryObj<typeof meta>

const mockTocItems = [
{
id: "section-1",
title: "Section 1",
url: "#section-1",
items: [
{
id: "subsection-1",
title: "Subsection 1",
url: "#subsection-1",
},
],
},
{
id: "section-2",
title: "Section 2",
url: "#section-2",
},
]

const mockDropdownLinks = {
text: "More",
ariaLabel: "More links",
items: [
{ text: "Link 1", to: "/link1" },
{ text: "Link 2", to: "/link2" },
],
}

export const Default: Story = {
args: {
tocItems: mockTocItems,
},
}

export const WithDropdown: Story = {
args: {
tocItems: mockTocItems,
dropdownLinks: mockDropdownLinks,
},
}

export const CustomMaxDepth: Story = {
args: {
tocItems: mockTocItems,
maxDepth: 2,
},
}