forked from revery-ui/revery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultButton.re
46 lines (39 loc) · 1.18 KB
/
DefaultButton.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
open Revery;
open Revery.UI;
open Revery.UI.Components;
module DefaultButtonWithCounter = {
let component = React.component("DefaultButtonWithCounter");
let createElement = (~children as _, ()) =>
component(hooks => {
let (count, setCount, hooks) = Hooks.state(0, hooks);
let increment = () => setCount(count + 1);
let containerStyle =
Style.[justifyContent(`Center), alignItems(`Center)];
let countContainer =
Style.[
width(300),
height(300),
alignItems(`Center),
justifyContent(`Center),
];
let countStyle =
Style.[
fontSize(50),
margin(24),
color(Colors.black),
fontFamily("Roboto-Regular.ttf"),
];
let countStr = string_of_int(count);
(
hooks,
<View style=containerStyle>
<View style=countContainer>
<Text style=countStyle text=countStr />
</View>
<Button title="click me!" onClick=increment />
<Button disabled=true title="(disabled)" onClick=increment />
</View>,
);
});
};
let render = () => <View> <DefaultButtonWithCounter /> </View>;