Skip to content

Commit

Permalink
Lib: small refactoring of cSS.ml
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Dec 4, 2024
1 parent 576c9a3 commit d876ec9
Showing 1 changed file with 5 additions and 159 deletions.
164 changes: 5 additions & 159 deletions lib/js_of_ocaml/cSS.ml
Original file line number Diff line number Diff line change
Expand Up @@ -703,166 +703,12 @@ module Color = struct
|| Js.to_bool (hsl_re##test s)
|| Js.to_bool (hsla_re##test s)
then s
else if
List.mem
(Js.to_string s)
[ "aliceblue"
; "antiquewhite"
; "aqua"
; "aquamarine"
; "azure"
; "beige"
; "bisque"
; "black"
; "blanchedalmond"
; "blue"
; "blueviolet"
; "brown"
; "burlywood"
; "cadetblue"
; "chartreuse"
; "chocolate"
; "coral"
; "cornflowerblue"
; "cornsilk"
; "crimson"
; "cyan"
; "darkblue"
; "darkcyan"
; "darkgoldenrod"
; "darkgray"
; "darkgreen"
; "darkgrey"
; "darkkhaki"
; "darkmagenta"
; "darkolivegreen"
; "darkorange"
; "darkorchid"
; "darkred"
; "darksalmon"
; "darkseagreen"
; "darkslateblue"
; "darkslategray"
; "darkslategrey"
; "darkturquoise"
; "darkviolet"
; "deeppink"
; "deepskyblue"
; "dimgray"
; "dimgrey"
; "dodgerblue"
; "firebrick"
; "floralwhite"
; "forestgreen"
; "fuchsia"
; "gainsboro"
; "ghostwhite"
; "gold"
; "goldenrod"
; "gray"
; "green"
; "greenyellow"
; "grey"
; "honeydew"
; "hotpink"
; "indianred"
; "indigo"
; "ivory"
; "khaki"
; "lavender"
; "lavenderblush"
; "lawngreen"
; "lemonchiffon"
; "lightblue"
; "lightcoral"
; "lightcyan"
; "lightgoldenrodyellow"
; "lightgray"
; "lightgreen"
; "lightgrey"
; "lightpink"
; "lightsalmon"
; "lightseagreen"
; "lightskyblue"
; "lightslategray"
; "lightslategrey"
; "lightsteelblue"
; "lightyellow"
; "lime"
; "limegreen"
; "linen"
; "magenta"
; "maroon"
; "mediumaquamarine"
; "mediumblue"
; "mediumorchid"
; "mediumpurple"
; "mediumseagreen"
; "mediumslateblue"
; "mediumspringgreen"
; "mediumturquoise"
; "mediumvioletred"
; "midnightblue"
; "mintcream"
; "mistyrose"
; "moccasin"
; "navajowhite"
; "navy"
; "oldlace"
; "olive"
; "olivedrab"
; "orange"
; "orangered"
; "orchid"
; "palegoldenrod"
; "palegreen"
; "paleturquoise"
; "palevioletred"
; "papayawhip"
; "peachpuff"
; "peru"
; "pink"
; "plum"
; "powderblue"
; "purple"
; "red"
; "rosybrown"
; "royalblue"
; "saddlebrown"
; "salmon"
; "sandybrown"
; "seagreen"
; "seashell"
; "sienna"
; "silver"
; "skyblue"
; "slateblue"
; "slategray"
; "slategrey"
; "snow"
; "springgreen"
; "steelblue"
; "tan"
; "teal"
; "thistle"
; "tomato"
; "turquoise"
; "violet"
; "wheat"
; "white"
; "whitesmoke"
; "yellow"
; "yellowgreen"
]
then s
else raise (Invalid_argument (Js.to_string s ^ " is not a valid color"))

let name cn = Js.string (string_of_name cn)
else
match name_of_string (Js.to_string s) with
| _ -> s
| exception _ -> raise (Invalid_argument (Js.to_string s ^ " is not a valid color"))

let js = function
| Name n -> name n
| (RGB _ | RGB_percent _ | RGBA _ | RGBA_percent _ | HSL _ | HSLA _) as c ->
Js.string (string_of_t c)
let js c = Js.string (string_of_t c)

let ml c =
let s = Js.to_string c in
Expand Down

0 comments on commit d876ec9

Please sign in to comment.