forked from devbookhq/splitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
106 lines (99 loc) · 3.35 KB
/
App.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { useState } from 'react';
import './styles.css';
import './App.css';
import SingleHorizontal from './SingleHorizontal';
import SingleVertical from './SingleVertical';
import HorizontalSplit from './HorizontalSplit';
import VerticalSplit from './VerticalSplit';
import NestedSplit from './NestedSplit';
import StyledGutter from './StyledGutter';
import MinSize from './MinSize';
import InitialSizes from './InitialSizes';
import ScrollableChildren from './ScrollableChildren';
import OnDidResizeSplit from './OnDidResize';
import DynamicParentSize from './DynamicParentSize';
import DynamicChildren from './DynamicChildren';
enum Page {
SingleHorizontal,
SingleVertical,
Horizontal,
Vertical,
Nested,
StyledGutter,
MinSize,
InitialSizes,
ScrollableChildren,
OnDidResize,
DynamicParent,
DynamicChildren,
}
function App() {
const [page, setPage] = useState(Page.SingleHorizontal);
return (
<div className="app">
<div className="split-selection">
<button onClick={() => setPage(Page.SingleHorizontal)}>Single horizontal</button>
<button onClick={() => setPage(Page.SingleVertical)}>Single Vertical</button>
<button onClick={() => setPage(Page.Horizontal)}>Horizontal</button>
<button onClick={() => setPage(Page.Vertical)}>Vertical</button>
<button onClick={() => setPage(Page.Nested)}>Nested</button>
<button onClick={() => setPage(Page.StyledGutter)}>Styled gutter</button>
<button onClick={() => setPage(Page.MinSize)}>Minimal tile size</button>
<button onClick={() => setPage(Page.InitialSizes)}>Initial tile sizes</button>
<button onClick={() => setPage(Page.ScrollableChildren)}>Scrollable tiles</button>
<button onClick={() => setPage(Page.OnDidResize)}>On size change</button>
<button onClick={() => setPage(Page.DynamicParent)}>Dynamic parent size</button>
<button onClick={() => setPage(Page.DynamicChildren)}>Dynamic children</button>
</div>
<div className="splits">
{page === Page.SingleHorizontal &&
<SingleHorizontal/>
}
{page === Page.SingleVertical &&
<SingleVertical/>
}
{page === Page.Horizontal &&
<HorizontalSplit/>
}
{page === Page.Vertical &&
<VerticalSplit/>
}
{page === Page.Nested &&
<NestedSplit/>
}
{page === Page.StyledGutter &&
<StyledGutter/>
}
{page === Page.MinSize &&
<MinSize/>
}
{page === Page.InitialSizes &&
<InitialSizes/>
}
{page === Page.ScrollableChildren &&
<>
<p>Just make sure the parent element ('.splits' in App.css) has set max-height/max-width in px</p>
<ScrollableChildren/>
</>
}
{page === Page.OnDidResize &&
<OnDidResizeSplit />
}
{page === Page.DynamicParent &&
<>
<p>Parent's initial width is 0% and will be set to 100% in 5s. Splitter will correctly re-render. Works also with the height.</p>
<DynamicParentSize />
</>
}
{
page === Page.DynamicChildren &&
<>
<p>Additional child nodes will be inserted after 5s.</p>
<DynamicChildren />
</>
}
</div>
</div>
);
}
export default App;