Skip to content

Commit

Permalink
refactor: migrate menulijst component from mdx to tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Sep 4, 2023
1 parent 83b7d53 commit 34672c2
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 96 deletions.
29 changes: 0 additions & 29 deletions components/menulijst/css/stories/default.stories.mdx

This file was deleted.

8 changes: 0 additions & 8 deletions components/menulijst/css/stories/readme.stories.mdx

This file was deleted.

11 changes: 0 additions & 11 deletions components/menulijst/css/stories/tokens.stories.mdx

This file was deleted.

48 changes: 0 additions & 48 deletions components/menulijst/css/story-template.jsx

This file was deleted.

65 changes: 65 additions & 0 deletions packages/storybook/stories/components/Menulijst.stories.tsx
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);
22 changes: 22 additions & 0 deletions packages/storybook/stories/components/Menulijst.tsx
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>
);

0 comments on commit 34672c2

Please sign in to comment.