Skip to content

Improve component library stories #2756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
de7f36b
docs: add stories for CopyButton component
aaronbassett Jun 3, 2025
7696c78
fix: remove horizontal scrollbar from story canvas
aaronbassett Jun 3, 2025
857cf91
docs: add stories for EntityList component
aaronbassett Jun 3, 2025
5fa634f
docs: add stories for ErrorPage component
aaronbassett Jun 3, 2025
6aa8123
fix: switch from vh to % for preview contents to fix issue with not r…
aaronbassett Jun 3, 2025
3d068a3
chore: extract iconControl out into a shared import
aaronbassett Jun 3, 2025
35db31d
docs: add stories for InfoBox component
aaronbassett Jun 3, 2025
30c245b
docs: add stories for Meter component
aaronbassett Jun 3, 2025
6e574c2
docs: add stories for NoResults component
aaronbassett Jun 3, 2025
624fac6
chore: add @storybook/test dependency for spying on callbacks/actions
aaronbassett Jun 3, 2025
c10b3ca
docs: add stories for NotFoundPage component
aaronbassett Jun 3, 2025
5d242f1
docs: add ErrorPage, NoResults, and NotFoundPage as subcomponents of …
aaronbassett Jun 3, 2025
2ebe59e
docs: Add stories for CrossfadeTabPanels component
aaronbassett Jun 3, 2025
fa74d53
docs: add basic story for dropdown caret
aaronbassett Jun 3, 2025
49f8366
docs: add stories for Badge types
aaronbassett Jun 3, 2025
87ea561
chore: remove metasyntactic variable names
aaronbassett Jun 3, 2025
f981f6f
fix: move inline styles into SCSS modules
aaronbassett Jun 3, 2025
9ef2c44
fix: change invalid Button props
aaronbassett Jun 3, 2025
9330881
docs: add additional stories for Header component
aaronbassett Jun 3, 2025
feca397
docs: add autodocs for Link component
aaronbassett Jun 3, 2025
20ff158
chore: remove metasyntactic variable names
aaronbassett Jun 3, 2025
d52f029
docs: add stories to SearchInput component
aaronbassett Jun 3, 2025
b19e10d
docs: add stories to Select component
aaronbassett Jun 3, 2025
206a4e9
docs: add stories for SingleToggleGroup
aaronbassett Jun 3, 2025
4c961eb
docs: add detailed stories for StatCard component
aaronbassett Jun 3, 2025
547cb37
chore: move inline styles into SCSS modules
aaronbassett Jun 3, 2025
5f47931
docs: add detailed stories for Status component variants
aaronbassett Jun 3, 2025
b06d1b3
docs: add stories for Switch component
aaronbassett Jun 3, 2025
ab2bfbe
chore: remove metasyntactic variables
aaronbassett Jun 3, 2025
32b52fe
docs: add stories for Table component
aaronbassett Jun 3, 2025
d21ed0c
docs: organize components into groups
aaronbassett Jun 3, 2025
d292372
fix: apply formatter and linter fixes
aaronbassett Jun 3, 2025
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
4 changes: 3 additions & 1 deletion packages/component-library/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export const decorators: Decorator[] = [
"data-background": globals.background,
})}
>
<Story />
<div className={styles.storyWrapper}>
<Story />
</div>
</BodyProviders>
)}
</RootProviders>
Expand Down
21 changes: 18 additions & 3 deletions packages/component-library/.storybook/storybook.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ body,
}

.contents {
height: 100vh;
width: 100vw;
height: 100%;
min-width: 100%;
color: theme.color("foreground");
background: theme.color("background", "primary");
display: grid;
Expand All @@ -19,7 +19,6 @@ body,
}

&[data-layout="padded"] {
padding: theme.spacing(10);
display: block;
place-content: unset;
}
Expand All @@ -29,3 +28,19 @@ body,
place-content: unset;
}
}

.storyWrapper {
padding: theme.spacing(4);
width: 100%;
max-width: min(100%, 1280px); // xl breakpoint
box-sizing: border-box;

[data-layout="padded"] & {
padding: theme.spacing(10);
}

[data-layout="fullscreen"] & {
padding: 0;
max-width: none;
}
}
1 change: 1 addition & 0 deletions packages/component-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"@storybook/blocks": "catalog:",
"@storybook/nextjs": "catalog:",
"@storybook/react": "catalog:",
"@storybook/test": "catalog:",
"@svgr/webpack": "catalog:",
"@types/jest": "catalog:",
"@types/react": "catalog:",
Expand Down
68 changes: 61 additions & 7 deletions packages/component-library/src/AppShell/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import type { Meta, StoryObj } from "@storybook/react";

import { AppBody as AppShellComponent } from "./index.jsx";
import type { Props as ErrorPageProps } from "../ErrorPage/index.jsx";
import { ErrorPage } from "../ErrorPage/index.jsx";
import { NetworkError as NetworkErrorStory } from "../ErrorPage/index.stories.jsx";
import { InfoBox } from "../InfoBox/index.jsx";
import type { Props as NoResultsProps } from "../NoResults/index.jsx";
import { NoResults } from "../NoResults/index.jsx";
import { WarningVariant as WarningVariantStory } from "../NoResults/index.stories.jsx";
import { NotFoundPage } from "../NotFoundPage/index.jsx";

const meta = {
title: "layouts & pages/AppShell",
component: AppShellComponent,
subcomponents: { ErrorPage, NoResults, NotFoundPage },
globals: {
args: {
appName: "Component Library",
children: "Hello world!",
tabs: [
{ children: "Home", segment: "" },
{ children: "Products", segment: "products" },
{ children: "Developers", segment: "developers" },
],
},
bare: true,
theme: {
disable: true,
Expand Down Expand Up @@ -35,17 +54,52 @@ const meta = {
},
},
},
tags: ["autodocs"],
} satisfies Meta<typeof AppShellComponent>;
export default meta;

export const AppShell = {
args: {
appName: "Component Library",
children: "Hello world!",
tabs: [
{ children: "Home", segment: "" },
{ children: "Foo", segment: "foo" },
{ children: "Bar", segment: "bar" },
],
...meta.globals.args,
},
render: (args) => (
<AppShellComponent {...args}>
<InfoBox>{args.children}</InfoBox>
</AppShellComponent>
),
} satisfies StoryObj<typeof AppShellComponent>;

type Story = StoryObj<typeof meta>;

export const ErrorStory: Story = {
args: {
...meta.globals.args,
},
render: (args) => (
<AppShellComponent {...args}>
<ErrorPage {...(NetworkErrorStory.args as ErrorPageProps)} />
</AppShellComponent>
),
};

export const NoResultsStory: Story = {
args: {
...meta.globals.args,
},
render: (args) => (
<AppShellComponent {...args}>
<NoResults {...(WarningVariantStory.args as NoResultsProps)} />
</AppShellComponent>
),
};

export const NotFoundStory: Story = {
args: {
...meta.globals.args,
},
render: (args) => (
<AppShellComponent {...args}>
<NotFoundPage />
</AppShellComponent>
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../theme";

.variantsContainer {
display: flex;
gap: theme.spacing(2);
flex-wrap: wrap;
align-items: center;
}
135 changes: 134 additions & 1 deletion packages/component-library/src/Badge/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Meta, StoryObj } from "@storybook/react";

import { Badge as BadgeComponent, VARIANTS, SIZES, STYLES } from "./index.jsx";
import { Badge as BadgeComponent, SIZES, STYLES, VARIANTS } from "./index.jsx";
import styles from "./index.stories.module.scss";

const meta = {
title: "building blocks/Badge",
component: BadgeComponent,
argTypes: {
children: {
Expand Down Expand Up @@ -33,6 +35,7 @@ const meta = {
},
},
},
tags: ["autodocs"],
} satisfies Meta<typeof BadgeComponent>;
export default meta;

Expand All @@ -44,3 +47,133 @@ export const Badge = {
size: "md",
},
} satisfies StoryObj<typeof BadgeComponent>;

type Story = StoryObj<typeof BadgeComponent>;

const renderAllVariants = (
style: (typeof STYLES)[number],
size: (typeof SIZES)[number],
children: React.ReactNode,
) => (
<div className={styles.variantsContainer}>
{VARIANTS.map((variant) => (
<BadgeComponent key={variant} variant={variant} style={style} size={size}>
{children}
</BadgeComponent>
))}
</div>
);

export const FilledXS: Story = {
args: {
children: "Badge",
},
render: ({ children }) => renderAllVariants("filled", "xs", children),
argTypes: {
variant: { table: { disable: true } },
style: { table: { disable: true } },
size: { table: { disable: true } },
},
parameters: {
docs: {
description: {
story: "Extra small filled badges in all variants",
},
},
},
};

export const FilledMD: Story = {
args: {
children: "Badge",
},
render: ({ children }) => renderAllVariants("filled", "md", children),
argTypes: {
variant: { table: { disable: true } },
style: { table: { disable: true } },
size: { table: { disable: true } },
},
parameters: {
docs: {
description: {
story: "Medium filled badges in all variants",
},
},
},
};

export const FilledLG: Story = {
args: {
children: "Badge",
},
render: ({ children }) => renderAllVariants("filled", "lg", children),
argTypes: {
variant: { table: { disable: true } },
style: { table: { disable: true } },
size: { table: { disable: true } },
},
parameters: {
docs: {
description: {
story: "Large filled badges in all variants",
},
},
},
};

export const OutlineXS: Story = {
args: {
children: "Badge",
},
render: ({ children }) => renderAllVariants("outline", "xs", children),
argTypes: {
variant: { table: { disable: true } },
style: { table: { disable: true } },
size: { table: { disable: true } },
},
parameters: {
docs: {
description: {
story: "Extra small outline badges in all variants",
},
},
},
};

export const OutlineMD: Story = {
args: {
children: "Badge",
},
render: ({ children }) => renderAllVariants("outline", "md", children),
argTypes: {
variant: { table: { disable: true } },
style: { table: { disable: true } },
size: { table: { disable: true } },
},
parameters: {
docs: {
description: {
story: "Medium outline badges in all variants",
},
},
},
};

export const OutlineLG: Story = {
args: {
children: "Badge",
},
render: ({ children }) => renderAllVariants("outline", "lg", children),
argTypes: {
variant: { table: { disable: true } },
style: { table: { disable: true } },
size: { table: { disable: true } },
},
parameters: {
docs: {
description: {
story: "Large outline badges in all variants",
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Meta, StoryObj } from "@storybook/react";
import { Breadcrumbs as BreadcrumbsComponent } from "./index.jsx";

const meta = {
title: "navigation & menus/Breadcrumbs",
component: BreadcrumbsComponent,
argTypes: {
label: {
Expand All @@ -25,8 +26,8 @@ export const Breadcrumbs = {
label: "Breadcrumbs",
items: [
{ href: "/", label: "Home" },
{ href: "/foo", label: "Foo" },
{ label: "Bar" },
{ href: "#", label: "Products" },
{ label: "Pyth Core" },
],
},
} satisfies StoryObj<typeof BreadcrumbsComponent>;
14 changes: 2 additions & 12 deletions packages/component-library/src/Button/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import * as icons from "@phosphor-icons/react/dist/ssr";
import type { Meta, StoryObj } from "@storybook/react";

import { Button as ButtonComponent, VARIANTS, SIZES } from "./index.jsx";

const iconControl = {
control: "select",
options: Object.keys(icons),
mapping: Object.fromEntries(
Object.entries(icons).map(([iconName, Icon]) => [
iconName,
<Icon key={iconName} weights={new Map()} />,
]),
),
} as const;
import { iconControl } from "../icon-control.jsx";

const meta = {
title: "forms & controls/Button",
component: ButtonComponent,
argTypes: {
children: {
Expand Down
Loading
Loading