Przeglądaj źródła

add g svg element (#5360)

Carlos 3 dni temu
rodzic
commit
0c35a29629

+ 2 - 2
pyi_hashes.json

@@ -27,11 +27,11 @@
   "reflex/components/datadisplay/shiki_code_block.pyi": "ac16fd6c23eef7ce0185437ecf2d529d",
   "reflex/components/el/__init__.pyi": "09042a2db5e0637e99b5173430600522",
   "reflex/components/el/element.pyi": "323cfb5d67d8ccb58ac36c7cc7641dc3",
-  "reflex/components/el/elements/__init__.pyi": "280ed457675f3720e34b560a3f617739",
+  "reflex/components/el/elements/__init__.pyi": "baeddd04d4d3a82799420b2a6df368f6",
   "reflex/components/el/elements/base.pyi": "697cd6716e3b1127b35299435c3d4e69",
   "reflex/components/el/elements/forms.pyi": "21d7135b513bac72fd63b44c945932a5",
   "reflex/components/el/elements/inline.pyi": "ab31eec758f1cff8a9d51bf0935b9fca",
-  "reflex/components/el/elements/media.pyi": "ac99654959ed26b7b7d0f3dafa0ea2ab",
+  "reflex/components/el/elements/media.pyi": "c191a9e00223a97e26a0d6ab99a1919b",
   "reflex/components/el/elements/metadata.pyi": "eda94a3283bae6a9b61b4cb1e20c1dbd",
   "reflex/components/el/elements/other.pyi": "960bdac0bb9bf6b3cffd241f9b66c0fc",
   "reflex/components/el/elements/scripts.pyi": "ac3b8bfbd7777f33fb2c6aa109a5c627",

+ 1 - 0
reflex/components/el/elements/__init__.py

@@ -69,6 +69,7 @@ _MAPPING = {
         "text",
         "line",
         "circle",
+        "g",
         "ellipse",
         "rect",
         "polygon",

+ 26 - 0
reflex/components/el/elements/media.py

@@ -484,6 +484,30 @@ class Path(BaseHTML):
     d: Var[str | int | float]
 
 
+class G(BaseHTML):
+    """The SVG g component, used to group other SVG elements."""
+
+    tag = "g"
+
+    # The fill color of the group.
+    fill: Var[str | Color]
+
+    # The fill opacity of the group.
+    fill_opacity: Var[str | int | float]
+
+    # The stroke color of the group.
+    stroke: Var[str | Color]
+
+    # The stroke opacity of the group.
+    stroke_opacity: Var[str | int | float]
+
+    # The stroke width of the group.
+    stroke_width: Var[str | int | float]
+
+    # The transform applied to the group.
+    transform: Var[str]
+
+
 class SVG(ComponentNamespace):
     """SVG component namespace."""
 
@@ -498,6 +522,7 @@ class SVG(ComponentNamespace):
     linear_gradient = staticmethod(LinearGradient.create)
     radial_gradient = staticmethod(RadialGradient.create)
     defs = staticmethod(Defs.create)
+    g = staticmethod(G.create)
     __call__ = staticmethod(Svg.create)
 
 
@@ -512,6 +537,7 @@ stop = Stop.create
 linear_gradient = LinearGradient.create
 radial_gradient = RadialGradient.create
 defs = Defs.create
+g = G.create
 area = Area.create
 audio = Audio.create
 image = img = Img.create

+ 6 - 0
tests/units/components/el/test_svg.py

@@ -2,6 +2,7 @@ from reflex.components.el.elements.media import (
     Circle,
     Defs,
     Ellipse,
+    G,
     Line,
     LinearGradient,
     Path,
@@ -72,3 +73,8 @@ def test_text():
 def test_stop():
     stop = Stop.create().render()
     assert stop["name"] == '"stop"'
+
+
+def test_g():
+    g = G.create().render()
+    assert g["name"] == '"g"'