generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate menulijst component from mdx to tsx
- Loading branch information
Showing
6 changed files
with
87 additions
and
96 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
packages/storybook/stories/components/Menulijst.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* @license CC0-1.0 */ | ||
|
||
import { Meta, StoryObj } from '@storybook/react'; | ||
import readme from '@utrecht/components/menulijst/README.md?raw'; | ||
import tokens from '@utrecht/design-tokens/dist/index.json'; | ||
import React from 'react'; | ||
import { Menulijst } from './Menulijst'; | ||
import { designTokenStory } from './util'; | ||
|
||
const meta = { | ||
title: 'CSS Component/Menulijst', | ||
id: 'css-menulijst', | ||
component: Menulijst, | ||
argTypes: { | ||
items: { | ||
description: 'Items of the menu', | ||
type: { | ||
name: 'array', | ||
required: true, | ||
}, | ||
}, | ||
}, | ||
decorators: [ | ||
(story) => <div style={{ 'max-inline-size': 'var(--utrecht-sidebar-max-inline-size, 20rem)' }}>{story()}</div>, | ||
], | ||
args: { | ||
items: [], | ||
}, | ||
parameters: { | ||
tokensPrefix: 'utrecht-menulijst', | ||
status: { | ||
type: 'WORK IN PROGRESS', | ||
}, | ||
tokens, | ||
tokensDefinition: {}, | ||
docs: { | ||
description: { | ||
component: readme, | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof Menulijst>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
items: [ | ||
{ href: 'https://example.com/1', children: 'Menu item label #1', active: true }, | ||
{ href: 'https://example.com/2', children: 'Menu item label #2' }, | ||
{ href: 'https://example.com/3', children: 'Menu item label #3' }, | ||
], | ||
}, | ||
parameters: { | ||
docs: { | ||
description: { | ||
story: 'Styling via `utrecht-menulijst` class name.', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const DesignTokens = designTokenStory(meta); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2020-2022 Gemeente Utrecht | ||
* Copyright (c) 2020-2022 Frameless B.V. | ||
*/ | ||
|
||
import clsx from 'clsx'; | ||
import React, { PropsWithChildren, ReactNode } from 'react'; | ||
|
||
export const Menulijst = ({ | ||
items = [], | ||
}: PropsWithChildren<{ items: { active?: boolean; href: string; children: ReactNode }[] }>) => ( | ||
<ul className="utrecht-menulijst"> | ||
{items.map(({ active, href, children }) => ( | ||
<li className={clsx('utrecht-menulijst__item', active && 'utrecht-menulijst__item--active')}> | ||
<a className="utrecht-menulijst__link" href={href}> | ||
{children} | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
); |