storybook/docs/snippets/react/table-story-fully-customize-controls.ts-4-9.mdx
Kasper Peulen 7452663a26 Prettyyy
2023-01-17 08:10:49 +01:00

46 lines
983 B
Plaintext

```tsx
// Table.stories.ts|tsx
import type { Meta, StoryObj } from '@storybook/react';
import { Table } from './Table';
import { TD } from './TableDataCell';
import { TR } from './TableRow';
const meta = {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Custom Table',
component: Table,
} satisfies Meta<typeof Table>;
export default meta;
type Story = StoryObj<typeof meta>;
export const TableStory: Story = {
render: ({ data, ...args }) => (
<Table {...args}>
{data.map((row) => (
<TR>
{row.map((item) => (
<TD>{item}</TD>
))}
</TR>
))}
</Table>
),
args: {
//👇 This arg is for the story component
data: [
[1, 2, 3],
[4, 5, 6],
],
//👇 The remaining args get passed to the `Table` component
size: 'large',
},
};
```