Skip to content

Commit a496fd1

Browse files
committed
Reverting the merging of opacity with offset. Opacity now takes a number.
1 parent 7478b52 commit a496fd1

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

lib/svg_f.ml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ struct
368368
let a_fy = user_attrib string_of_coord "fy"
369369

370370
let a_offset x =
371-
user_attrib C.string_of_number_or_percentage "offset" x
371+
user_attrib C.string_of_offset "offset" x
372372

373373
let a_patternUnits x =
374374
user_attrib C.string_of_big_variant "patternUnits" x
@@ -539,7 +539,7 @@ struct
539539
let a_animation_fill x =
540540
user_attrib C.string_of_big_variant "fill" x
541541

542-
let a_fill_opacity = user_attrib C.string_of_number_or_percentage "fill-opacity"
542+
let a_fill_opacity = user_attrib C.string_of_opacity "fill-opacity"
543543

544544
let a_fill_rule = user_attrib C.string_of_fill_rule "fill-rule"
545545

@@ -713,9 +713,12 @@ struct
713713
let a_ontouchmove = Xml.touch_event_handler_attrib "ontouchmove"
714714
let a_ontouchcancel = Xml.touch_event_handler_attrib "ontouchcancel"
715715

716+
717+
let a_opacity = user_attrib C.string_of_opacity "opacity"
718+
716719
let a_stop_color = color_attrib "stop-color"
717720

718-
let a_stop_opacity = user_attrib C.string_of_number "stop-opacity"
721+
let a_stop_opacity = user_attrib C.string_of_opacity "stop-opacity"
719722

720723
let a_stroke = user_attrib C.string_of_paint "stroke"
721724

@@ -737,7 +740,7 @@ struct
737740
user_attrib C.string_of_length "stroke-dashoffset"
738741

739742
let a_stroke_opacity =
740-
user_attrib C.string_of_number "stroke-opacity"
743+
user_attrib C.string_of_opacity "stroke-opacity"
741744

742745
(* xlink namespace given a nickname since some attributes mandated by
743746
the svg standard such as xlink:href live in that namespace, and we
@@ -1106,7 +1109,7 @@ struct
11061109

11071110
let string_of_numbers_semicolon = list ~sep:"; " string_of_number
11081111

1109-
let string_of_number_or_percentage = function
1112+
let string_of_offset = function
11101113
| `Number x -> string_of_number x
11111114
| `Percentage x -> string_of_percentage x
11121115

@@ -1116,6 +1119,8 @@ struct
11161119

11171120
let string_of_paint = string_of_paint
11181121

1122+
let string_of_opacity = string_of_number
1123+
11191124
let string_of_fill_rule = string_of_fill_rule
11201125

11211126
let string_of_strokedasharray = function

lib/svg_sigs.mli

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,7 @@ module type T = sig
488488
val a_animation_fill : [< | `Freeze | `Remove ] wrap -> [> | `Fill_Animation ] attrib
489489
[@@reflect.attribute "fill" ["animate"]]
490490

491-
val a_fill_opacity :
492-
[< `Number of number | `Percentage of percentage ] wrap ->
493-
[> | `Fill_opacity ] attrib
491+
val a_fill_opacity : number wrap -> [> | `Fill_opacity ] attrib
494492

495493
val a_fill_rule : fill_rule wrap -> [> | `Fill_rule ] attrib
496494

@@ -637,6 +635,8 @@ module type T = sig
637635
| `Text_after_edge | `Text_before_edge | `Inherit ] wrap ->
638636
[> | `Dominant_Baseline ] attrib
639637

638+
val a_opacity : number wrap -> [> | `Opacity ] attrib
639+
640640
val a_stop_color : color wrap -> [> | `Stop_Color ] attrib
641641

642642
val a_stop_opacity : number wrap -> [> | `Stop_Opacity ] attrib
@@ -1111,8 +1111,7 @@ module type Wrapped_functions = sig
11111111

11121112
val string_of_numbers_semicolon : (float list, string) Xml.W.ft
11131113

1114-
val string_of_number_or_percentage :
1115-
([< `Number of number | `Percentage of percentage ], string) Xml.W.ft
1114+
val string_of_offset : ([< Svg_types.offset], string) Xml.W.ft
11161115

11171116
val string_of_orient : (Svg_types.Unit.angle option, string) Xml.W.ft
11181117

test/test_ppx.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ let svg = "svg", SvgTests.make Svg.[
418418

419419
"fill_opacity, circle",
420420
[[%svg "<circle cx=50 cy=50 r=50 fill-opacity=0.5 />"]],
421-
[rect ~a:[a_cx (50., None); a_cy (50., None); a_r (50., None); a_fill_opacity (`Number 0.5)] []] ;
421+
[rect ~a:[a_cx (50., None); a_cy (50., None); a_r (50., None); a_fill_opacity 0.5] []] ;
422422

423423
"fill_rule type nonzero",
424424
[[%svg "<path fill-rule='nonzero'/>"]],

0 commit comments

Comments
 (0)