Skip to content

Commit b2382d2

Browse files
authored
Merge pull request #289 from samoht/color-fold-refuse
text-shadow: drop the prefix from the arbitrary-colour constructors
2 parents 18d8827 + 8b9e72a commit b2382d2

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

lib/text_shadow.ml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ module Handler = struct
1515

1616
(* Color in an arbitrary shadow value *)
1717
type arb_color =
18-
| Arb_hex of string
19-
| Arb_var of string
20-
| Arb_css_color of Css.color
21-
| Arb_none
18+
| Hex of string
19+
| Var_ref of string
20+
| Css_color of Css.color
21+
| No_color
2222

2323
type t =
2424
| Text_shadow_none
@@ -97,16 +97,16 @@ module Handler = struct
9797
let rec find_color_and_lengths acc (parts : string list) :
9898
string list * arb_color =
9999
match parts with
100-
| [] -> (List.rev acc, Arb_none)
100+
| [] -> (List.rev acc, No_color)
101101
| x :: _rest when String.length x > 0 && x.[0] = '#' ->
102-
(List.rev acc, Arb_hex x)
102+
(List.rev acc, Hex x)
103103
| x :: _rest when String.length x > 4 && String.sub x 0 4 = "var(" ->
104-
(List.rev acc, Arb_var x)
104+
(List.rev acc, Var_ref x)
105105
| x :: rest when Parse.is_css_color_fn x -> (
106106
(* A colour function may carry spaces, so it runs to the end of the
107107
value. *)
108108
match Css.parse_color (String.concat " " (x :: rest)) with
109-
| Some c -> (List.rev acc, Arb_css_color c)
109+
| Some c -> (List.rev acc, Css_color c)
110110
| None -> find_color_and_lengths (x :: acc) rest)
111111
| x :: rest -> find_color_and_lengths (x :: acc) rest
112112
in
@@ -118,7 +118,7 @@ module Handler = struct
118118
if List.compare_lengths lengths length_strs <> 0 then Stdlib.Option.None
119119
else
120120
match color with
121-
| Arb_hex h when not (is_hex_value h) -> Stdlib.Option.None
121+
| Hex h when not (is_hex_value h) -> Stdlib.Option.None
122122
| _ -> (
123123
match lengths with
124124
| [ h; v ] -> Some (h, v, Stdlib.Option.None, color)
@@ -486,11 +486,11 @@ module Handler = struct
486486
| Some (h_offset, v_offset, blur, color) ->
487487
let fallback_color : Css.color =
488488
match color with
489-
| Arb_hex c -> Css.hex (shorten_hex c)
490-
| Arb_var v -> make_full_color_var v
491-
| Arb_css_color c -> (
489+
| Hex c -> Css.hex (shorten_hex c)
490+
| Var_ref v -> make_full_color_var v
491+
| Css_color c -> (
492492
match Color.css_color_to_hex c with Some h -> h | None -> c)
493-
| Arb_none -> Css.Current
493+
| No_color -> Css.Current
494494
in
495495
let color_ref =
496496
Var.reference_with_fallback text_shadow_color_var fallback_color
@@ -511,13 +511,13 @@ module Handler = struct
511511
let alpha_d = alpha_decl percent in
512512
let base_fallback : Css.color =
513513
match color with
514-
| Arb_hex c -> Color.hex_to_oklab_alpha c alpha
515-
| Arb_var v -> make_full_color_var v
516-
| Arb_css_color c -> (
514+
| Hex c -> Color.hex_to_oklab_alpha c alpha
515+
| Var_ref v -> make_full_color_var v
516+
| Css_color c -> (
517517
match hex_string_of_css_color c with
518518
| Some hex -> Color.hex_to_oklab_alpha hex alpha
519519
| None -> c)
520-
| Arb_none -> Css.Current
520+
| No_color -> Css.Current
521521
in
522522
let base_color_ref =
523523
Var.reference_with_fallback text_shadow_color_var base_fallback
@@ -529,8 +529,8 @@ module Handler = struct
529529
in
530530
let rules =
531531
match color with
532-
| Arb_hex _ | Arb_css_color _ -> Stdlib.Option.None
533-
| Arb_var v -> (
532+
| Hex _ | Css_color _ -> Stdlib.Option.None
533+
| Var_ref v -> (
534534
match relative_oklab_from_var v percent with
535535
| Some relative_color ->
536536
let enhanced_ref =
@@ -556,7 +556,7 @@ module Handler = struct
556556
in
557557
Some [ supports_block ]
558558
| None -> Stdlib.Option.None)
559-
| Arb_none ->
559+
| No_color ->
560560
let color_mix_fallback =
561561
Css.color_mix ~in_space:Oklab Css.Current Css.Transparent
562562
~percent1:percent
@@ -796,9 +796,9 @@ module Handler = struct
796796
let suborder = function
797797
| Text_shadow_arbitrary_opacity (arb, _) -> (
798798
match parse_arbitrary_shadow arb with
799-
| Some (_, _, _, Arb_var _) -> -3 (* @supports lab *)
800-
| Some (_, _, _, Arb_none) -> -2 (* @supports color-mix *)
801-
| Some (_, _, _, (Arb_hex _ | Arb_css_color _)) -> -1 (* no @supports *)
799+
| Some (_, _, _, Var_ref _) -> -3 (* @supports lab *)
800+
| Some (_, _, _, No_color) -> -2 (* @supports color-mix *)
801+
| Some (_, _, _, (Hex _ | Css_color _)) -> -1 (* no @supports *)
802802
| Stdlib.Option.None -> 0)
803803
| Text_shadow_shape_opacity _ -> -1 (* no @supports *)
804804
| _ -> 0

0 commit comments

Comments
 (0)