Skip to content

Commit 2bcaa86

Browse files
Merge pull request #7 from itsmeadarsh2008/dev
2 parents 3f3d39f + 2d8cd7a commit 2bcaa86

File tree

7 files changed

+112
-17
lines changed

7 files changed

+112
-17
lines changed

examples/examples/examples.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,22 @@ def set_description(self, value: str):
2020
def change_body(self, value: str):
2121
self.description = "It is animated by default. Wrapper over @heroui"
2222

23+
2324
def index() -> rx.Component:
2425
return rx.container(
2526
hero.provider(
2627
# hero.theme(),
2728
rx.vstack(
28-
hero.avatar(
29-
name="John Doe",
30-
size="lg",
31-
src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston",
29+
hero.badge(
30+
hero.avatar(
31+
name="John Doe",
32+
size="lg",
33+
src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston",
34+
),
35+
content="1",
36+
),
37+
hero.snippet(
38+
rx.el.span("echo 'Hello, World!'"),
3239
),
3340
hero.alert(
3441
color="success",
@@ -37,17 +44,9 @@ def index() -> rx.Component:
3744
# variant="solid",
3845
),
3946
rx.flex(
40-
hero.button(
41-
"Increment",
42-
on_press=State.increment,
43-
color="success"
44-
),
47+
hero.button("Increment", on_press=State.increment, color="success"),
4548
rx.text(State.count),
46-
hero.button(
47-
"Decrement",
48-
on_press=State.decrement,
49-
color="danger"
50-
),
49+
hero.button("Decrement", on_press=State.decrement, color="danger"),
5150
align="center",
5251
margin="auto",
5352
gap="1rem",
@@ -79,12 +78,14 @@ def index() -> rx.Component:
7978
is_blurred=True,
8079
is_zoomed=True,
8180
),
82-
hero.chip("v1.0.0 has been released!", variant="faded", color="success"),
81+
hero.chip(
82+
"v1.0.0 has been released!", variant="faded", color="success"
83+
),
8384
hero.code("uv pip install heroui-provider"),
8485
hero.spinner(
8586
size="lg",
8687
variant="default",
87-
)
88+
),
8889
),
8990
)
9091
)

heroui/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from src.switch import *
1818
from src.chip import *
1919
from src.code import *
20+
from src.badge import *
21+
from src.snippet import *
2022

2123
# Import provider related components
2224
from src.provider import *

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "heroui-provider"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
description = "Hero UI - Modern UI components for Reflex Web Framework"
55
readme = "README.md"
66
authors = [

src/badge/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .badge import Badge
2+
3+
badge = Badge.create

src/badge/badge.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import reflex as rx
2+
from typing import Any, Literal, Optional, Union
3+
4+
lib_deps: list = ["@heroui/theme", "@heroui/system", "framer-motion"]
5+
6+
7+
class Badge(rx.Component):
8+
library = "@heroui/badge"
9+
lib_dependencies: list = lib_deps
10+
tag = "Badge"
11+
content: rx.Var[Union[str, int, Any]]
12+
variant: rx.Var[Literal["solid", "flat", "faded", "shadow"]] = "solid"
13+
color: rx.Var[
14+
Literal["default", "primary", "secondary", "success", "warning", "danger"]
15+
] = "default"
16+
size: rx.Var[Literal["sm", "md", "lg"]] = "md"
17+
shape: rx.Var[Literal["circle", "rectangle"]] = "rectangle"
18+
placement: rx.Var[
19+
Literal["top-right", "top-left", "bottom-right", "bottom-left"]
20+
] = "top-right"
21+
show_outline: rx.Var[bool] = True
22+
disable_outline: rx.Var[bool] = False
23+
disable_animation: rx.Var[bool] = False
24+
is_invisible: rx.Var[bool] = False
25+
is_one_char: rx.Var[bool] = False
26+
is_dot: rx.Var[bool] = False

src/snippet/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .snippet import Snippet
2+
3+
snippet = Snippet.create

src/snippet/snippet.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import reflex as rx
2+
from typing import Any, Literal, Optional, Union
3+
4+
5+
lib_deps: list = ["@heroui/theme", "@heroui/system", "framer-motion"]
6+
7+
8+
# Type aliases for component props
9+
TooltipProps = dict[str, Any]
10+
"""Type for tooltip component properties."""
11+
12+
ButtonProps = dict[str, Any]
13+
"""Type for button component properties."""
14+
15+
16+
class Snippet(rx.Component):
17+
"""A code snippet component with copy functionality and customizable appearance.
18+
19+
Attributes:
20+
library: The library the component belongs to.
21+
lib_dependencies: Dependencies required by the component.
22+
tag: The tag name for the component.
23+
size: The size of the snippet component.
24+
radius: The border radius of the snippet.
25+
symbol: The symbol to display before the code (string or ReactNode).
26+
timeout: The timeout duration for copy feedback in milliseconds.
27+
code_string: The code string to be copied to clipboard.
28+
tooltip_props: Additional props for the tooltip component.
29+
copy_icon: Custom icon for the copy button.
30+
check_icon: Custom icon shown after successful copy.
31+
disable_tooltip: Whether to disable the tooltip.
32+
disable_copy: Whether to disable copy functionality.
33+
hide_copy_button: Whether to hide the copy button.
34+
hide_symbol: Whether to hide the symbol.
35+
copy_button_props: Additional props for the copy button.
36+
disable_animation: Whether to disable animations.
37+
"""
38+
39+
library = "@heroui/snippet"
40+
lib_dependencies: list = lib_deps
41+
tag = "Snippet"
42+
43+
# Props
44+
size: rx.Var[Literal["sm", "md", "lg"]] = "md"
45+
radius: rx.Var[Literal["none", "sm", "md", "lg"]] = "lg"
46+
symbol: rx.Var[Union[str, Any]] = "$"
47+
timeout: rx.Var[int] = 2000
48+
code_string: rx.Var[Optional[str]]
49+
tooltip_props: rx.Var[Optional[TooltipProps]]
50+
copy_icon: rx.Var[Optional[Any]]
51+
check_icon: rx.Var[Optional[Any]]
52+
disable_tooltip: rx.Var[bool] = False
53+
disable_copy: rx.Var[bool] = False
54+
hide_copy_button: rx.Var[bool] = False
55+
hide_symbol: rx.Var[bool] = False
56+
copy_button_props: rx.Var[Optional[ButtonProps]]
57+
disable_animation: rx.Var[bool] = False
58+
59+
# Events
60+
on_copy: rx.EventHandler[lambda e: [e]]

0 commit comments

Comments
 (0)