Skip to content

Commit 5848410

Browse files
author
Nikolai Lopin
committed
docs: migrate Headline docs
1 parent 34cda7a commit 5848410

File tree

5 files changed

+137
-111
lines changed

5 files changed

+137
-111
lines changed

src/components/Headline/Headline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface HeadlineProps extends ComponentPropsWithoutRef<'h1'>, MarginProps, Tex
2121
size?: ResponsiveValue<'xxl' | 'xl' | 'l' | 'm' | 's' | 'xs'>;
2222
}
2323

24-
const DEFAULT_HEADLINE_SIZE = {
24+
export const DEFAULT_HEADLINE_SIZE = {
2525
h1: 'xxl',
2626
h2: 'xl',
2727
h3: 'l',

src/components/Headline/docs/Headline.mdx

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Meta, StoryObj } from '@storybook/react';
2+
import { DEFAULT_HEADLINE_SIZE, Headline } from '../Headline';
3+
4+
const meta: Meta = {
5+
title: 'Components/Headline',
6+
component: Headline,
7+
args: {
8+
children: "The dos and don'ts of eating sushi"
9+
},
10+
argTypes: {
11+
size: {
12+
table: {
13+
defaultValue: {
14+
summary: 'depends on the heading level',
15+
detail: Object.entries(DEFAULT_HEADLINE_SIZE)
16+
.map(([tag, size]) => `${tag}${size}`)
17+
.join('\n')
18+
}
19+
},
20+
control: 'select',
21+
options: ['xxl', 'xl', 'l', 'm', 's', 'xs']
22+
}
23+
}
24+
};
25+
26+
export default meta;
27+
28+
type Story = StoryObj<typeof Headline>;
29+
30+
export const Default: Story = {};
31+
32+
export const WithAnotherLevel: Story = {
33+
args: {
34+
as: 'h3'
35+
}
36+
};
37+
38+
export const WithAnotherSize: Story = {
39+
args: {
40+
size: 's'
41+
}
42+
};
43+
44+
export const Inverted: Story = {
45+
args: {
46+
inverted: true
47+
},
48+
parameters: {
49+
backgrounds: {
50+
default: 'dark'
51+
}
52+
}
53+
};
54+
55+
export const Responsive: Story = {
56+
args: {
57+
children: 'Change the viewport size',
58+
size: ['s', 'xl']
59+
}
60+
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { ArgsTable, Meta, Primary, Stories, Unstyled } from '@storybook/blocks';
2+
import { ItemWrapper } from '../../../../docs/components/ItemWrapper';
3+
import { StyledSystemLinks } from '../../../docs/StyledSystemLinks';
4+
import { Headline } from '../Headline';
5+
import * as HeadlineStories from './Headline.stories';
6+
7+
<Meta of={HeadlineStories} />
8+
9+
# Headline
10+
11+
<Primary />
12+
13+
The Headline component will render an html `h1-6` tag. Please reference the
14+
[w3 recommendations for headings](https://www.w3.org/WAI/tutorials/page-structure/headings/) to ensure your headings
15+
provide an accessible experience for screen reader users.
16+
17+
Prefer to use headlines starting from level one and not skip levels. Use combination of `as` and `size` property to keep
18+
the semantics while following the design.
19+
20+
- Use different headlines and paragraphs to structure your content hierarchically
21+
- Avoid using headline lengths, breaking more than two times (three times on mobile)
22+
- Avoid using sizes outside the given range
23+
- Recommended width of headline is between 500px and 700px
24+
25+
## Properties
26+
27+
<ArgsTable of={Headline} />
28+
<StyledSystemLinks component="Headline" supportedProps={['margin', 'textAlign']} />
29+
30+
## Default headlines
31+
32+
<Unstyled>
33+
<ItemWrapper>
34+
<Headline as="h1">headline h1</Headline>
35+
<Headline as="h2">headline h2</Headline>
36+
<Headline as="h3">headline h3</Headline>
37+
<Headline as="h4">headline h4</Headline>
38+
<Headline as="h5">headline h5</Headline>
39+
<Headline as="h6">headline h6</Headline>
40+
</ItemWrapper>
41+
<ItemWrapper inverted>
42+
<Headline as="h1" inverted>
43+
headline h1 inverted
44+
</Headline>
45+
<Headline as="h2" inverted>
46+
headline h2 inverted
47+
</Headline>
48+
<Headline as="h3" inverted>
49+
headline h3 inverted
50+
</Headline>
51+
<Headline as="h4" inverted>
52+
headline h4 inverted
53+
</Headline>
54+
<Headline as="h5" inverted>
55+
headline h5 inverted
56+
</Headline>
57+
<Headline as="h6" inverted>
58+
headline h6 inverted
59+
</Headline>
60+
</ItemWrapper>
61+
</Unstyled>
62+
63+
## Responsive size
64+
65+
The `size` property supports [responsive values](https://styled-system.com/responsive-styles/). Pass an array or an object
66+
and the design system use corresponding values for different viewport sizes.
67+
68+
For example, the following snippet uses `s` size for mobile and `xl` size bigger screens:
69+
70+
```jsx
71+
<Headline as="h2" size={{ _: 's', medium: 'xl' }}>
72+
Small on mobile, big on bigger screens
73+
</Headline>
74+
```
75+
76+
<Stories includePrimary={false} />

src/components/Headline/docs/HeadlinePropsTable.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)