Tailwind classes in OCaml
1type position = [
2 | `Static
3 | `Fixed
4 | `Absolute
5 | `Relative
6 | `Sticky
7]
8
9type inset_dir = [
10 | `All
11 | `X
12 | `Y
13 | `Top
14 | `Right
15 | `Bottom
16 | `Left
17 | `Start
18 | `End
19]
20
21type t = [
22 | `Position of position
23 | `Inset of inset_dir * Size.t
24 | `Z_index of int option
25]
26
27let to_class = function
28 | `Position `Static -> Css.make "static"
29 | `Position `Fixed -> Css.make "fixed"
30 | `Position `Absolute -> Css.make "absolute"
31 | `Position `Relative -> Css.make "relative"
32 | `Position `Sticky -> Css.make "sticky"
33 | `Inset (`All, size) -> Css.make (Printf.sprintf "inset-%s" (Size.to_string size))
34 | `Inset (`X, size) -> Css.make (Printf.sprintf "inset-x-%s" (Size.to_string size))
35 | `Inset (`Y, size) -> Css.make (Printf.sprintf "inset-y-%s" (Size.to_string size))
36 | `Inset (`Top, size) -> Css.make (Printf.sprintf "top-%s" (Size.to_string size))
37 | `Inset (`Right, size) -> Css.make (Printf.sprintf "right-%s" (Size.to_string size))
38 | `Inset (`Bottom, size) -> Css.make (Printf.sprintf "bottom-%s" (Size.to_string size))
39 | `Inset (`Left, size) -> Css.make (Printf.sprintf "left-%s" (Size.to_string size))
40 | `Inset (`Start, size) -> Css.make (Printf.sprintf "start-%s" (Size.to_string size))
41 | `Inset (`End, size) -> Css.make (Printf.sprintf "end-%s" (Size.to_string size))
42 | `Z_index None -> Css.make "z-auto"
43 | `Z_index (Some n) -> Css.make (Printf.sprintf "z-%d" n)
44
45let position p = `Position p
46let inset dir size = `Inset (dir, size)
47let z_index z = `Z_index z
48
49let static = Css.make "static"
50let fixed = Css.make "fixed"
51let absolute = Css.make "absolute"
52let relative = Css.make "relative"
53let sticky = Css.make "sticky"
54
55let top size = inset `Top size
56let right size = inset `Right size
57let bottom size = inset `Bottom size
58let left size = inset `Left size
59let inset_x size = inset `X size
60let inset_y size = inset `Y size