Skip to content

Commit e32a0ba

Browse files
authored
DS Storybook - Add DataView story (#5816)
* add dataview story * fix error
1 parent 21416ec commit e32a0ba

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react';
2+
import type { Meta, StoryObj } from '@storybook/react';
3+
import { Data, DataView, DataTable, Toolbar } from 'grommet';
4+
5+
const meta = {
6+
title: 'Components/DataView',
7+
component: DataView,
8+
argTypes: {
9+
// DataView has no props to control
10+
},
11+
} satisfies Meta<typeof DataView>;
12+
13+
export default meta;
14+
type Story = StoryObj<typeof meta>;
15+
16+
export const Default = {
17+
name: 'DataView',
18+
render: args => (
19+
<Data
20+
data={[
21+
{ id: 1, name: 'Person 1', age: 12 },
22+
{ id: 2, name: 'Person 2', age: 91 },
23+
]}
24+
views={[
25+
{ name: 'oldest', sort: { property: 'age', direction: 'desc' } },
26+
{ name: 'youngest', sort: { property: 'age', direction: 'asc' } },
27+
]}
28+
>
29+
<Toolbar>
30+
<DataView {...args} />
31+
</Toolbar>
32+
<DataTable
33+
columns={[
34+
{
35+
property: 'name',
36+
header: 'Name',
37+
},
38+
{
39+
property: 'age',
40+
header: 'Age',
41+
},
42+
]}
43+
/>
44+
</Data>
45+
),
46+
args: {},
47+
} satisfies Story;

0 commit comments

Comments
 (0)