type overflow = [ | `Auto | `Hidden | `Clip | `Visible | `Scroll ] type box_sizing = [ | `Border_box | `Content_box ] type object_fit = [ | `Contain | `Cover | `Fill | `None | `Scale_down ] type object_position = [ | `Bottom | `Center | `Left | `Left_bottom | `Left_top | `Right | `Right_bottom | `Right_top | `Top ] type t = [ | `Width of Size.t | `Height of Size.t | `Min_width of Size.t | `Max_width of Size.t | `Min_height of Size.t | `Max_height of Size.t | `Overflow of [`All | `X | `Y] * overflow | `Box_sizing of box_sizing | `Object_fit of object_fit | `Object_position of object_position | `Aspect of [`Auto | `Square | `Video | `Ratio of int * int] ] let to_class = function | `Width size -> Css.make (Printf.sprintf "w-%s" (Size.to_string size)) | `Height size -> Css.make (Printf.sprintf "h-%s" (Size.to_string size)) | `Min_width size -> Css.make (Printf.sprintf "min-w-%s" (Size.to_string size)) | `Max_width size -> Css.make (Printf.sprintf "max-w-%s" (Size.to_string size)) | `Min_height size -> Css.make (Printf.sprintf "min-h-%s" (Size.to_string size)) | `Max_height size -> Css.make (Printf.sprintf "max-h-%s" (Size.to_string size)) | `Overflow (`All, `Auto) -> Css.make "overflow-auto" | `Overflow (`All, `Hidden) -> Css.make "overflow-hidden" | `Overflow (`All, `Clip) -> Css.make "overflow-clip" | `Overflow (`All, `Visible) -> Css.make "overflow-visible" | `Overflow (`All, `Scroll) -> Css.make "overflow-scroll" | `Overflow (`X, `Auto) -> Css.make "overflow-x-auto" | `Overflow (`X, `Hidden) -> Css.make "overflow-x-hidden" | `Overflow (`X, `Clip) -> Css.make "overflow-x-clip" | `Overflow (`X, `Visible) -> Css.make "overflow-x-visible" | `Overflow (`X, `Scroll) -> Css.make "overflow-x-scroll" | `Overflow (`Y, `Auto) -> Css.make "overflow-y-auto" | `Overflow (`Y, `Hidden) -> Css.make "overflow-y-hidden" | `Overflow (`Y, `Clip) -> Css.make "overflow-y-clip" | `Overflow (`Y, `Visible) -> Css.make "overflow-y-visible" | `Overflow (`Y, `Scroll) -> Css.make "overflow-y-scroll" | `Box_sizing `Border_box -> Css.make "box-border" | `Box_sizing `Content_box -> Css.make "box-content" | `Object_fit `Contain -> Css.make "object-contain" | `Object_fit `Cover -> Css.make "object-cover" | `Object_fit `Fill -> Css.make "object-fill" | `Object_fit `None -> Css.make "object-none" | `Object_fit `Scale_down -> Css.make "object-scale-down" | `Object_position `Bottom -> Css.make "object-bottom" | `Object_position `Center -> Css.make "object-center" | `Object_position `Left -> Css.make "object-left" | `Object_position `Left_bottom -> Css.make "object-left-bottom" | `Object_position `Left_top -> Css.make "object-left-top" | `Object_position `Right -> Css.make "object-right" | `Object_position `Right_bottom -> Css.make "object-right-bottom" | `Object_position `Right_top -> Css.make "object-right-top" | `Object_position `Top -> Css.make "object-top" | `Aspect `Auto -> Css.make "aspect-auto" | `Aspect `Square -> Css.make "aspect-square" | `Aspect `Video -> Css.make "aspect-video" | `Aspect (`Ratio (w, h)) -> Css.make (Printf.sprintf "aspect-[%d/%d]" w h) let width size = `Width size let height size = `Height size let min_width size = `Min_width size let max_width size = `Max_width size let min_height size = `Min_height size let max_height size = `Max_height size let overflow dir overflow = `Overflow (dir, overflow) let box_sizing bs = `Box_sizing bs let object_fit of_ = `Object_fit of_ let object_position op = `Object_position op let aspect a = `Aspect a let w_full = Css.make "w-full" let w_screen = Css.make "w-screen" let w_auto = Css.make "w-auto" let w_fit = Css.make "w-fit" let h_full = Css.make "h-full" let h_screen = Css.make "h-screen" let h_auto = Css.make "h-auto" let h_fit = Css.make "h-fit" (* Accessibility utilities *) let sr_only = Css.make "sr-only" let focus_ring ?color ?width () = let base_classes = [ Css.make "focus:outline-none"; Css.make "focus:ring-2"; Css.make "focus:ring-offset-2"; ] in let color_class = match color with | Some c -> [Color.ring c] | None -> [Css.make "focus:ring-blue-500"] in let width_class = match width with | Some _ -> [] (* Could implement width variations *) | None -> [] in Css.concat (base_classes @ color_class @ width_class)