Skip to content

Commit 54e0727

Browse files
Add SVG marker element support (#5683)
* 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: [email protected] <[email protected]> * Add marker to _MAPPING for proper lazy loading - Enables marker component to be discovered by Reflex's import system - Addresses PR feedback from @adhami3310 Co-Authored-By: [email protected] <[email protected]> * Revert marker from _MAPPING - Remove marker from top-level _MAPPING as requested by @adhami3310 - Marker should only be available at rx.el.marker and rx.el.svg.marker - Addresses PR feedback to keep marker in el namespace only Co-Authored-By: [email protected] <[email protected]> * Add marker to el elements _MAPPING - Enables rx.el.marker and rx.el.svg.marker access - Addresses PR feedback from @adhami3310 - Marker now properly available through el namespace only Co-Authored-By: [email protected] <[email protected]> * Update pyi_hashes.json after adding marker to el elements - Generated by update-pyi-files pre-commit hook - Fixes pre-commit issues as requested by @adhami3310 - All pre-commit hooks now pass with proper environment Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
1 parent 8c1ca43 commit 54e0727

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

pyi_hashes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
"reflex/components/datadisplay/code.pyi": "ec35c215a219c616ff38c30047d9b601",
2727
"reflex/components/datadisplay/dataeditor.pyi": "82c652f0679148d8431a0cf645686a50",
2828
"reflex/components/datadisplay/shiki_code_block.pyi": "1d53e75b6be0d3385a342e7b3011babd",
29-
"reflex/components/el/__init__.pyi": "00ded672c0336da6225036f56855b042",
29+
"reflex/components/el/__init__.pyi": "0adfd001a926a2a40aee94f6fa725ecc",
3030
"reflex/components/el/element.pyi": "c5974a92fbc310e42d0f6cfdd13472f4",
31-
"reflex/components/el/elements/__init__.pyi": "2e30624329b8b535dfd8969f95efdd25",
31+
"reflex/components/el/elements/__init__.pyi": "29512d7a6b29c6dc5ff68d3b31f26528",
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/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"linear_gradient",
7979
"radial_gradient",
8080
"defs",
81+
"marker",
8182
],
8283
"metadata": [
8384
"base",

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)