|
1 |
| -import * as React from 'react' |
| 1 | +import * as React from 'react'; |
2 | 2 | import {
|
3 | 3 | Orientation,
|
4 | 4 | GridviewComponent,
|
5 | 5 | LayoutPriority,
|
6 | 6 | GridviewReadyEvent,
|
7 | 7 | ComponentGridview,
|
8 | 8 | IGridviewPanelProps,
|
9 |
| -} from 'splitview' |
10 |
| -import { TestGrid } from './reactgrid' |
| 9 | +} from 'splitview'; |
| 10 | +import { TestGrid } from './reactgrid'; |
11 | 11 |
|
12 | 12 | const rootcomponents: {
|
13 |
| - [index: string]: React.FunctionComponent<IGridviewPanelProps> |
| 13 | + [index: string]: React.FunctionComponent<IGridviewPanelProps>; |
14 | 14 | } = {
|
15 | 15 | sidebar: (props: IGridviewPanelProps) => {
|
16 | 16 | return (
|
17 | 17 | <div style={{ backgroundColor: 'rgb(37,37,38)', height: '100%' }}>
|
18 | 18 | sidebar
|
19 | 19 | </div>
|
20 |
| - ) |
| 20 | + ); |
21 | 21 | },
|
22 | 22 | editor: TestGrid,
|
23 | 23 | panel: () => {
|
24 | 24 | return (
|
25 | 25 | <div style={{ backgroundColor: 'rgb(30,30,30)', height: '100%' }}>
|
26 | 26 | panel
|
27 | 27 | </div>
|
28 |
| - ) |
| 28 | + ); |
29 | 29 | },
|
30 |
| -} |
| 30 | +}; |
31 | 31 |
|
32 | 32 | export const Application = () => {
|
33 |
| - const api = React.useRef<ComponentGridview>() |
| 33 | + const api = React.useRef<ComponentGridview>(); |
34 | 34 |
|
35 | 35 | const onReady = (event: GridviewReadyEvent) => {
|
36 | 36 | // event.api.deserialize(rootLayout);
|
37 | 37 | event.api.addComponent({
|
38 | 38 | id: '1',
|
39 | 39 | component: 'sidebar',
|
40 | 40 | snap: true,
|
41 |
| - }) |
| 41 | + }); |
42 | 42 | event.api.addComponent({
|
43 | 43 | id: '2',
|
44 | 44 | component: 'editor',
|
45 | 45 | snap: true,
|
46 | 46 | position: { reference: '1', direction: 'right' },
|
47 | 47 | priority: LayoutPriority.High,
|
48 |
| - }) |
| 48 | + }); |
49 | 49 |
|
50 |
| - api.current = event.api as ComponentGridview |
51 |
| - } |
| 50 | + api.current = event.api as ComponentGridview; |
| 51 | + }; |
52 | 52 |
|
53 | 53 | React.useEffect(() => {
|
54 | 54 | const callback = (ev: UIEvent) => {
|
55 |
| - const height = window.innerHeight - 20 |
56 |
| - const width = window.innerWidth |
| 55 | + const height = window.innerHeight - 20; |
| 56 | + const width = window.innerWidth; |
57 | 57 |
|
58 |
| - api.current?.layout(width, height) |
59 |
| - } |
60 |
| - window.addEventListener('resize', callback) |
61 |
| - callback(undefined) |
| 58 | + api.current?.layout(width, height); |
| 59 | + }; |
| 60 | + window.addEventListener('resize', callback); |
| 61 | + callback(undefined); |
62 | 62 |
|
63 | 63 | api.current.addComponent({
|
64 | 64 | id: '3',
|
65 | 65 | component: 'panel',
|
66 | 66 | position: { reference: '2', direction: 'below' },
|
67 | 67 | size: 200,
|
68 | 68 | snap: true,
|
69 |
| - }) |
| 69 | + }); |
70 | 70 |
|
71 | 71 | return () => {
|
72 |
| - window.removeEventListener('resize', callback) |
73 |
| - } |
74 |
| - }, []) |
| 72 | + window.removeEventListener('resize', callback); |
| 73 | + }; |
| 74 | + }, []); |
75 | 75 |
|
76 | 76 | return (
|
77 | 77 | <GridviewComponent
|
78 | 78 | components={rootcomponents}
|
79 | 79 | onReady={onReady}
|
80 | 80 | orientation={Orientation.HORIZONTAL}
|
81 | 81 | />
|
82 |
| - ) |
83 |
| -} |
| 82 | + ); |
| 83 | +}; |
0 commit comments