Skip to content

Commit

Permalink
sticky badge inherit from A instead of using on_click/redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Lendemor committed Jan 24, 2025
1 parent 6c76b91 commit 8c3defa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
8 changes: 4 additions & 4 deletions reflex/components/core/sticky.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
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.inline import A
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.event import redirect
from reflex.style import Style


Expand Down Expand Up @@ -73,7 +72,7 @@ def add_style(self):
)


class StickyBadge(Box):
class StickyBadge(A):
"""A badge that displays the Reflex sticky."""

@classmethod
Expand All @@ -86,7 +85,8 @@ def create(cls):
return super().create(
StickyLogo.create(),
StickyLabel.create(),
on_click=redirect("https://reflex.dev"),
href="https://reflex.dev",
target="_blank",
width="auto",
padding="0.375rem",
align="center",
Expand Down
26 changes: 24 additions & 2 deletions reflex/components/core/sticky.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ 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.inline import A
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
Expand Down Expand Up @@ -301,12 +301,23 @@ class StickyLabel(Text):

def add_style(self): ...

class StickyBadge(Box):
class StickyBadge(A):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
target: Optional[Union[Var[Union[bool, int, str]], bool, 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]
Expand Down Expand Up @@ -370,6 +381,17 @@ class StickyNamespace(ComponentNamespace):
@staticmethod
def __call__(
*children,
download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
target: Optional[Union[Var[Union[bool, int, str]], bool, 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]
Expand Down

0 comments on commit 8c3defa

Please sign in to comment.