Skip to content

Commit

Permalink
add svg text to media.py and media.pyi
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinoUkaegbu committed Sep 28, 2024
1 parent 7416310 commit 008ce54
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
21 changes: 21 additions & 0 deletions reflex/components/el/elements/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,26 @@ class Svg(BaseHTML):
xmlns: Var[str]


class Text(BaseHTML):
"""The SVG text component."""

tag = "text"
# The x coordinate of the starting point of the text baseline.
x: Var[Union[str, int]]
# The y coordinate of the starting point of the text baseline.
y: Var[Union[str, int]]
# Shifts the text position horizontally from a previous text element.
dx: Var[Union[str, int]]
# Shifts the text position vertically from a previous text element.
dy: Var[Union[str, int]]
# Rotates orientation of each individual glyph.
rotate: Var[Union[str, int]]
# How the text is stretched or compressed to fit the width defined by the text_length attribute.
length_adjust: Var[str]
# A width that the text should be scaled to fit.
text_length: Var[Union[str, int]]


class Line(BaseHTML):
"""The SVG line component."""

Expand Down Expand Up @@ -486,6 +506,7 @@ class Path(BaseHTML):
class SVG(ComponentNamespace):
"""SVG component namespace."""

text = staticmethod(Text.create)
line = staticmethod(Line.create)
circle = staticmethod(Circle.create)
ellipse = staticmethod(Ellipse.create)
Expand Down
121 changes: 121 additions & 0 deletions reflex/components/el/elements/media.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,126 @@ class Svg(BaseHTML):
"""
...

class Text(BaseHTML):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
x: Optional[Union[Var[Union[int, str]], int, str]] = None,
y: Optional[Union[Var[Union[int, str]], int, str]] = None,
dx: Optional[Union[Var[Union[int, str]], int, str]] = None,
dy: Optional[Union[Var[Union[int, str]], int, str]] = None,
rotate: Optional[Union[Var[Union[int, str]], int, str]] = None,
length_adjust: Optional[Union[Var[str], str]] = None,
text_length: Optional[Union[Var[Union[int, str]], int, str]] = None,
access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mouse_down: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_enter: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_leave: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_move: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_out: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_over: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
**props,
) -> "Text":
"""Create the component.
Args:
*children: The children of the component.
x: The x coordinate of the starting point of the text baseline.
y: The y coordinate of the starting point of the text baseline.
dx: Shifts the text position horizontally from a previous text element.
dy: Shifts the text position vertically from a previous text element.
rotate: Rotates orientation of each individual glyph.
length_adjust: How the text is stretched or compressed to fit the width defined by the text_length attribute.
text_length: A width that the text should be scaled to fit.
access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
draggable: Defines whether the element can be dragged.
enter_key_hint: Hints what media types the media element is able to play.
hidden: Defines whether the element is hidden.
input_mode: Defines the type of the element.
item_prop: Defines the name of the element for metadata purposes.
lang: Defines the language used in the element.
role: Defines the role of the element.
slot: Assigns a slot in a shadow DOM shadow tree to an element.
spell_check: Defines whether the element may be checked for spelling errors.
tab_index: Defines the position of the current element in the tabbing order.
title: Defines a tooltip for the element.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
class_name: The class name for the component.
autofocus: Whether the component should take the focus once the page is loaded
custom_attrs: custom attribute
**props: The props of the component.
Returns:
The component.
"""
...

class Line(BaseHTML):
@overload
@classmethod
Expand Down Expand Up @@ -2701,6 +2821,7 @@ class Path(BaseHTML):
...

class SVG(ComponentNamespace):
text = staticmethod(Text.create)
line = staticmethod(Line.create)
circle = staticmethod(Circle.create)
ellipse = staticmethod(Ellipse.create)
Expand Down

0 comments on commit 008ce54

Please sign in to comment.