-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Flexbox.re
84 lines (76 loc) · 2.53 KB
/
Flexbox.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
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
open Revery;
open Revery.UI;
let parentWidth = 400;
let childWidth = 300;
let parentStyles =
(~alignment as a=`Auto, ~direction as d=`Row, ~justify as j=`Center, ()) =>
Style.[
backgroundColor(Colors.green),
position(`Relative),
width(parentWidth),
height(100),
alignItems(a),
justifyContent(j),
flexDirection(d),
];
let childStyles =
Style.[
backgroundColor(Colors.blue),
position(`Relative),
width(childWidth),
height(40),
];
let defaultTextStyles =
Style.[color(Colors.white), backgroundColor(Colors.blue)];
let parentColumnStyle = parentStyles(~direction=`Column);
let headerStyle =
Style.[marginTop(25), marginBottom(25), color(Colors.white)];
let horizontalStyles =
<View>
<Text style=headerStyle fontSize=30. text="Flex Direction Row" />
<View style={parentColumnStyle(~alignment=`Auto, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Default Flex" />
</View>
</View>
<View style={parentColumnStyle(~alignment=`Center, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Center" />
</View>
</View>
<View style={parentColumnStyle(~alignment=`FlexStart, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Flex Start" />
</View>
</View>
<View style={parentColumnStyle(~alignment=`FlexEnd, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Flex End" />
</View>
</View>
<View style={parentColumnStyle(~alignment=`Stretch, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Flex Stretch" />
</View>
</View>
</View>;
let verticalStyles =
<View>
<Text style=headerStyle fontSize=30. text="Flex Direction Column" />
<View style={parentStyles(~direction=`Column, ~justify=`FlexStart, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Align Flex Start" />
</View>
</View>
<View style={parentStyles(~direction=`Column, ~justify=`Center, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Align Flex Center" />
</View>
</View>
<View style={parentStyles(~direction=`Column, ~justify=`FlexEnd, ())}>
<View style=childStyles>
<Text style=defaultTextStyles fontSize=20. text="Align Flex End" />
</View>
</View>
</View>;
let render = () => <View> horizontalStyles verticalStyles </View>;