Skip to content

Commit 69e29ec

Browse files
authored
ENG-6160: Select component (#5)
1 parent c93a502 commit 69e29ec

File tree

10 files changed

+614
-33
lines changed

10 files changed

+614
-33
lines changed

demo/assets/css/globals.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
--warning-a11: var(--amber-a11);
153153
--warning-a12: var(--amber-a12);
154154
/* Radius */
155-
--radius: 0.625rem;
155+
--radius: 0.5rem;
156156
/* Font */
157157
--font-sans: "Instrument Sans", sans-serif;
158158
--font-mono: "JetBrains Mono", monospace;
@@ -1099,12 +1099,12 @@
10991099
0px -8px 8px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0)),
11001100
0px -2px 6px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0));
11011101
/* Radius */
1102-
--radius-xs: calc(var(--radius) - 0.375rem);
1103-
--radius-sm: calc(var(--radius) - 0.25rem);
1104-
--radius-md: calc(var(--radius) - 0.125rem);
1105-
--radius-lg: var(--radius);
1106-
--radius-xl: calc(var(--radius) + 0.125rem);
1107-
--radius-2xl: calc(var(--radius) + 0.25rem);
1102+
--radius-xs: calc(var(--radius) - 0.125rem);
1103+
--radius-sm: var(--radius);
1104+
--radius-md: calc(var(--radius) + 0.125rem);
1105+
--radius-lg: calc(var(--radius) + 0.25rem);
1106+
--radius-xl: calc(var(--radius) + 0.375rem);
1107+
--radius-2xl: calc(var(--radius) + 0.5rem);
11081108
}
11091109

11101110
@layer base {
@@ -1128,7 +1128,7 @@
11281128
}
11291129

11301130
* {
1131-
@apply border-secondary-5 outline-primary-5 font-sans;
1131+
@apply border-secondary-6 outline-primary-6 font-sans;
11321132
}
11331133

11341134
body {

demo/demo/demo.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,27 @@ def index() -> rx.Component:
1616
position="top-center",
1717
),
1818
),
19+
ui.select(
20+
items=[
21+
"Item 1",
22+
"Item 2",
23+
"Item 3",
24+
"Item 4",
25+
"Item 5",
26+
"Item 6",
27+
"Item 7",
28+
"Item 8",
29+
"Item 9",
30+
"Item 10",
31+
],
32+
name="select",
33+
placeholder="Select an item",
34+
on_value_change=lambda value: rx.toast.success(f"Value: {value}"),
35+
on_open_change=lambda value: rx.toast.success(f"Open: {value}"),
36+
),
1937
ui.theme_switcher(class_name="absolute top-4 right-4"),
2038
class_name=ui.cn(
21-
"flex flex-col items-center justify-center h-screen", "bg-secondary-1"
39+
"flex flex-col gap-4 items-center justify-center h-screen", "bg-secondary-1"
2240
),
2341
)
2442

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.1"
44
description = "A set of reusable components built on top of Base UI and Tailwind, designed for use across any Reflex project"
55
readme = "README.md"
66
requires-python = ">=3.13"
7-
dependencies = ["reflex>=0.7.14"]
7+
dependencies = ["reflex>=0.8.0a4"]
88

99
[build-system]
1010
requires = ["hatchling", "uv-dynamic-versioning"]
@@ -63,4 +63,4 @@ lint.ignore = [
6363
"TRY0",
6464
"UP038",
6565
]
66-
lint.pydocstyle.convention = "google"
66+
lint.pydocstyle.convention = "google"

reflex_ui/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
_REFLEX_UI_MAPPING = {
66
"components.base.avatar": ["avatar"],
7-
"components.base.button": ["button"],
87
"components.base.badge": ["badge"],
8+
"components.base.button": ["button"],
9+
"components.base.select": ["select"],
910
"components.base.theme_switcher": ["theme_switcher"],
1011
}
1112

reflex_ui/components/base/avatar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Custom avatar component."""
22

33
from reflex.components.component import Component, ComponentNamespace
4-
from reflex.event import EventHandler, no_args_event_spec
4+
from reflex.event import EventHandler, passthrough_event_spec
55
from reflex.utils.imports import ImportVar
66
from reflex.vars import Var
77

@@ -51,7 +51,7 @@ class AvatarImage(AvatarBaseComponent):
5151
src: Var[str]
5252

5353
# Callback when loading status changes
54-
on_loading_status_change: EventHandler[no_args_event_spec]
54+
on_loading_status_change: EventHandler[passthrough_event_spec(str)]
5555

5656
# The component to render
5757
render_: Var[Component]
@@ -88,7 +88,7 @@ class HighLevelAvatar(AvatarRoot):
8888
src: Var[str]
8989

9090
# Callback when loading status changes
91-
on_loading_status_change: EventHandler[no_args_event_spec]
91+
on_loading_status_change: EventHandler[passthrough_event_spec(str)]
9292

9393
# How long to wait before showing the fallback. Specified in milliseconds
9494
delay: Var[int]

reflex_ui/components/base/button.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@
2020
"variant": {
2121
"primary": "bg-primary-9 text-white hover:bg-primary-10",
2222
"destructive": "bg-destructive-9 hover:bg-destructive-10 text-white",
23-
"outline": "border border-secondary-5/80 hover:bg-border-secondary-6/80 bg-secondary-1 hover:bg-secondary-3 text-secondary-12",
23+
"outline": "border border-secondary-a4 bg-secondary-1 hover:bg-secondary-3 text-secondary-12",
2424
"secondary": "bg-secondary-4 text-secondary-12 hover:bg-secondary-5",
2525
"ghost": "hover:bg-secondary-3 text-secondary-12",
2626
"link": "text-secondary-12 underline-offset-4 hover:underline",
2727
"dark": "bg-secondary-12 text-secondary-1 hover:bg-secondary-12/80",
2828
},
2929
"size": {
30-
"xs": "px-1.5 h-7 rounded-sm gap-1.5",
31-
"sm": "px-2 h-8 rounded-lg gap-2",
32-
"md": "px-2.5 h-9 rounded-lg gap-2",
33-
"lg": "px-3 h-10 rounded-xl gap-2.5",
34-
"xl": "px-3.5 h-12 rounded-2xl gap-3",
35-
"icon-xs": "size-7 rounded-md",
36-
"icon-sm": "size-8 rounded-md",
37-
"icon-md": "size-9 rounded-lg",
38-
"icon-lg": "size-10 rounded-xl",
39-
"icon-xl": "size-12 rounded-2xl",
30+
"xs": "px-1.5 h-7 rounded-xs gap-1.5",
31+
"sm": "px-2 h-8 rounded-sm gap-2",
32+
"md": "px-2.5 h-9 rounded-md gap-2",
33+
"lg": "px-3 h-10 rounded-lg gap-2.5",
34+
"xl": "px-3.5 h-12 rounded-xl gap-3",
35+
"icon-xs": "size-7 rounded-xs",
36+
"icon-sm": "size-8 rounded-sm",
37+
"icon-md": "size-9 rounded-md",
38+
"icon-lg": "size-10 rounded-lg",
39+
"icon-xl": "size-12 rounded-xl",
4040
},
4141
}
4242

4343

4444
class Button(BaseButton, CoreComponent):
4545
"""A custom button component."""
4646

47-
# Button variant
47+
# Button variant. Defaults to "primary".
4848
variant: Var[LiteralButtonVariant]
4949

50-
# Button size
50+
# Button size. Defaults to "md".
5151
size: Var[LiteralButtonSize]
5252

5353
# The loading state of the button

0 commit comments

Comments
 (0)