-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathApp.res
73 lines (66 loc) · 2.25 KB
/
App.res
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
type state = {mobileNavShown: bool}
type action =
| ShowMobileNav
| HideMobileNav
let reducer = (_state, action) =>
switch action {
| ShowMobileNav => {mobileNavShown: true}
| HideMobileNav => {mobileNavShown: false}
}
@react.component
let make = () => {
let url = RescriptReactRouter.useUrl()
let route = React.useMemo1(() => url->Route.fromUrl, [url])
let (state, dispatch) = reducer->React.useReducer({mobileNavShown: false})
React.useEffect1(() => {
HideMobileNav->dispatch
None
}, [route])
let showMobileNav = React.useCallback0(() => ShowMobileNav->dispatch)
let hideMobileNav = React.useCallback0(() => HideMobileNav->dispatch)
<Container>
<Nav route mobileNavShown=state.mobileNavShown hideMobileNav />
<Main>
{switch route {
| VerticalList =>
<Example.Dynamic
key=url.hash title="Vertical list" layout=Vertical initialAmount=7 showMobileNav>
{n => <SimpleList key={n->Int.toString} axis=Y n />}
</Example.Dynamic>
| HorizontalList =>
<Example.Dynamic
key=url.hash title="Horizontal list" layout=Horizontal initialAmount=7 showMobileNav>
{n => <SimpleList key={n->Int.toString} axis=X n />}
</Example.Dynamic>
| VerticalScrollableContainer =>
<Example.Dynamic
key=url.hash
title="Vertical scrollable container"
layout=Vertical
scrollable=true
initialAmount=50
showMobileNav>
{n => <SimpleList key={n->Int.toString} axis=Y n />}
</Example.Dynamic>
| HorizontalScrollableContainer =>
<Example.Dynamic
key=url.hash
title="Horizontal scrollable container"
layout=Horizontal
scrollable=true
initialAmount=50
showMobileNav>
{n => <SimpleList key={n->Int.toString} axis=X n />}
</Example.Dynamic>
| CardBoard =>
<Example.Static key=url.hash title="Card board" layout=CardBoard showMobileNav>
<CardBoard />
</Example.Static>
| NestedVerticalLists =>
<Example.Static key=url.hash title="Nested vertical list" layout=Vertical showMobileNav>
<NestedVerticalLists />
</Example.Static>
}}
</Main>
</Container>
}