Skip to content

Commit c8413ba

Browse files
Add SVG marker element support
- Add Marker class with all standard SVG marker attributes - Include marker in SVG namespace and convenience functions - Add test coverage for marker element - Follows established patterns for SVG element implementation Co-Authored-By: khaleel@reflex.dev <khaleel.aladhami@gmail.com>
1 parent 8c1ca43 commit c8413ba

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

pyi_hashes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"reflex/components/el/elements/base.pyi": "7d1163c7221bb16691ce179646ce8515",
3333
"reflex/components/el/elements/forms.pyi": "a2099706131a8cf364b2bf9a6f958cdc",
3434
"reflex/components/el/elements/inline.pyi": "8bc2bbf8f3fd8bb9b5910c0e888e5386",
35-
"reflex/components/el/elements/media.pyi": "09c761bb3743e2351073ad81397e7d13",
35+
"reflex/components/el/elements/media.pyi": "66846a0c74fbe772811cd6577b2796d0",
3636
"reflex/components/el/elements/metadata.pyi": "bace81e70eaa42adbf50702c166dcd65",
3737
"reflex/components/el/elements/other.pyi": "a6615c3b7373d57f3bf5bf52fd96410f",
3838
"reflex/components/el/elements/scripts.pyi": "944fbe108254498fd34d9fbf744fc965",

reflex/components/el/elements/media.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,36 @@ class Path(BaseHTML):
484484
d: Var[str | int | float]
485485

486486

487+
class Marker(BaseHTML):
488+
"""Display the marker element."""
489+
490+
tag = "marker"
491+
492+
# The height of the marker viewport.
493+
marker_height: Var[str | int | float]
494+
495+
# The width of the marker viewport.
496+
marker_width: Var[str | int | float]
497+
498+
# The coordinate system for the marker attributes.
499+
marker_units: Var[str]
500+
501+
# The orientation of the marker relative to the shape it is attached to.
502+
orient: Var[str | int | float]
503+
504+
# How the svg fragment must be deformed if it is embedded in a container with a different aspect ratio.
505+
preserve_aspect_ratio: Var[str]
506+
507+
# The x coordinate for the reference point of the marker.
508+
ref_x: Var[str | int | float]
509+
510+
# The y coordinate for the reference point of the marker.
511+
ref_y: Var[str | int | float]
512+
513+
# The bound of the SVG viewport for the current SVG fragment.
514+
view_box: Var[str]
515+
516+
487517
class G(BaseHTML):
488518
"""The SVG g component, used to group other SVG elements."""
489519

@@ -522,6 +552,7 @@ class SVG(ComponentNamespace):
522552
linear_gradient = staticmethod(LinearGradient.create)
523553
radial_gradient = staticmethod(RadialGradient.create)
524554
defs = staticmethod(Defs.create)
555+
marker = staticmethod(Marker.create)
525556
g = staticmethod(G.create)
526557
__call__ = staticmethod(Svg.create)
527558

@@ -537,6 +568,7 @@ class SVG(ComponentNamespace):
537568
linear_gradient = LinearGradient.create
538569
radial_gradient = RadialGradient.create
539570
defs = Defs.create
571+
marker = Marker.create
540572
g = G.create
541573
area = Area.create
542574
audio = Audio.create

tests/units/components/el/test_svg.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
G,
66
Line,
77
LinearGradient,
8+
Marker,
89
Path,
910
Polygon,
1011
RadialGradient,
@@ -75,6 +76,11 @@ def test_stop():
7576
assert stop["name"] == '"stop"'
7677

7778

79+
def test_marker():
80+
marker = Marker.create().render()
81+
assert marker["name"] == '"marker"'
82+
83+
7884
def test_g():
7985
g = G.create().render()
8086
assert g["name"] == '"g"'

0 commit comments

Comments
 (0)