forked from revery-ui/revery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DropdownExample.re
47 lines (40 loc) · 1.13 KB
/
DropdownExample.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
open Revery.UI;
open Revery.UI.Components;
let containerStyle =
Style.[
position(`Absolute),
top(0),
bottom(0),
left(0),
right(0),
alignItems(`Center),
justifyContent(`Center),
];
let textStyle =
Style.[fontFamily("Roboto-Regular.ttf"), fontSize(20), marginBottom(20)];
module DropdownExample = {
let component = React.component("DropDownExample");
let items: Dropdown.items(int) = [
{value: 1, label: "First option"},
{value: 2, label: "Second option"},
{value: 3, label: "Third option"},
{value: 4, label: "Fourth option"},
{value: 5, label: "A really, really, really long option"},
];
let createElement = (~children as _, ()) =>
component(hooks => {
let (selectedItem, setSelectedItem, hooks) =
Hooks.state(List.nth(items, 0), hooks);
(
hooks,
<View style=containerStyle>
<Text
style=textStyle
text={"Selected Item: " ++ selectedItem.label}
/>
<Dropdown items onItemSelected={item => setSelectedItem(item)} />
</View>,
);
});
};
let render = () => <DropdownExample />;