Tailwind classes in OCaml
1type direction = [
2 | `Row
3 | `Row_reverse
4 | `Col
5 | `Col_reverse
6]
7
8type wrap = [
9 | `Wrap
10 | `Wrap_reverse
11 | `Nowrap
12]
13
14type justify = [
15 | `Normal
16 | `Start
17 | `End
18 | `Center
19 | `Between
20 | `Around
21 | `Evenly
22 | `Stretch
23]
24
25type align_items = [
26 | `Start
27 | `End
28 | `Center
29 | `Baseline
30 | `Stretch
31]
32
33type align_content = [
34 | `Normal
35 | `Start
36 | `End
37 | `Center
38 | `Between
39 | `Around
40 | `Evenly
41 | `Stretch
42 | `Baseline
43]
44
45type align_self = [
46 | `Auto
47 | `Start
48 | `End
49 | `Center
50 | `Stretch
51 | `Baseline
52]
53
54type t = [
55 | `Direction of direction
56 | `Wrap_setting of wrap
57 | `Justify of justify
58 | `Align_items of align_items
59 | `Align_content of align_content
60 | `Align_self of align_self
61 | `Grow of int option
62 | `Shrink of int option
63 | `Basis of Size.t
64 | `Flex of [`Initial | `One | `Auto | `None]
65]
66
67let to_class = function
68 | `Direction `Row -> Css.make "flex-row"
69 | `Direction `Row_reverse -> Css.make "flex-row-reverse"
70 | `Direction `Col -> Css.make "flex-col"
71 | `Direction `Col_reverse -> Css.make "flex-col-reverse"
72 | `Wrap_setting `Wrap -> Css.make "flex-wrap"
73 | `Wrap_setting `Wrap_reverse -> Css.make "flex-wrap-reverse"
74 | `Wrap_setting `Nowrap -> Css.make "flex-nowrap"
75 | `Justify `Normal -> Css.make "justify-normal"
76 | `Justify `Start -> Css.make "justify-start"
77 | `Justify `End -> Css.make "justify-end"
78 | `Justify `Center -> Css.make "justify-center"
79 | `Justify `Between -> Css.make "justify-between"
80 | `Justify `Around -> Css.make "justify-around"
81 | `Justify `Evenly -> Css.make "justify-evenly"
82 | `Justify `Stretch -> Css.make "justify-stretch"
83 | `Align_items `Start -> Css.make "items-start"
84 | `Align_items `End -> Css.make "items-end"
85 | `Align_items `Center -> Css.make "items-center"
86 | `Align_items `Baseline -> Css.make "items-baseline"
87 | `Align_items `Stretch -> Css.make "items-stretch"
88 | `Align_content `Normal -> Css.make "content-normal"
89 | `Align_content `Start -> Css.make "content-start"
90 | `Align_content `End -> Css.make "content-end"
91 | `Align_content `Center -> Css.make "content-center"
92 | `Align_content `Between -> Css.make "content-between"
93 | `Align_content `Around -> Css.make "content-around"
94 | `Align_content `Evenly -> Css.make "content-evenly"
95 | `Align_content `Stretch -> Css.make "content-stretch"
96 | `Align_content `Baseline -> Css.make "content-baseline"
97 | `Align_self `Auto -> Css.make "self-auto"
98 | `Align_self `Start -> Css.make "self-start"
99 | `Align_self `End -> Css.make "self-end"
100 | `Align_self `Center -> Css.make "self-center"
101 | `Align_self `Stretch -> Css.make "self-stretch"
102 | `Align_self `Baseline -> Css.make "self-baseline"
103 | `Grow None -> Css.make "grow-0"
104 | `Grow (Some 0) -> Css.make "grow-0"
105 | `Grow (Some n) -> Css.make (Printf.sprintf "grow-%d" n)
106 | `Shrink None -> Css.make "shrink-0"
107 | `Shrink (Some 0) -> Css.make "shrink-0"
108 | `Shrink (Some n) -> Css.make (Printf.sprintf "shrink-%d" n)
109 | `Basis size -> Css.make (Printf.sprintf "basis-%s" (Size.to_string size))
110 | `Flex `Initial -> Css.make "flex-initial"
111 | `Flex `One -> Css.make "flex-1"
112 | `Flex `Auto -> Css.make "flex-auto"
113 | `Flex `None -> Css.make "flex-none"
114
115let direction d = `Direction d
116let wrap w = `Wrap_setting w
117let justify j = `Justify j
118let align_items a = `Align_items a
119let align_content a = `Align_content a
120let align_self a = `Align_self a
121let grow g = `Grow g
122let shrink s = `Shrink s
123let basis b = `Basis b
124let flex f = `Flex f
125
126let combine ts = Css.concat (List.map to_class ts)