Skip to content
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

feat!: Remove HeadingLevel type, group Heading sizes in story #1387

Merged
merged 16 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
7 changes: 5 additions & 2 deletions packages/react/src/Heading/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { forwardRef } from 'react'
import type { ForwardedRef, HTMLAttributes, PropsWithChildren } from 'react'
import { getHeadingElement } from './getHeadingElement'

export type HeadingLevel = 1 | 2 | 3 | 4
type HeadingSize = 'level-1' | 'level-2' | 'level-3' | 'level-4' | 'level-5' | 'level-6'
export const headingLevels: Array<number> = [1, 2, 3, 4]
export const headingSizes: Array<string> = ['level-1', 'level-2', 'level-3', 'level-4', 'level-5', 'level-6']

export type HeadingLevel = (typeof headingLevels)[number]
export type HeadingSize = (typeof headingSizes)[number]
alimpens marked this conversation as resolved.
Show resolved Hide resolved

export type HeadingProps = {
/** Changes the text colour for readability on a dark background. */
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Heading/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { Heading } from './Heading'
export { Heading, headingLevels, headingSizes } from './Heading'
alimpens marked this conversation as resolved.
Show resolved Hide resolved
export type { HeadingLevel, HeadingProps } from './Heading'
alimpens marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 11 additions & 10 deletions storybook/src/components/Heading/Heading.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ import README from "../../../../packages/css/src/components/heading/README.md?ra

## Examples

### Heading 1
### Levels

<Canvas of={HeadingStories.Heading1} />
Four levels of headings are available.
A page should contain only one Heading with level 1.
Do not skip heading levels.
User agents can use heading information to construct a table of contents for a document.
alimpens marked this conversation as resolved.
Show resolved Hide resolved

### Heading 2
<Canvas of={HeadingStories.Levels} />

<Canvas of={HeadingStories.Heading2} />
### Sizes

### Heading 3
It may be useful to display a heading in smaller font sizes.
We offer six sizes to match the list of [Text Levels](?path=/docs/docs-design-guidelines-typography--docs).
Be sure to maintain a consistent semantic hierarchy of heading levels.

<Canvas of={HeadingStories.Heading3} />

### Heading 4

<Canvas of={HeadingStories.Heading4} />
<Canvas of={HeadingStories.Sizes} />

### Inverse colour

Expand Down
34 changes: 17 additions & 17 deletions storybook/src/components/Heading/Heading.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright Gemeente Amsterdam
*/

import { Heading } from '@amsterdam/design-system-react/src'
import { Column, Heading, headingLevels, headingSizes } from '@amsterdam/design-system-react/src'
import { Meta, StoryObj } from '@storybook/react'
import { inverseColorDecorator } from '../shared/decorators'
import { exampleHeading } from '../shared/exampleContent'
Expand Down Expand Up @@ -32,24 +32,24 @@ type Story = StoryObj<typeof meta>

export const Default: Story = {}

export const Heading1: Story = {}

export const Heading2: Story = {
args: {
level: 2,
},
export const Levels: Story = {
render: (args) => (
<Column gap="small">
{headingLevels.map((level) => (
alimpens marked this conversation as resolved.
Show resolved Hide resolved
<Heading {...args} key={level} level={level} />
))}
</Column>
),
}

export const Heading3: Story = {
args: {
level: 3,
},
}

export const Heading4: Story = {
args: {
level: 4,
},
export const Sizes: Story = {
render: (args) => (
<Column gap="small">
{headingSizes.map((size) => (
<Heading {...args} key={size} size={size} />
))}
</Column>
),
}

export const InvertedColor: Story = {
Expand Down