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: Add examples of entire pages to Storybook #1234

Merged
merged 41 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9bb1010
Amsterdam Homepage start
dlnr May 17, 2024
3ed39ba
Article page pattern for demo
dlnr May 17, 2024
9472e8c
refactor: Update AmsterdamArticlePage to use Breadcrumb component
dlnr May 17, 2024
7b09997
Lighter content from exampleContent
dlnr May 17, 2024
d240d5a
a11y tip
dlnr May 17, 2024
b175666
Gradient background for spotlight test (no extra markup)
dlnr May 17, 2024
a4489d5
WIP (+1 squashed commit)
VincentSmedinga May 24, 2024
b9c90bb
Merge branch 'develop' into feature/storybook-patterns
VincentSmedinga Jun 6, 2024
9804324
Split Home and Article examples
VincentSmedinga Jun 6, 2024
4da88c2
Add introduction
VincentSmedinga Jun 6, 2024
28461d5
Expand pages like we do with components
VincentSmedinga Jun 6, 2024
62d527d
Prevent accidental navigation into dead ends
VincentSmedinga Jun 6, 2024
a4266b2
Update some actual component stories
VincentSmedinga Jun 6, 2024
b56777d
Improve introduction and add license to docs
VincentSmedinga Jun 6, 2024
aab7e43
Make Page Menu tests slightly more realistic
VincentSmedinga Jun 6, 2024
8ae9708
Use numeric keys in Overlap stories
VincentSmedinga Jun 6, 2024
ea2885c
Make separate examples for Page Menu in header and footer and reuse i…
VincentSmedinga Jun 6, 2024
fced853
Extract subcomponents and reuse more stories
VincentSmedinga Jun 6, 2024
647455d
Merge branch 'develop' into feature/storybook-patterns
VincentSmedinga Jun 13, 2024
389baad
Tweak things
VincentSmedinga Jun 7, 2024
b44f850
Add default Amsterdam footer
VincentSmedinga Jun 7, 2024
cc72b9d
Add initial documentation for Article Page
VincentSmedinga Jun 13, 2024
68fdad2
Improve default example for Breadcrumb
VincentSmedinga Jun 14, 2024
33cfe59
Replace lorem ipsum and inline styles
VincentSmedinga Jun 14, 2024
2fe1a33
Generalize function to pick random content
VincentSmedinga Jun 14, 2024
e330edd
Let Card display a random top task
VincentSmedinga Jun 14, 2024
1b4f039
Improve Card example
VincentSmedinga Jun 14, 2024
ad0667a
Remove buggy function to disable empty links
VincentSmedinga Jun 14, 2024
9ef14f0
Merge branch 'develop' into feature/storybook-patterns
VincentSmedinga Jun 14, 2024
040bbff
Improve accesibility of links to social platforms
VincentSmedinga Jun 19, 2024
c06b175
Deduplicate config
VincentSmedinga Jun 19, 2024
a9e8586
Remove unnecessary alternative text
VincentSmedinga Jun 19, 2024
4138185
Fix copy paste error
VincentSmedinga Jun 19, 2024
6daafa0
Remove alternative text for decorative image
VincentSmedinga Jun 19, 2024
1cbdf1b
Remove remnants of breadcrumbs prop
VincentSmedinga Jun 19, 2024
0202bd3
Fix content and target of Skip Links
VincentSmedinga Jun 19, 2024
f8fd519
Add required image source
VincentSmedinga Jun 19, 2024
6fcea2f
Use a real article instead of example content
VincentSmedinga Jun 19, 2024
c8b6d8c
Remove Article outline
VincentSmedinga Jun 19, 2024
91851f0
Add more example app components to home page
VincentSmedinga Jun 19, 2024
b440432
Merge branch 'develop' into feature/storybook-patterns
VincentSmedinga Jun 21, 2024
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
10 changes: 7 additions & 3 deletions packages/react/src/PageMenu/PageMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ describe('Page menu', () => {
it('renders a page menu with children', () => {
const { container } = render(
<PageMenu>
<PageMenu.Link href="#">English</PageMenu.Link>
<PageMenu.Link href="#" lang="en">
alimpens marked this conversation as resolved.
Show resolved Hide resolved
English
</PageMenu.Link>
<PageMenu.Link href="#" icon={LoginIcon}>
Inloggen Mijn Amsterdam
Mijn Amsterdam
</PageMenu.Link>
</PageMenu>,
)
Expand Down Expand Up @@ -39,7 +41,9 @@ describe('Page menu', () => {
const ref = createRef<HTMLUListElement>()
const { container } = render(
<PageMenu ref={ref}>
<PageMenu.Link href="#">English</PageMenu.Link>
<PageMenu.Link href="#" lang="en">
alimpens marked this conversation as resolved.
Show resolved Hide resolved
English
</PageMenu.Link>
</PageMenu>,
)
const component = container.querySelector(':only-child')
Expand Down
6 changes: 4 additions & 2 deletions storybook/config/manager-head.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<script id="storybook-mod-expand-all-folders" type="text/javascript">
// Somewhat hacky way to expand all folders. Storybook does not support that natively.
var clickCollapsedItemsUntilNoneLeft = () => {
const itemsLeftToClick = document.querySelectorAll('button[data-parent-id="components"][aria-expanded="false"]');
const collapsedItems = document.querySelectorAll(
':is(button[data-parent-id="components"], button[data-parent-id="pages"])[aria-expanded="false"]',
);

for (item of itemsLeftToClick) {
for (item of collapsedItems) {
item.click();
}
};
Expand Down
2 changes: 2 additions & 0 deletions storybook/config/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const parameters = {
['Introduction', 'Assets', 'Design Guidelines'],
'Components',
['Buttons', 'Containers', 'Feedback', 'Forms', 'Layout', 'Media', 'Navigation', 'Text'],
'Pages',
['Introduction', 'Amsterdam.nl', ['Home']],
],
},
},
Expand Down
4 changes: 4 additions & 0 deletions storybook/config/storybook-overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@
font-size: 0.875rem;
}

:is(#storybook-root, .sbdocs-content) a[href="#"] {
cursor: not-allowed;
}

/* stylelint-enable */
7 changes: 5 additions & 2 deletions storybook/src/components/Breadcrumb/Breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ export const Default: Story = {
Home
</Breadcrumb.Link>,
<Breadcrumb.Link href="#" key={2}>
Nieuws
Afval
</Breadcrumb.Link>,
<Breadcrumb.Link href="#" key={3}>
Kennisgevingen en bekendmakingen
Bedrijfsafval
</Breadcrumb.Link>,
<Breadcrumb.Link href="#" key={4}>
Recyclepunten voor bedrijven
</Breadcrumb.Link>,
],
},
Expand Down
15 changes: 8 additions & 7 deletions storybook/src/components/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { AspectRatio, Card, Heading, Image, Paragraph } from '@amsterdam/design-system-react/src'
import { Meta, StoryObj } from '@storybook/react'
import { exampleTopTask } from '../shared/exampleContent'

const dateFormat = new Intl.DateTimeFormat('nl', {
day: 'numeric',
Expand All @@ -13,6 +14,8 @@ const dateFormat = new Intl.DateTimeFormat('nl', {
})
const today = dateFormat.format(Date.now())

const topTask = exampleTopTask()

const meta = {
title: 'Components/Navigation/Card',
component: Card,
Expand All @@ -33,11 +36,9 @@ export const Default: Story = {
args: {
children: [
<Heading size="level-4" key={1}>
<Card.Link href="/">Monitor Attracties MRA</Card.Link>
<Card.Link href="/">{topTask.heading}</Card.Link>
</Heading>,
<Paragraph key={2}>
Ontwikkeling van het aantal attracties en bezoekers in de metropoolregio Amsterdam.
</Paragraph>,
<Paragraph key={2}>{topTask.description}</Paragraph>,
],
},
}
Expand All @@ -63,13 +64,13 @@ export const WithImage: Story = {
<AspectRatio key={1} ratio="wide">
<Image alt="" src="https://picsum.photos/480/360" />
</AspectRatio>,
<Card.HeadingGroup key={2} tagline="Dossier">
<Card.HeadingGroup key={2} tagline="Nieuws">
<Heading size="level-4">
<Card.Link href="/">Monitor Attracties MRA</Card.Link>
<Card.Link href="/">Nederlands eerste houten woonwijk komt in Zuidoost</Card.Link>
</Heading>
</Card.HeadingGroup>,
<Paragraph key={3}>
Ontwikkeling van het aantal attracties en bezoekers in de metropoolregio Amsterdam.
We bouwen een levendige, groene en duurzame woonbuurt tussen de Gooiseweg en het Nelson Mandelapark.
</Paragraph>,
<Paragraph key={4} size="small">
{today}
Expand Down
11 changes: 10 additions & 1 deletion storybook/src/components/Footer/Footer.docs.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{/* @license CC0-1.0 */}

import { Markdown, Meta, Primary } from "@storybook/blocks";
import { Canvas, Markdown, Meta, Primary } from "@storybook/blocks";
import * as FooterStories from "./Footer.stories.tsx";
import README from "../../../../packages/css/src/components/footer/README.md?raw";

Expand All @@ -9,3 +9,12 @@ import README from "../../../../packages/css/src/components/footer/README.md?raw
<Markdown>{README}</Markdown>

<Primary />

## Examples

### Onderzoek en Statistiek

The footer for a specific website can be a bit different.
Here’s an example for the ‘Onderzoek en Statistiek’ department.

<Canvas of={FooterStories.Onderzoek} />
198 changes: 143 additions & 55 deletions storybook/src/components/Footer/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ import {
Paragraph,
VisuallyHidden,
} from '@amsterdam/design-system-react/src'
import { EmailIcon, PhoneIcon } from '@amsterdam/design-system-react-icons'
import {
CameraIcon,
ClockIcon,
EmailIcon,
FacebookIcon,
LinkedinIcon,
PhoneIcon,
TwitterIcon,
} from '@amsterdam/design-system-react-icons'
import { Meta, StoryObj } from '@storybook/react'
import { Default as PageMenuStory } from '../../components/PageMenu/PageMenu.stories'

const meta = {
title: 'Components/Containers/Footer',
Expand All @@ -24,6 +33,13 @@ export default meta

type Story = StoryObj<typeof meta>

const socialPlatforms = [
{ icon: TwitterIcon, name: 'Twitter' },
{ icon: FacebookIcon, name: 'Facebook' },
{ icon: LinkedinIcon, name: 'Linkedin' },
{ icon: CameraIcon, name: 'Instagram' },
]

export const Default: Story = {
args: {
children: [
Expand All @@ -32,65 +48,140 @@ export const Default: Story = {
<Heading>Colofon</Heading>
</VisuallyHidden>
<Grid gapVertical="large" paddingVertical="medium">
<Grid.Cell span={3}>
<div style={{ display: 'grid', gap: '2.5rem' }}>
<Heading level={2} size="level-4" inverseColor>
Contact
<Grid.Cell span={4}>
<Heading className="ams-mb--xs" level={2} size="level-4" inverseColor>
Meer weten
</Heading>
<LinkList>
{['Veel gestelde vragen', 'Over ons', 'Werken bij', 'Kalender', 'Uit in Amsterdam', 'Bronnen'].map(
(label, index) => (
<LinkList.Link href="#" key={index} onBackground="dark" size="small">
{label}
</LinkList.Link>
),
)}
</LinkList>
</Grid.Cell>
<Grid.Cell span={4} start={{ narrow: 1, medium: 5, wide: 5 }}>
<Heading className="ams-mb--xs" level={2} size="level-4" inverseColor>
Contact
</Heading>
<Paragraph className="ams-mb--xs" inverseColor size="small">
Hebt u een vraag en kunt u het antwoord niet vinden op deze website? Neem dan contact met ons op.
</Paragraph>
<LinkList>
<LinkList.Link href="mailto:[email protected]" icon={EmailIcon} onBackground="dark" size="small">
E-mail
</LinkList.Link>
<LinkList.Link href="tel:+3114020" icon={PhoneIcon} onBackground="dark" size="small">
14 020
</LinkList.Link>
<LinkList.Link href="#" icon={ClockIcon} onBackground="dark" size="small">
Contactgegevens en openingstijden
</LinkList.Link>
</LinkList>
</Grid.Cell>
<Grid.Cell span={4} start={{ narrow: 1, medium: 1, wide: 9 }}>
<section className="ams-mb--md">
<Heading className="ams-mb--xs" level={2} size="level-4" inverseColor>
Nieuwsbrief
</Heading>
<Paragraph size="small" inverseColor>
Heeft u een vraag en kunt u het antwoord niet vinden op deze site? Neem dan contact met ons op.
</Paragraph>
<LinkList>
<LinkList.Link href="mailto:[email protected]" icon={EmailIcon} onBackground="dark" size="small">
E-mail
</LinkList.Link>
<LinkList.Link href="tel:+31202510333" icon={PhoneIcon} onBackground="dark" size="small">
020 251 0333
<LinkList.Link href="#" onBackground="dark" size="small">
Inschrijven
</LinkList.Link>
</LinkList>
</div>
</Grid.Cell>
<Grid.Cell span={3} start={{ narrow: 1, medium: 5, wide: 5 }}>
<div style={{ display: 'grid', gap: '2.5rem' }}>
<Heading level={2} size="level-4" inverseColor>
Panels en enquêtes
</section>
<section>
<Heading className="ams-mb--xs" level={2} size="level-4" inverseColor>
Volg ons
</Heading>
<Paragraph size="small" inverseColor>
Bent u uitgenodigd om mee te doen aan onderzoek of heeft u vragen over het panel of stadspaspanel?
</Paragraph>
<LinkList>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Meedoen aan onderzoek
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Panel Amsterdam
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Stadspaspanel Amsterdam
</LinkList.Link>
{socialPlatforms.map(({ name, icon }) => (
<LinkList.Link href="#" icon={icon} key={name} onBackground="dark" size="small">
{name}
</LinkList.Link>
))}
</LinkList>
</div>
</section>
</Grid.Cell>
</Grid>
</Footer.Top>,
<Footer.Bottom key="footer-bottom">
<VisuallyHidden>
<Heading level={2}>Over deze website</Heading>
</VisuallyHidden>
<Grid paddingVertical="small">
<Grid.Cell span="all">
<PageMenu>{PageMenuStory.args?.children}</PageMenu>
</Grid.Cell>
</Grid>
</Footer.Bottom>,
],
},
}

export const Onderzoek: Story = {
args: {
children: [
<Footer.Top key="footer-top">
<VisuallyHidden>
<Heading>Colofon</Heading>
</VisuallyHidden>
<Grid gapVertical="large" paddingVertical="medium">
<Grid.Cell span={3}>
<Heading className="ams-mb--xs" level={2} size="level-4" inverseColor>
Contact
</Heading>
<Paragraph className="ams-mb--xs" size="small" inverseColor>
Heeft u een vraag en kunt u het antwoord niet vinden op deze site? Neem dan contact met ons op.
</Paragraph>
<LinkList>
<LinkList.Link href="mailto:[email protected]" icon={EmailIcon} onBackground="dark" size="small">
E-mail
</LinkList.Link>
<LinkList.Link href="tel:+31202510333" icon={PhoneIcon} onBackground="dark" size="small">
020 251 0333
</LinkList.Link>
</LinkList>
</Grid.Cell>
<Grid.Cell span={3} start={{ narrow: 1, medium: 5, wide: 5 }}>
<Heading className="ams-mb--xs" level={2} size="level-4" inverseColor>
Panels en enquêtes
</Heading>
<Paragraph className="ams-mb--xs" inverseColor size="small">
Bent u uitgenodigd om mee te doen aan onderzoek of heeft u vragen over het panel of stadspaspanel?
</Paragraph>
<LinkList>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Meedoen aan onderzoek
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Panel Amsterdam
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Stadspaspanel Amsterdam
</LinkList.Link>
</LinkList>
</Grid.Cell>
<Grid.Cell span={3} start={{ narrow: 1, medium: 1, wide: 9 }}>
<div style={{ display: 'grid', gap: '2.5rem' }}>
<Heading level={2} size="level-4" inverseColor>
Onderzoek en Statistiek
</Heading>
<LinkList>
<LinkList.Link href="#" onBackground="dark" size="small">
Over Onderzoek en Statistiek
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" size="small">
Veelgestelde vragen
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Nieuwsbrief
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" size="small">
Vacatures
</LinkList.Link>
</LinkList>
</div>
<Heading className="ams-mb--xs" level={2} size="level-4" inverseColor>
Onderzoek en Statistiek
</Heading>
<LinkList>
<LinkList.Link href="#" onBackground="dark" size="small">
Over Onderzoek en Statistiek
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" size="small">
Veelgestelde vragen
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Nieuwsbrief
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" size="small">
Vacatures
</LinkList.Link>
</LinkList>
</Grid.Cell>
</Grid>
</Footer.Top>,
Expand All @@ -100,10 +191,7 @@ export const Default: Story = {
</VisuallyHidden>
<Grid paddingVertical="small">
<Grid.Cell span="all">
<PageMenu>
<PageMenu.Link href="#">Privacy</PageMenu.Link>
<PageMenu.Link href="#">Toegankelijkheid</PageMenu.Link>
</PageMenu>
<PageMenu>{PageMenuStory.args?.children}</PageMenu>
</Grid.Cell>
</Grid>
</Footer.Bottom>,
Expand Down
1 change: 1 addition & 0 deletions storybook/src/components/Image/Image.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import README from "../../../../packages/css/src/components/image/README.md?raw"

Use the srcSet prop, which controls the corresponding HTML attribute (see [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#srcset)), to let the browser select the optimal source file for the image.
A mobile device can often download a smaller file, saving the user’s bandwidth and time.
Don’t forget to still include the required `src` attribute.

<Canvas of={ImageStories.MultipleSources} />

Expand Down
1 change: 1 addition & 0 deletions storybook/src/components/Image/Image.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const Default: Story = {
export const MultipleSources: Story = {
args: {
alt: '',
src: 'https://picsum.photos/1280/720',
srcSet: 'https://picsum.photos/640/360 640w, https://picsum.photos/1280/720 1280w',
sizes: '(max-width: 36rem) 640px, 50vw',
},
Expand Down
Loading
Loading