Skip to content

Commit

Permalink
docs: migrate Select CSS component stories to tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Jun 22, 2023
1 parent 0d0431d commit ef5ecf7
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 213 deletions.
30 changes: 0 additions & 30 deletions components/select/css/stories/default.stories.mdx

This file was deleted.

11 changes: 0 additions & 11 deletions components/select/css/stories/readme.stories.mdx

This file was deleted.

78 changes: 0 additions & 78 deletions components/select/css/stories/states.stories.mdx

This file was deleted.

16 changes: 0 additions & 16 deletions components/select/css/stories/tokens.stories.mdx

This file was deleted.

78 changes: 0 additions & 78 deletions components/select/css/story-template.jsx

This file was deleted.

125 changes: 125 additions & 0 deletions packages/storybook/stories/components/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/* @license CC0-1.0 */

import type { Meta, StoryObj } from '@storybook/react';
import { Select, SelectOption, SelectProps } from '@utrecht/component-library-react/src/Select';
import readme from '@utrecht/components/select/README.md?raw';
import tokensDefinition from '@utrecht/components/select/tokens.json';
import tokens from '@utrecht/design-tokens/dist/index.json';
import clsx from 'clsx';
import React, { ReactNode } from 'react';
import { designTokenStory } from './util';
import '@utrecht/components/select/css/index.scss';

const meta = {
title: 'CSS Component/Select',
id: 'css-select',
component: Select,
argTypes: {
disabled: {
description: 'Disabled',
control: 'boolean',
},
focus: {
description: 'Focus',
control: 'boolean',
},
invalid: {
description: 'Invalid',
control: 'boolean',
},
options: {
description: 'Options',
type: {
name: 'array',
required: true,
},
},
required: {
description: 'Required',
control: 'boolean',
},
},
args: {
disabled: false,
focus: false,
invalid: false,
options: [
{ value: '1', label: 'Option #1' },
{ value: '2', label: 'Option #2', selected: true },
{ value: '3', label: 'Option #3' },
],
required: false,
},
render: ({
focus,
focusVisible,
options,
...props
}: SelectProps & { focus?: boolean; focusVisible?: boolean; options: { value?: string; label: ReactNode }[] }) => {
return (
<Select
className={clsx({
'utrecht-select--focus': focus,
'utrecht-select--focus-visible': focusVisible,
})}
{...props}
>
{options.map(({ value, label }) => (
<SelectOption value={value}>{label}</SelectOption>
))}
</Select>
);
},
tags: ['autodocs'],
parameters: {
status: {
type: 'ALPHA',
},
tokensPrefix: 'utrecht-select',
tokens,
tokensDefinition,
docs: {
description: {
component: readme,
},
},
},
} satisfies Meta<typeof Select>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {};

export const Disabled: Story = {
args: {
disabled: true,
},
};

export const Invalid: Story = {
args: {
invalid: true,
},
};

export const Required: Story = {
args: {
required: true,
},
};

export const Focus: Story = {
args: {
className: 'utrecht-select--focus',
},
};

export const FocusVisible: Story = {
args: {
className: 'utrecht-select--focus utrecht-select--focus-visible',
},
};

export const DesignTokens = designTokenStory(meta);

0 comments on commit ef5ecf7

Please sign in to comment.