-
Notifications
You must be signed in to change notification settings - Fork 25
/
Flex.purs
84 lines (58 loc) · 2.88 KB
/
Flex.purs
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
module ReactNative.Styles.Flex where
import ReactNative.PropTypes (class AutoEnum, class CenterEnum)
import ReactNative.Styles (StyleProp, unsafeStyleProp)
class FlexStartEnd a where
flexStart :: a
flexEnd :: a
newtype FlexAlignment = FlexAlignment String
instance alignmentStartEnd :: FlexStartEnd FlexAlignment where
flexStart = FlexAlignment "flex-start"
flexEnd = FlexAlignment "flex-end"
instance flexAlignmentAuto :: AutoEnum FlexAlignment where
auto = FlexAlignment "auto"
instance flexAlignmentCenter :: CenterEnum FlexAlignment where
center = FlexAlignment "center"
stretch :: FlexAlignment
stretch = FlexAlignment "stretch"
newtype FlexDirection = FlexDirection String
row :: FlexDirection
row = FlexDirection "row"
rowReverse :: FlexDirection
rowReverse = FlexDirection "row-reverse"
column :: FlexDirection
column = FlexDirection "column"
columnReverse :: FlexDirection
columnReverse = FlexDirection "column-reverse"
newtype FlexWrap = FlexWrap String
wrap :: FlexWrap
wrap = FlexWrap "wrap"
nowrap :: FlexWrap
nowrap = FlexWrap "nowrap"
newtype JustifyContent = JustifyContent String
instance justifyContentFlexSE :: FlexStartEnd JustifyContent where
flexStart = JustifyContent "flex-start"
flexEnd = JustifyContent "flex-end"
instance jcCenter :: CenterEnum JustifyContent where
center = JustifyContent "center"
spaceBetween :: JustifyContent
spaceBetween = JustifyContent "space-between"
spaceAround :: JustifyContent
spaceAround = JustifyContent "space-around"
alignItems :: FlexAlignment -> StyleProp
alignItems = unsafeStyleProp "alignItems"
alignSelf :: FlexAlignment -> StyleProp
alignSelf = unsafeStyleProp "alignSelf"
-- flexDirection controls which directions children of a container go. row goes left to right, column goes top to bottom, and you may be able to guess what the other two do. It works like flex-direction in CSS, except the default is column. See https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction for more details.
flexDirection :: FlexDirection -> StyleProp
flexDirection = unsafeStyleProp "flexDirection"
flexGrow :: Int -> StyleProp
flexGrow = unsafeStyleProp "flexGrow"
--
flexShrink :: Int -> StyleProp
flexShrink = unsafeStyleProp "flexShrink"
-- flexWrap controls whether children can wrap around after they hit the end of a flex container. It works like flex-wrap in CSS (default: nowrap). See https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap for more details.
flexWrap :: FlexWrap -> StyleProp
flexWrap = unsafeStyleProp "flexWrap"
-- justifyContent aligns children in the main direction. For example, if children are flowing vertically, justifyContent controls how they align vertically. It works like justify-content in CSS (default: flex-start). See https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content for more details.
justifyContent :: JustifyContent -> StyleProp
justifyContent = unsafeStyleProp "justifyContent"