Tailwind classes in OCaml
1type cols =
2 | None
3 | Subgrid
4 | Cols of int
5
6type rows =
7 | None
8 | Subgrid
9 | Rows of int
10
11type span =
12 | Auto
13 | Full
14 | Span of int
15 | Start of int
16 | End of int
17
18type flow =
19 | Row
20 | Col
21 | Dense
22 | Row_dense
23 | Col_dense
24
25type t =
26 | Template_cols of cols
27 | Template_rows of rows
28 | Col of span
29 | Row of span
30 | Auto_flow of flow
31 | Auto_cols of [`Auto | `Min | `Max | `Fr of int]
32 | Auto_rows of [`Auto | `Min | `Max | `Fr of int]
33
34let to_class = function
35 | Template_cols None -> Css.make "grid-cols-none"
36 | Template_cols Subgrid -> Css.make "grid-cols-subgrid"
37 | Template_cols (Cols n) -> Css.make (Printf.sprintf "grid-cols-%d" n)
38 | Template_rows None -> Css.make "grid-rows-none"
39 | Template_rows Subgrid -> Css.make "grid-rows-subgrid"
40 | Template_rows (Rows n) -> Css.make (Printf.sprintf "grid-rows-%d" n)
41 | Col Auto -> Css.make "col-auto"
42 | Col Full -> Css.make "col-full"
43 | Col (Span n) -> Css.make (Printf.sprintf "col-span-%d" n)
44 | Col (Start n) -> Css.make (Printf.sprintf "col-start-%d" n)
45 | Col (End n) -> Css.make (Printf.sprintf "col-end-%d" n)
46 | Row Auto -> Css.make "row-auto"
47 | Row Full -> Css.make "row-full"
48 | Row (Span n) -> Css.make (Printf.sprintf "row-span-%d" n)
49 | Row (Start n) -> Css.make (Printf.sprintf "row-start-%d" n)
50 | Row (End n) -> Css.make (Printf.sprintf "row-end-%d" n)
51 | Auto_flow Row -> Css.make "grid-flow-row"
52 | Auto_flow Col -> Css.make "grid-flow-col"
53 | Auto_flow Dense -> Css.make "grid-flow-dense"
54 | Auto_flow Row_dense -> Css.make "grid-flow-row-dense"
55 | Auto_flow Col_dense -> Css.make "grid-flow-col-dense"
56 | Auto_cols `Auto -> Css.make "auto-cols-auto"
57 | Auto_cols `Min -> Css.make "auto-cols-min"
58 | Auto_cols `Max -> Css.make "auto-cols-max"
59 | Auto_cols (`Fr n) -> Css.make (Printf.sprintf "auto-cols-fr-%d" n)
60 | Auto_rows `Auto -> Css.make "auto-rows-auto"
61 | Auto_rows `Min -> Css.make "auto-rows-min"
62 | Auto_rows `Max -> Css.make "auto-rows-max"
63 | Auto_rows (`Fr n) -> Css.make (Printf.sprintf "auto-rows-fr-%d" n)
64
65let template_cols cols = Template_cols cols
66let template_rows rows = Template_rows rows
67let col span = Col span
68let row span = Row span
69let auto_flow flow = Auto_flow flow
70let auto_cols cols = Auto_cols cols
71let auto_rows rows = Auto_rows rows
72
73let combine ts = Css.concat (List.map to_class ts)