Text default as p (#2551)

This commit is contained in:
Alek Petuskey 2024-02-07 18:53:59 -08:00 committed by GitHub
parent cb66933921
commit ea2a5904f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -4,6 +4,8 @@ https://www.radix-ui.com/themes/docs/theme/typography
"""
from __future__ import annotations
from typing import Literal
from reflex import el
from reflex.vars import Var
@ -18,6 +20,8 @@ from .base import (
LiteralTextWeight,
)
LiteralType = Literal["p", "label", "div", "span"]
class Text(el.Span, RadixThemesComponent):
"""A foundational text primitive based on the <span> element."""
@ -28,7 +32,7 @@ class Text(el.Span, RadixThemesComponent):
as_child: Var[bool]
# Change the default rendered element into a semantically appropriate alternative (cannot be used with asChild)
as_: Var[str]
as_: Var[LiteralType] = "p" # type: ignore
# Text size: "1" - "9"
size: Var[LiteralTextSize]

View File

@ -7,11 +7,14 @@ from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.vars import Var, BaseVar, ComputedVar
from reflex.event import EventChain, EventHandler, EventSpec
from reflex.style import Style
from typing import Literal
from reflex import el
from reflex.vars import Var
from ..base import LiteralAccentColor, RadixThemesComponent
from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight
LiteralType = Literal["p", "label", "div", "span"]
class Text(el.Span, RadixThemesComponent):
@overload
@classmethod
@ -82,7 +85,12 @@ class Text(el.Span, RadixThemesComponent):
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
as_: Optional[Union[Var[str], str]] = None,
as_: Optional[
Union[
Var[Literal["p", "label", "div", "span"]],
Literal["p", "label", "div", "span"],
]
] = None,
size: Optional[
Union[
Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],