feature: support Hightlight component (#1079)

This commit is contained in:
TaiJuWu 2023-05-27 02:40:42 +08:00 committed by GitHub
parent 9485127c1c
commit 2903d7a7ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -214,6 +214,7 @@ popover_header = PopoverHeader.create
popover_trigger = PopoverTrigger.create popover_trigger = PopoverTrigger.create
tooltip = Tooltip.create tooltip = Tooltip.create
heading = Heading.create heading = Heading.create
highlight = Highlight.create
markdown = Markdown.create markdown = Markdown.create
span = Span.create span = Span.create
text = Text.create text = Text.create

View File

@ -3,6 +3,7 @@
from pynecone.components.component import Component from pynecone.components.component import Component
from .heading import Heading from .heading import Heading
from .highlight import Highlight
from .markdown import Markdown from .markdown import Markdown
from .span import Span from .span import Span
from .text import Text from .text import Text

View File

@ -1,9 +1,10 @@
"""A heading component.""" """A highlight component."""
from typing import List from typing import List
from pynecone.components.libs.chakra import ChakraComponent from pynecone.components.libs.chakra import ChakraComponent
from pynecone.vars import Var from pynecone.components.tags import Tag
from pynecone.vars import Dict, Var
class Highlight(ChakraComponent): class Highlight(ChakraComponent):
@ -13,3 +14,10 @@ class Highlight(ChakraComponent):
# A query for the text to highlight. Can be a string or a list of strings. # A query for the text to highlight. Can be a string or a list of strings.
query: Var[List[str]] query: Var[List[str]]
# The style of the content.
# Note: styles and style are different prop.
styles: Var[Dict] = {"px": "2", "py": "1", "rounded": "full", "bg": "teal.100"} # type: ignore
def _render(self) -> Tag:
return super()._render().add_props(styles=self.style)