type border_width = [ `None | `Px | `Px2 | `Px4 | `Px8 ] type border_style = [ `Solid | `Dashed | `Dotted | `Double | `Hidden | `None ] type border_radius = [ `None | `Sm | `Base | `Md | `Lg | `Xl | `Xl2 | `Xl3 | `Full ] type shadow = [ `None | `Sm | `Base | `Md | `Lg | `Xl | `Xl2 | `Inner ] type opacity = int type transform_origin = [ `Center | `Top | `Top_right | `Right | `Bottom_right | `Bottom | `Bottom_left | `Left | `Top_left ] type t = [ | `Border_width of [`All | `X | `Y | `Top | `Right | `Bottom | `Left] * border_width | `Border_style of border_style | `Border_color of Color.t | `Rounded of [`All | `Top | `Right | `Bottom | `Left | `Tl | `Tr | `Br | `Bl] * border_radius | `Shadow of shadow | `Opacity of opacity | `Backdrop_blur of [`None | `Sm | `Base | `Md | `Lg | `Xl | `Xl2 | `Xl3] | `Transform of [`None | `Gpu] | `Transform_origin of transform_origin | `Scale of [`All | `X | `Y] * int | `Rotate of int | `Translate of [`X | `Y] * Size.t ] let to_class = function | `Border_width (`All, `None) -> Css.make "border-0" | `Border_width (`All, `Px) -> Css.make "border" | `Border_width (`All, `Px2) -> Css.make "border-2" | `Border_width (`All, `Px4) -> Css.make "border-4" | `Border_width (`All, `Px8) -> Css.make "border-8" | `Border_style `Solid -> Css.make "border-solid" | `Border_style `Dashed -> Css.make "border-dashed" | `Border_style `Dotted -> Css.make "border-dotted" | `Border_style `Double -> Css.make "border-double" | `Border_style `Hidden -> Css.make "border-hidden" | `Border_style `None -> Css.make "border-none" | `Border_color color -> Color.border color | `Rounded (`All, `None) -> Css.make "rounded-none" | `Rounded (`All, `Sm) -> Css.make "rounded-sm" | `Rounded (`All, `Base) -> Css.make "rounded" | `Rounded (`All, `Md) -> Css.make "rounded-md" | `Rounded (`All, `Lg) -> Css.make "rounded-lg" | `Rounded (`All, `Xl) -> Css.make "rounded-xl" | `Rounded (`All, `Xl2) -> Css.make "rounded-2xl" | `Rounded (`All, `Xl3) -> Css.make "rounded-3xl" | `Rounded (`All, `Full) -> Css.make "rounded-full" | `Shadow `None -> Css.make "shadow-none" | `Shadow `Sm -> Css.make "shadow-sm" | `Shadow `Base -> Css.make "shadow" | `Shadow `Md -> Css.make "shadow-md" | `Shadow `Lg -> Css.make "shadow-lg" | `Shadow `Xl -> Css.make "shadow-xl" | `Shadow `Xl2 -> Css.make "shadow-2xl" | `Shadow `Inner -> Css.make "shadow-inner" | `Opacity n -> Css.make (Printf.sprintf "opacity-%d" n) | `Transform `None -> Css.make "transform-none" | `Transform `Gpu -> Css.make "transform-gpu" | `Backdrop_blur `None -> Css.make "backdrop-blur-none" | `Backdrop_blur `Sm -> Css.make "backdrop-blur-sm" | `Backdrop_blur `Base -> Css.make "backdrop-blur" | `Backdrop_blur `Md -> Css.make "backdrop-blur-md" | `Backdrop_blur `Lg -> Css.make "backdrop-blur-lg" | `Backdrop_blur `Xl -> Css.make "backdrop-blur-xl" | `Backdrop_blur `Xl2 -> Css.make "backdrop-blur-2xl" | `Backdrop_blur `Xl3 -> Css.make "backdrop-blur-3xl" | `Transform_origin `Center -> Css.make "origin-center" | `Transform_origin `Top -> Css.make "origin-top" | `Transform_origin `Top_right -> Css.make "origin-top-right" | `Transform_origin `Right -> Css.make "origin-right" | `Transform_origin `Bottom_right -> Css.make "origin-bottom-right" | `Transform_origin `Bottom -> Css.make "origin-bottom" | `Transform_origin `Bottom_left -> Css.make "origin-bottom-left" | `Transform_origin `Left -> Css.make "origin-left" | `Transform_origin `Top_left -> Css.make "origin-top-left" | `Scale (dir, percent) -> let dir_str = match dir with `All -> "" | `X -> "-x" | `Y -> "-y" in Css.make (Printf.sprintf "scale%s-%d" dir_str percent) | `Rotate degrees -> Css.make (Printf.sprintf "rotate-%d" degrees) | `Translate (dir, size) -> let dir_str = match dir with `X -> "x" | `Y -> "y" in Css.make (Printf.sprintf "translate-%s-%s" dir_str (Size.to_string size)) | `Rounded (_, _) -> Css.empty (* This should be handled by the specific rounded patterns above *) | `Border_width (_, _) -> Css.empty (* This should be handled by the specific border patterns above *) let border_width dir width = `Border_width (dir, width) let border_style style = `Border_style style let border_color color = `Border_color color let rounded dir radius = `Rounded (dir, radius) let shadow s = `Shadow s let opacity o = `Opacity o let backdrop_blur blur = `Backdrop_blur blur let transform t = `Transform t let transform_origin origin = `Transform_origin origin let scale dir percent = `Scale (dir, percent) let rotate degrees = `Rotate degrees let translate dir size = `Translate (dir, size) let border = Css.make "border" let border_2 = Css.make "border-2" let border_4 = Css.make "border-4" let rounded_sm = Css.make "rounded-sm" let rounded_md = Css.make "rounded-md" let rounded_lg = Css.make "rounded-lg" let rounded_full = Css.make "rounded-full" let shadow_sm = Css.make "shadow-sm" let shadow_md = Css.make "shadow-md" let shadow_lg = Css.make "shadow-lg" (* Animation and transition utilities *) type transition_property = [ `None | `All | `Colors | `Opacity | `Shadow | `Transform ] type timing_function = [ `Linear | `In | `Out | `In_out ] let transition transition_type = let class_name = match transition_type with | `None -> "transition-none" | `All -> "transition-all" | `Colors -> "transition-colors" | `Opacity -> "transition-opacity" | `Shadow -> "transition-shadow" | `Transform -> "transition-transform" in Css.make class_name let duration ms = Css.make (Printf.sprintf "duration-%d" ms) let ease timing = let class_name = match timing with | `Linear -> "ease-linear" | `In -> "ease-in" | `Out -> "ease-out" | `In_out -> "ease-in-out" in Css.make class_name (* Text shadow utilities *) let text_shadow shadow_size = let class_name = match shadow_size with | `None -> "text-shadow-none" | `Sm -> "text-shadow-sm" | `Base -> "text-shadow" | `Lg -> "text-shadow-lg" | `Xl -> "text-shadow-xl" in Css.make class_name (* Mask utilities *) let mask mask_type = let class_name = match mask_type with | `Auto -> "mask-auto" | `Cover -> "mask-cover" | `Contain -> "mask-contain" in Css.make class_name (* 3D perspective *) let perspective perspective_type = let class_name = match perspective_type with | `None -> "perspective-none" | `Distant -> "perspective-distant" | `Normal -> "perspective-normal" | `Near -> "perspective-near" in Css.make class_name