package tw
Source file box_sizing.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38(** Box sizing utilities *) module Css = Cascade.Css module Handler = struct open Style open Css type t = Border | Content let name = "box_sizing" (* box-sizing (rank 25) sorts after margin/prose (priority 2) and before the display family (priority 4). *) let priority _ = 3 let suborder = function Border -> 0 | Content -> 1 let to_class = function Border -> "box-border" | Content -> "box-content" let to_style _theme = function | Border -> style [ box_sizing Border_box ] | Content -> style [ box_sizing Content_box ] let of_class _theme class_name = let parts = Parse.split_class class_name in match parts with | [ "box"; "border" ] -> Ok Border | [ "box"; "content" ] -> Ok Content | _ -> Error (`Msg "Not a box-sizing utility") let examples = [ Border ] end open Handler module Utility_factory = Utility.Make (Handler) let utility = Utility_factory.v let box_border = utility Border let box_content = utility Content