Skip to content

Commit

Permalink
docs: add 4 components to CSS storybook: root/body/page-layout/page-body
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Feb 9, 2025
1 parent 32644ca commit 145264a
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 24 deletions.
6 changes: 6 additions & 0 deletions packages/storybook-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,16 @@
"@utrecht/number-badge-css": "workspace:*",
"@utrecht/number-data-css": "workspace:*",
"@utrecht/ordered-list-css": "workspace:*",
"@utrecht/page-body-css": "workspace:*",
"@utrecht/page-body-react": "workspace:*",
"@utrecht/page-content-css": "workspace:*",
"@utrecht/page-css": "workspace:*",
"@utrecht/page-footer-css": "workspace:*",
"@utrecht/page-footer-react": "workspace:*",
"@utrecht/page-header-css": "workspace:*",
"@utrecht/page-header-react": "workspace:*",
"@utrecht/page-layout-css": "workspace:*",
"@utrecht/page-layout-react": "workspace:*",
"@utrecht/pagination-css": "workspace:*",
"@utrecht/paragraph-css": "workspace:*",
"@utrecht/pre-heading-css": "workspace:*",
Expand Down
51 changes: 51 additions & 0 deletions packages/storybook-css/src/Body.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* @license CC0-1.0 */

import { Meta, StoryObj } from '@storybook/react';
import readme from '@utrecht/body-css/README.md?raw';
import tokensDefinition from '@utrecht/body-css/src/tokens.json';
import { Body } from '@utrecht/body-react';
import tokens from '@utrecht/design-tokens/dist/index.json';
import React from 'react';
import Paragraph from './Paragraph';
import { designTokenStory } from './design-token-story';

const meta = {
title: 'CSS Component/Body',
id: 'css-body',
component: Body,
argTypes: {
children: {
description: 'Body content',
},
},
args: {
children: [],
},
parameters: {
bugs: 'https://github.com/nl-design-system/utrecht/issues?q=is%3Aissue+is%3Aopen+label%3Acomponent%2Fbody',
layout: 'fullscreen',
tokensPrefix: 'utrecht-body',
status: {
type: 'WORK IN PROGRESS',
},
tokens,
tokensDefinition,
docs: {
description: {
component: readme,
},
},
},
} satisfies Meta<typeof Body>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
children: [<Paragraph>Body content</Paragraph>],
},
};

export const DesignTokens = designTokenStory(meta);
148 changes: 148 additions & 0 deletions packages/storybook-css/src/PageBody.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/* @license CC0-1.0 */

import { Meta, StoryObj } from '@storybook/react';
import {
BreadcrumbNav,
BreadcrumbNavLink,
Code,
Heading1,
Heading2,
Link,
Paragraph,
UnorderedList,
UnorderedListItem,
} from '@utrecht/component-library-react';
import tokens from '@utrecht/design-tokens/dist/index.json';
import readme from '@utrecht/page-body-css/README.md?raw';
import tokensDefinition from '@utrecht/page-body-css/src/tokens.json';
import { PageBody } from '@utrecht/page-body-react';
import React, { PropsWithChildren, ReactNode } from 'react';
import { designTokenStory } from './design-token-story';

interface PageBodyStoryProps {
aside?: ReactNode;
main?: ReactNode;
nav?: ReactNode;
}

const PageBodyStory = ({ aside, children, main, nav }: PropsWithChildren<PageBodyStoryProps>) => (
<PageBody>
{nav && <div className="utrecht-page-body__nav">{nav}</div>}
{main && <main className="utrecht-page-body__main">{main}</main>}
{aside && <aside className="utrecht-page-body__aside">{aside}</aside>}
{children}
</PageBody>
);

const meta = {
title: 'CSS Component/Page Body',
id: 'css-page-body',
component: PageBodyStory,
argTypes: {
children: {
description: 'Page body content',
},
},
args: {
children: [],
},
parameters: {
bugs: 'https://github.com/nl-design-system/utrecht/issues?q=is%3Aissue+is%3Aopen+label%3Acomponent%2Fpage-body',
tokensPrefix: 'utrecht-page-body',
status: {
type: 'WORK IN PROGRESS',
},
tokens,
tokensDefinition,
docs: {
description: {
component: readme,
},
},
},
} satisfies Meta<typeof PageBodyStory>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
children: [
<Heading1>Lorem ipsum</Heading1>,
<Paragraph>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</Paragraph>,
],
},
};

export const PageBodyWithBreadcrumb: Story = {
args: {
nav: (
<BreadcrumbNav appearance="arrows">
<BreadcrumbNavLink href="https://example.com/" rel="home">
Home
</BreadcrumbNavLink>
<BreadcrumbNavLink href="https://example.com/a/">Wonen en leven</BreadcrumbNavLink>
<BreadcrumbNavLink href="https://example.com/a/b/" rel="up">
Afval
</BreadcrumbNavLink>
</BreadcrumbNav>
),
main: [
<Heading1>Main page content</Heading1>,
<Paragraph>
The main landmark should not include breadcrumb navigation. Breadcrumb links should be part of navigation
landmark.
</Paragraph>,
],
},
parameters: {
docs: {
description: {
story: `The \`main\` landmark should not include breadcrumb navigation. Breadcrumb links should be part of \`navigation\` landmark.
The preferred markup for secondary navigation components is \`<nav>\` with \`aria-labelledby\` to give it a unique label.`,
},
},
},
name: 'Breadcrumb navigation',
};

export const PageBodyWithAside: Story = {
args: {
main: [
<Heading1>Main page content</Heading1>,
<Paragraph>
The <Code>main</Code> landmark should be used to separate the main content from complementary and unrelated
content.
</Paragraph>,
],
aside: [
<Heading2>Related pages</Heading2>,
<UnorderedList>
<UnorderedListItem>
<Link href="https://www.htmhell.dev/tips/landmarks/" external>
Landmarks — HTMHell
</Link>
</UnorderedListItem>
<UnorderedListItem>
<Link
href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Complementary_role"
external
>
ARIA: complementary role — MDN
</Link>
</UnorderedListItem>
</UnorderedList>,
],
},
name: 'Complementary content',
};

export const DesignTokens = designTokenStory(meta);
12 changes: 2 additions & 10 deletions packages/storybook-css/src/PageFooter.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
/* @license CC0-1.0 */

import { Meta, StoryObj } from '@storybook/react';
import {
Heading2,
Heading3,
Link,
LinkList,
LinkListLink,
PageFooter,
Paragraph,
Strong,
} from '@utrecht/component-library-react';
import { Heading2, Heading3, Link, LinkList, LinkListLink, Paragraph, Strong } from '@utrecht/component-library-react';
import tokens from '@utrecht/design-tokens/dist/index.json';
import readme from '@utrecht/page-footer-css/README.md?raw';
import tokensDefinition from '@utrecht/page-footer-css/src/tokens.json';
import { PageFooter } from '@utrecht/page-footer-react';
import { UtrechtIconChevronRight } from '@utrecht/web-component-library-react';
import React from 'react';
import { designTokenStory } from './design-token-story';
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook-css/src/PageHeader.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* @license CC0-1.0 */

import { Meta, StoryObj } from '@storybook/react';
import { PageHeader } from '@utrecht/component-library-react';
import tokens from '@utrecht/design-tokens/dist/index.json';
import readme from '@utrecht/page-header-css/README.md?raw';
import tokensDefinition from '@utrecht/page-header-css/src/tokens.json';
import { PageHeader } from '@utrecht/page-header-react';
import { designTokenStory } from './design-token-story';

const meta = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
/* @license CC0-1.0 */

import { Meta, StoryObj } from '@storybook/react';
import { Page, PageContent, PageFooter, PageHeader } from '@utrecht/component-library-react';
import tokens from '@utrecht/design-tokens/dist/index.json';
import readme from '@utrecht/page-css/README.md?raw';
import tokensDefinition from '@utrecht/page-css/src/tokens.json';
import { PageBody } from '@utrecht/page-body-react';
import { PageFooter } from '@utrecht/page-footer-react';
import { PageHeader } from '@utrecht/page-header-react';
import readme from '@utrecht/page-layout-css/README.md?raw';
import tokensDefinition from '@utrecht/page-layout-css/src/tokens.json';
import { PageLayout } from '@utrecht/page-layout-react';
import React from 'react';
import { designTokenStory } from './design-token-story';

const meta = {
title: 'CSS Component/Page',
id: 'css-page',
component: Page,
title: 'CSS Component/Page Layout',
id: 'css-page-layout',
component: PageLayout,
argTypes: {
children: {
description: 'Page content',
description: 'Page layout content',
},
},
args: {
children: [],
},
parameters: {
bugs: 'https://github.com/nl-design-system/utrecht/issues?q=is%3Aissue+is%3Aopen+label%3Acomponent%2Fpage',
bugs: 'https://github.com/nl-design-system/utrecht/issues?q=is%3Aissue+is%3Aopen+label%3Acomponent%2Fpage-layout',
layout: 'fullscreen',
tokensPrefix: 'utrecht-page',
tokensPrefix: 'utrecht-page-layout',
status: {
type: 'WORK IN PROGRESS',
},
Expand All @@ -35,7 +38,7 @@ const meta = {
},
},
},
} satisfies Meta<typeof Page>;
} satisfies Meta<typeof PageLayout>;

export default meta;

Expand All @@ -45,9 +48,9 @@ export const Default: Story = {
args: {
children: [
<PageHeader>Header area</PageHeader>,
<PageContent>
<main className="utrecht-page-content__main">Content area</main>
</PageContent>,
<PageBody>
<main>Content area</main>
</PageBody>,
<PageFooter>Footer area</PageFooter>,
],
},
Expand Down
56 changes: 56 additions & 0 deletions packages/storybook-css/src/Root.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* @license CC0-1.0 */

import { Meta, StoryObj } from '@storybook/react';
import { Body } from '@utrecht/body-react';
import tokens from '@utrecht/design-tokens/dist/index.json';
import readme from '@utrecht/root-css/README.md?raw';
import tokensDefinition from '@utrecht/root-css/src/tokens.json';
import { Root } from '@utrecht/root-react';
import React from 'react';
import Paragraph from './Paragraph';
import { designTokenStory } from './design-token-story';

const meta = {
title: 'CSS Component/Root',
id: 'css-root',
component: Root,
argTypes: {
children: {
description: 'Root content',
},
},
args: {
children: [],
},
parameters: {
bugs: 'https://github.com/nl-design-system/utrecht/issues?q=is%3Aissue+is%3Aopen+label%3Acomponent%2Froot',
layout: 'fullscreen',
tokensPrefix: 'utrecht-root',
status: {
type: 'WORK IN PROGRESS',
},
tokens,
tokensDefinition,
docs: {
description: {
component: readme,
},
},
},
} satisfies Meta<typeof Root>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
children: [
<Body>
<Paragraph>Root content</Paragraph>
</Body>,
],
},
};

export const DesignTokens = designTokenStory(meta);
Loading

0 comments on commit 145264a

Please sign in to comment.