type position = [ | `Static | `Fixed | `Absolute | `Relative | `Sticky ] type inset_dir = [ | `All | `X | `Y | `Top | `Right | `Bottom | `Left | `Start | `End ] type t = [ | `Position of position | `Inset of inset_dir * Size.t | `Z_index of int option ] let to_class = function | `Position `Static -> Css.make "static" | `Position `Fixed -> Css.make "fixed" | `Position `Absolute -> Css.make "absolute" | `Position `Relative -> Css.make "relative" | `Position `Sticky -> Css.make "sticky" | `Inset (`All, size) -> Css.make (Printf.sprintf "inset-%s" (Size.to_string size)) | `Inset (`X, size) -> Css.make (Printf.sprintf "inset-x-%s" (Size.to_string size)) | `Inset (`Y, size) -> Css.make (Printf.sprintf "inset-y-%s" (Size.to_string size)) | `Inset (`Top, size) -> Css.make (Printf.sprintf "top-%s" (Size.to_string size)) | `Inset (`Right, size) -> Css.make (Printf.sprintf "right-%s" (Size.to_string size)) | `Inset (`Bottom, size) -> Css.make (Printf.sprintf "bottom-%s" (Size.to_string size)) | `Inset (`Left, size) -> Css.make (Printf.sprintf "left-%s" (Size.to_string size)) | `Inset (`Start, size) -> Css.make (Printf.sprintf "start-%s" (Size.to_string size)) | `Inset (`End, size) -> Css.make (Printf.sprintf "end-%s" (Size.to_string size)) | `Z_index None -> Css.make "z-auto" | `Z_index (Some n) -> Css.make (Printf.sprintf "z-%d" n) let position p = `Position p let inset dir size = `Inset (dir, size) let z_index z = `Z_index z let static = Css.make "static" let fixed = Css.make "fixed" let absolute = Css.make "absolute" let relative = Css.make "relative" let sticky = Css.make "sticky" let top size = inset `Top size let right size = inset `Right size let bottom size = inset `Bottom size let left size = inset `Left size let inset_x size = inset `X size let inset_y size = inset `Y size