forked from mui/mui-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid-resize.stories.tsx
59 lines (56 loc) · 1.68 KB
/
grid-resize.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import * as React from 'react';
import { ElementSize, XGrid } from '@material-ui/x-grid';
import { withKnobs } from '@storybook/addon-knobs';
import '../style/grid-stories.css';
import { useData } from '../hooks/useData';
export default {
title: 'X-Grid Tests/Resize',
component: XGrid,
decorators: [withKnobs],
parameters: {
options: { selectedPanel: 'storybook/storysource/panel' },
docs: {
page: null,
},
},
};
export const ResizeSmallDataset = () => {
const [size, setSize] = React.useState<ElementSize>({ width: 800, height: 600 });
const data = useData(5, 4);
return (
<React.Fragment>
<div>
<button
type="button"
onClick={() => setSize((p: ElementSize) => ({ width: p.height, height: p.width }))}
style={{ padding: 5, textTransform: 'capitalize', margin: 10 }}
>
Switch sizes
</button>
</div>
<div style={{ width: size.width, height: size.height }}>
<XGrid rows={data.rows} columns={data.columns} />
</div>
</React.Fragment>
);
};
export const ResizeLargeDataset = () => {
const [size, setSize] = React.useState<ElementSize>({ width: 800, height: 600 });
const data = useData(200, 200);
return (
<React.Fragment>
<div>
<button
type="button"
onClick={() => setSize((p: ElementSize) => ({ width: p.height, height: p.width }))}
style={{ padding: 5, textTransform: 'capitalize', margin: 10 }}
>
Switch sizes
</button>
</div>
<div style={{ width: size.width, height: size.height }}>
<XGrid rows={data.rows} columns={data.columns} />
</div>
</React.Fragment>
);
};