diff --git a/reflex/__init__.py b/reflex/__init__.py index 0be568b1a..071a3b112 100644 --- a/reflex/__init__.py +++ b/reflex/__init__.py @@ -245,6 +245,7 @@ COMPONENTS_CORE_MAPPING: dict = { "selected_files", "upload", ], + "components.core.watermark": ["watermark"], } COMPONENTS_BASE_MAPPING: dict = { diff --git a/reflex/__init__.pyi b/reflex/__init__.pyi index 6bdfa11a0..f0e141f8c 100644 --- a/reflex/__init__.pyi +++ b/reflex/__init__.pyi @@ -56,6 +56,7 @@ from .components.core.upload import get_upload_dir as get_upload_dir from .components.core.upload import get_upload_url as get_upload_url from .components.core.upload import selected_files as selected_files from .components.core.upload import upload as upload +from .components.core.watermark import watermark as watermark from .components.datadisplay.code import code_block as code_block from .components.datadisplay.dataeditor import data_editor as data_editor from .components.datadisplay.dataeditor import data_editor_theme as data_editor_theme diff --git a/reflex/components/core/watermark.py b/reflex/components/core/watermark.py new file mode 100644 index 000000000..19a0893d1 --- /dev/null +++ b/reflex/components/core/watermark.py @@ -0,0 +1,131 @@ +"""Components for displaying the Reflex watermark.""" + +from reflex.components.component import ComponentNamespace +from reflex.components.core.colors import color +from reflex.components.core.cond import color_mode_cond +from reflex.components.el.elements.media import Path, Rect, Svg +from reflex.components.radix.themes.layout.box import Box +from reflex.components.radix.themes.typography.text import Text +from reflex.style import Style + + +class WatermarkLogo(Svg): + """A simple Reflex logo SVG with only the letter R.""" + + @classmethod + def create(cls): + """Create the simple Reflex logo SVG. + + Returns: + The simple Reflex logo SVG. + """ + return super().create( + Rect.create(width="16", height="16", rx="2", fill="#6E56CF"), + Path.create(d="M10 9V13H12V9H10Z", fill="white"), + Path.create(d="M4 3V13H6V9H10V7H6V5H10V7H12V3H4Z", fill="white"), + width="16", + height="16", + viewBox="0 0 16 16", + xmlns="http://www.w3.org/2000/svg", + ) + + def add_style(self): + """Add the style to the component. + + Returns: + The style of the component. + """ + return Style( + { + "fill": "white", + } + ) + + +class WatermarkLabel(Text): + """A label that displays the Reflex watermark.""" + + @classmethod + def create(cls): + """Create the watermark label. + + Returns: + The watermark label. + """ + return super().create("Built with Reflex!") + + def add_style(self): + """Add the style to the component. + + Returns: + The style of the component. + """ + return Style( + { + "color": color("slate", 1), + "font-weight": "600", + "font-family": "'Instrument Sans', sans-serif", + "font-size": "0.875rem", + "line-height": "1rem", + "letter-spacing": "-0.00656rem", + } + ) + + +class WatermarkBadge(Box): + """A badge that displays the Reflex watermark.""" + + @classmethod + def create(cls): + """Create the watermark badge. + + Returns: + The watermark badge. + """ + return super().create( + WatermarkLogo.create(), + WatermarkLabel.create(), + width="auto", + padding="0.375rem", + align="center", + text_align="center", + ) + + def add_style(self): + """Add the style to the component. + + Returns: + The style of the component. + """ + return Style( + { + "position": "fixed", + "bottom": "1rem", + "right": "1rem", + "display": "flex", + "flex-direction": "row", + "gap": "0.375rem", + "align-items": "center", + "width": "auto", + "border-radius": "0.5rem", + "color": color_mode_cond("#E5E7EB", "#27282B"), + "border": color_mode_cond("1px solid #27282B", "1px solid #E5E7EB"), + "background-color": color_mode_cond("#151618", "#FCFCFD"), + "padding": "0.375rem", + "transition": "background-color 0.2s ease-in-out", + "box-shadow": "0 1px 2px 0 rgba(0, 0, 0, 0.05)", + "z-index": "9998", + "cursor": "pointer", + } + ) + + +class WatermarkNamespace(ComponentNamespace): + """Watermark components namespace.""" + + __call__ = staticmethod(WatermarkBadge.create) + label = staticmethod(WatermarkLabel.create) + logo = staticmethod(WatermarkLogo.create) + + +watermark = WatermarkNamespace() diff --git a/reflex/components/core/watermark.pyi b/reflex/components/core/watermark.pyi new file mode 100644 index 000000000..6606be537 --- /dev/null +++ b/reflex/components/core/watermark.pyi @@ -0,0 +1,427 @@ +"""Stub file for reflex/components/core/watermark.py""" + +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ +from typing import Any, Dict, Literal, Optional, Union, overload + +from reflex.components.component import ComponentNamespace +from reflex.components.core.breakpoints import Breakpoints +from reflex.components.el.elements.media import Svg +from reflex.components.radix.themes.layout.box import Box +from reflex.components.radix.themes.typography.text import Text +from reflex.event import BASE_STATE, EventType +from reflex.style import Style +from reflex.vars.base import Var + +class WatermarkLogo(Svg): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, + xmlns: Optional[Union[Var[str], 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "WatermarkLogo": + """Create the simple Reflex logo SVG. + + Returns: + The simple Reflex logo SVG. + """ + ... + + def add_style(self): ... + +class WatermarkLabel(Text): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + as_child: Optional[Union[Var[bool], bool]] = None, + as_: Optional[ + Union[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ], + Var[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ] + ], + ] + ] = None, + size: Optional[ + Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + Union[ + Breakpoints[ + str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + ] + ], + ] + ] = None, + weight: Optional[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + Var[ + Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], + ] + ], + ] + ] = None, + align: Optional[ + Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + Var[ + Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], + ] + ], + ] + ] = None, + trim: Optional[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + Var[ + Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], + ] + ], + ] + ] = None, + color_scheme: Optional[ + Union[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] + ], + ] + ] = None, + high_contrast: Optional[Union[Var[bool], bool]] = 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "WatermarkLabel": + """Create the watermark label. + + Returns: + The watermark label. + """ + ... + + def add_style(self): ... + +class WatermarkBadge(Box): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "WatermarkBadge": + """Create the watermark badge. + + Returns: + The watermark badge. + """ + ... + + def add_style(self): ... + +class WatermarkNamespace(ComponentNamespace): + label = staticmethod(WatermarkLabel.create) + logo = staticmethod(WatermarkLogo.create) + + @staticmethod + def __call__( + *children, + 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "WatermarkBadge": + """Create the watermark badge. + + Returns: + The watermark badge. + """ + ... + +watermark = WatermarkNamespace()