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