Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support Hightlight component #1079

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pynecone/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
popover_trigger = PopoverTrigger.create
tooltip = Tooltip.create
heading = Heading.create
highlight = Highlight.create
markdown = Markdown.create
span = Span.create
text = Text.create
Expand Down
1 change: 1 addition & 0 deletions pynecone/components/typography/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pynecone.components.component import Component

from .heading import Heading
from .highlight import Highlight
from .markdown import Markdown
from .span import Span
from .text import Text
Expand Down
12 changes: 10 additions & 2 deletions pynecone/components/typography/highlight.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""A heading component."""
"""A highlight component."""

from typing import List

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):
Expand All @@ -13,3 +14,10 @@ class Highlight(ChakraComponent):

# A query for the text to highlight. Can be a string or a list of strings.
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)