Tailwind classes in OCaml
1type t = 2 | Px 3 | Zero 4 | Auto 5 | Rem of float 6 | Fraction of int * int 7 | Full 8 | Screen 9 | Min 10 | Max 11 | Fit 12 | Viewport of [`W | `H] * [`S | `L | `D] 13 14let to_string = function 15 | Px -> "px" 16 | Zero -> "0" 17 | Auto -> "auto" 18 | Rem f -> 19 let s = string_of_float f in 20 if String.ends_with ~suffix:".0" s then 21 String.sub s 0 (String.length s - 2) 22 else if String.ends_with ~suffix:"." s then 23 String.sub s 0 (String.length s - 1) 24 else s 25 | Fraction (n, d) -> Printf.sprintf "%d/%d" n d 26 | Full -> "full" 27 | Screen -> "screen" 28 | Min -> "min" 29 | Max -> "max" 30 | Fit -> "fit" 31 | Viewport (dir, size) -> 32 let d = match dir with `W -> "w" | `H -> "h" in 33 let s = match size with `S -> "s" | `L -> "l" | `D -> "d" in 34 Printf.sprintf "%sv%s" s d 35 36let px = Px 37let zero = Zero 38let auto = Auto 39let full = Full 40let screen = Screen 41 42let rem f = Rem f 43 44let fraction n d = Fraction (n, d)