-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.re
49 lines (43 loc) · 1.26 KB
/
Main.re
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
open Revery;
open Revery.UI;
open Revery.UI.Components;
let allRoutes = [`Query, `QueryWithVariables, `Mutation, `MutationTwo];
let routeToString =
fun
| `Query => "Query"
| `QueryWithVariables => "Query with variables"
| `Mutation => "Mutation"
| `MutationTwo => "MutationTwo";
let%component make = (~app: Revery.App.t, ()) => {
let%hook (route, setRoute) = Hooks.state(`Query);
let currentRoute =
switch (route) {
| `Query => <Query />
| `QueryWithVariables => <QueryWithVariables />
| `Mutation => <Mutation />
| `MutationTwo => <Mutation />
};
let handleClose = _ =>
Sys.getenv_opt("CI") |> Option.is_some
? Revery.App.quit(~code=0, app) : ();
<Center>
<Ticker onTick=handleClose tickRate={Time.seconds(5)} />
<View style=Style.[marginTop(32)]>
<Row>
{allRoutes
|> List.map(r => {
<View style=Style.[marginRight(16)]>
<Clickable onClick={_ => setRoute(_ => r)}>
<Theme.Typography.Link
active={route == r}
text={r |> routeToString}
/>
</Clickable>
</View>
})
|> React.listToElement}
</Row>
currentRoute
</View>
</Center>;
};