
* Improve import times * add lazy loading to rx.el * add lazy loading to reflex core components * minor refactor * Get imports working with reflex web * get imports to work with all reflex examples * refactor to define imports only in the root. * lint * deadcode remove * update poetry deps * unit tests fix * app_harness fix * app_harness fix * pyi file generate * pyi file generate * sort pyi order * fix pyi * fix docker ci * rework pyi-generator * generate pyi for __init__ files * test pyright * test pyright ci * partial pyright fix * more pyright fix * pyright fix * fix pyi_generator * add rx.serializer and others * add future annotation import which fixes container CI, then also load recharts lazily * add new pyi files * pyright fix * minor fixes for reflex-web and flexdown * forward references for py38 * ruff fix * pyi fix * unit tests fix * reduce coverage to 68% * reduce coverage to 67% * reduce coverage to 66%as a workaround to coverage's rounding issue * reduce coverage to 66%as a workaround to coverage's rounding issue * exclude lazy_loader dependency review checks. * its lazy-loader * Add docstrings and regenerate pyi files * add link * address Pr comments * CI fix * partially address PR comments. * edit docstrings and fix integration tests * fix typo in docstring * pyi fix
122 lines
2.6 KiB
Python
122 lines
2.6 KiB
Python
"""Components for rendering text.
|
|
|
|
https://www.radix-ui.com/themes/docs/theme/typography
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Literal
|
|
|
|
from reflex.components.component import ComponentNamespace
|
|
from reflex.components.el import elements
|
|
from reflex.vars import Var
|
|
|
|
from ..base import (
|
|
LiteralAccentColor,
|
|
RadixThemesComponent,
|
|
)
|
|
from .base import (
|
|
LiteralTextAlign,
|
|
LiteralTextSize,
|
|
LiteralTextTrim,
|
|
LiteralTextWeight,
|
|
)
|
|
|
|
LiteralType = Literal[
|
|
"p",
|
|
"label",
|
|
"div",
|
|
"span",
|
|
"b",
|
|
"i",
|
|
"u",
|
|
"abbr",
|
|
"cite",
|
|
"del",
|
|
"em",
|
|
"ins",
|
|
"kbd",
|
|
"mark",
|
|
"s",
|
|
"samp",
|
|
"sub",
|
|
"sup",
|
|
]
|
|
|
|
|
|
class Text(elements.Span, RadixThemesComponent):
|
|
"""A foundational text primitive based on the <span> element."""
|
|
|
|
tag = "Text"
|
|
|
|
# Change the default rendered element for the one passed as a child, merging their props and behavior.
|
|
as_child: Var[bool]
|
|
|
|
# Change the default rendered element into a semantically appropriate alternative (cannot be used with asChild)
|
|
as_: Var[LiteralType] = "p" # type: ignore
|
|
|
|
# Text size: "1" - "9"
|
|
size: Var[LiteralTextSize]
|
|
|
|
# Thickness of text: "light" | "regular" | "medium" | "bold"
|
|
weight: Var[LiteralTextWeight]
|
|
|
|
# Alignment of text in element: "left" | "center" | "right"
|
|
align: Var[LiteralTextAlign]
|
|
|
|
# Removes the leading trim space: "normal" | "start" | "end" | "both"
|
|
trim: Var[LiteralTextTrim]
|
|
|
|
# Overrides the accent color inherited from the Theme.
|
|
color_scheme: Var[LiteralAccentColor]
|
|
|
|
# Whether to render the text with higher contrast color
|
|
high_contrast: Var[bool]
|
|
|
|
|
|
class Span(Text):
|
|
"""A variant of text rendering as <span> element."""
|
|
|
|
as_: Var[LiteralType] = "span" # type: ignore
|
|
|
|
|
|
class Em(elements.Em, RadixThemesComponent):
|
|
"""Marks text to stress emphasis."""
|
|
|
|
tag = "Em"
|
|
|
|
|
|
class Kbd(elements.Kbd, RadixThemesComponent):
|
|
"""Represents keyboard input or a hotkey."""
|
|
|
|
tag = "Kbd"
|
|
|
|
# Text size: "1" - "9"
|
|
size: Var[LiteralTextSize]
|
|
|
|
|
|
class Quote(elements.Q, RadixThemesComponent):
|
|
"""A short inline quotation."""
|
|
|
|
tag = "Quote"
|
|
|
|
|
|
class Strong(elements.Strong, RadixThemesComponent):
|
|
"""Marks text to signify strong importance."""
|
|
|
|
tag = "Strong"
|
|
|
|
|
|
class TextNamespace(ComponentNamespace):
|
|
"""Checkbox components namespace."""
|
|
|
|
__call__ = staticmethod(Text.create)
|
|
em = staticmethod(Em.create)
|
|
kbd = staticmethod(Kbd.create)
|
|
quote = staticmethod(Quote.create)
|
|
strong = staticmethod(Strong.create)
|
|
span = staticmethod(Span.create)
|
|
|
|
|
|
text = TextNamespace()
|