Skip to content

Commit 99aeeaa

Browse files
authored
update some components (#70)
1 parent 728d5aa commit 99aeeaa

8 files changed

Lines changed: 130 additions & 33 deletions

File tree

reflex_ui/components/base/button.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"outline-shadow",
1919
"secondary",
2020
"ghost",
21+
"ghost-highlight",
2122
"link",
2223
"dark",
2324
]
@@ -33,9 +34,10 @@
3334
"primary-bordered": "bg-primary-9 text-primary-contrast hover:bg-primary-10 shadow-button-bordered disabled:shadow-none",
3435
"destructive": "bg-destructive-9 hover:bg-destructive-10 text-primary-contrast",
3536
"outline": "border border-secondary-a4 bg-secondary-1 hover:bg-secondary-3 text-secondary-12",
36-
"outline-shadow": "dark:border dark:border-secondary-a4 bg-white dark:bg-secondary-1 hover:bg-secondary-3 text-secondary-12 shadow-button-outline disabled:shadow-none",
37+
"outline-shadow": "dark:shadow-[0_1px_0_0_rgba(255,255,255,0.08)_inset] bg-white hover:bg-secondary-2 dark:bg-secondary-3 dark:hover:bg-secondary-4 text-secondary-12 shadow-button-outline disabled:shadow-none",
3738
"secondary": "bg-secondary-4 text-secondary-12 hover:bg-secondary-5",
3839
"ghost": "hover:bg-secondary-3 text-secondary-11",
40+
"ghost-highlight": "text-secondary-12 hover:text-primary-9",
3941
"link": "text-secondary-12 underline-offset-4 hover:underline",
4042
"dark": "bg-secondary-12 text-secondary-1 hover:bg-secondary-12/80",
4143
},

reflex_ui/components/base/button.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LiteralButtonVariant = Literal[
2222
"outline-shadow",
2323
"secondary",
2424
"ghost",
25+
"ghost-highlight",
2526
"link",
2627
"dark",
2728
]
@@ -35,9 +36,10 @@ BUTTON_VARIANTS = {
3536
"primary-bordered": "bg-primary-9 text-primary-contrast hover:bg-primary-10 shadow-button-bordered disabled:shadow-none",
3637
"destructive": "bg-destructive-9 hover:bg-destructive-10 text-primary-contrast",
3738
"outline": "border border-secondary-a4 bg-secondary-1 hover:bg-secondary-3 text-secondary-12",
38-
"outline-shadow": "dark:border dark:border-secondary-a4 bg-white dark:bg-secondary-1 hover:bg-secondary-3 text-secondary-12 shadow-button-outline disabled:shadow-none",
39+
"outline-shadow": "dark:shadow-[0_1px_0_0_rgba(255,255,255,0.08)_inset] bg-white hover:bg-secondary-2 dark:bg-secondary-3 dark:hover:bg-secondary-4 text-secondary-12 shadow-button-outline disabled:shadow-none",
3940
"secondary": "bg-secondary-4 text-secondary-12 hover:bg-secondary-5",
4041
"ghost": "hover:bg-secondary-3 text-secondary-11",
42+
"ghost-highlight": "text-secondary-12 hover:text-primary-9",
4143
"link": "text-secondary-12 underline-offset-4 hover:underline",
4244
"dark": "bg-secondary-12 text-secondary-1 hover:bg-secondary-12/80",
4345
},
@@ -71,6 +73,7 @@ class Button(BaseButton, CoreComponent):
7173
"dark",
7274
"destructive",
7375
"ghost",
76+
"ghost-highlight",
7477
"link",
7578
"outline",
7679
"outline-shadow",
@@ -83,6 +86,7 @@ class Button(BaseButton, CoreComponent):
8386
"dark",
8487
"destructive",
8588
"ghost",
89+
"ghost-highlight",
8690
"link",
8791
"outline",
8892
"outline-shadow",
@@ -359,6 +363,7 @@ class ButtonNamespace(ComponentNamespace):
359363
"dark",
360364
"destructive",
361365
"ghost",
366+
"ghost-highlight",
362367
"link",
363368
"outline",
364369
"outline-shadow",
@@ -371,6 +376,7 @@ class ButtonNamespace(ComponentNamespace):
371376
"dark",
372377
"destructive",
373378
"ghost",
379+
"ghost-highlight",
374380
"link",
375381
"outline",
376382
"outline-shadow",

reflex_ui/components/base/input.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Custom input component."""
22

3-
from typing import Literal
3+
from typing import ClassVar, Literal
44

55
from reflex.components.component import Component, ComponentNamespace
66
from reflex.components.el import Button, Div, Span
@@ -17,7 +17,7 @@
1717
"xs": "px-1.5 h-7 rounded-ui-xs gap-1.5",
1818
"sm": "px-2 h-8 rounded-ui-sm gap-2",
1919
"md": "px-2.5 h-9 rounded-ui-md gap-2",
20-
"lg": "px-3 h-10 rounded-lg gap-2.5",
20+
"lg": "px-3 h-10 rounded-ui-lg gap-2.5",
2121
"xl": "px-3.5 h-12 rounded-ui-xl gap-3",
2222
}
2323

@@ -34,8 +34,8 @@
3434
class ClassNames:
3535
"""Class names for input components."""
3636

37-
INPUT = "outline-none bg-transparent text-secondary-12 placeholder:text-secondary-9 text-sm leading-normal peer disabled:text-secondary-8 disabled:placeholder:text-secondary-8 w-full data-[disabled]:pointer-events-none font-medium"
38-
DIV = "flex flex-row items-center focus-within:shadow-[0px_0px_0px_2px_var(--primary-4)] focus-within:border-primary-a6 not-data-[invalid]:focus-within:hover:border-primary-a6 bg-secondary-1 shrink-0 border border-secondary-a4 hover:border-secondary-a6 transition-[color,box-shadow] text-secondary-9 [&_svg]:pointer-events-none has-data-[disabled]:border-secondary-4 has-data-[disabled]:bg-secondary-3 has-data-[disabled]:text-secondary-8 has-data-[disabled]:cursor-not-allowed cursor-text has-data-[invalid]:border-destructive-10 has-data-[invalid]:focus-within:border-destructive-a11 has-data-[invalid]:focus-within:shadow-[0px_0px_0px_2px_var(--destructive-4)] has-data-[invalid]:hover:border-destructive-a11"
37+
INPUT = "outline-none bg-transparent text-secondary-12 placeholder:text-secondary-10 text-sm leading-normal peer disabled:text-secondary-8 disabled:placeholder:text-secondary-8 w-full data-[disabled]:pointer-events-none font-medium"
38+
DIV = "flex flex-row items-center focus-within:shadow-[0px_0px_0px_2px_var(--primary-4)] focus-within:border-primary-a6 not-data-[invalid]:focus-within:hover:border-primary-a6 bg-white dark:bg-secondary-3 shrink-0 border border-secondary-4 hover:border-secondary-a6 transition-[color,box-shadow] text-secondary-9 [&_svg]:pointer-events-none has-data-[disabled]:border-secondary-4 has-data-[disabled]:bg-secondary-3 has-data-[disabled]:text-secondary-8 has-data-[disabled]:cursor-not-allowed cursor-text has-data-[invalid]:border-destructive-10 has-data-[invalid]:focus-within:border-destructive-a11 has-data-[invalid]:focus-within:shadow-[0px_0px_0px_2px_var(--destructive-4)] has-data-[invalid]:hover:border-destructive-a11 shadow-[0_1px_2px_0_rgba(0,0,0,0.02),0_1px_4px_0_rgba(0,0,0,0.02)] dark:shadow-none dark:border-secondary-5"
3939

4040

4141
class InputBaseComponent(BaseUIComponent):
@@ -74,7 +74,7 @@ class HighLevelInput(InputBaseComponent):
7474
icon: Var[str]
7575

7676
# Whether to show the clear button.
77-
show_clear_button: Var[bool]
77+
show_clear_button: ClassVar[bool]
7878

7979
# Events to fire when the clear button is clicked.
8080
clear_events: Var[list[EventHandler]]
@@ -132,20 +132,21 @@ def create(cls, *children, **props) -> BaseUIComponent:
132132
show_clear_button = props.pop("show_clear_button", True)
133133
clear_events = props.pop("clear_events", [])
134134
# Configure input with merged attributes
135+
custom_attrs_override = props.pop("custom_attrs", {})
135136
input_props.update(
136137
{
137138
"id": id,
138139
"custom_attrs": {
139140
**DEFAULT_INPUT_ATTRS,
140-
**input_props.get("custom_attrs", {}),
141+
**custom_attrs_override,
141142
},
142143
}
143144
)
144145

145146
return Div.create( # pyright: ignore[reportReturnType]
146147
(
147148
Span.create(
148-
hi(icon, class_name="text-secondary-9 size-4 pointer-events-none"),
149+
hi(icon, class_name="text-secondary-12 size-4 pointer-events-none"),
149150
aria_hidden="true",
150151
)
151152
if icon
@@ -171,7 +172,7 @@ def _create_clear_button(id: str, clear_events: list[EventHandler]) -> Button:
171172
*clear_events,
172173
],
173174
tab_index=-1,
174-
class_name="opacity-100 peer-placeholder-shown:opacity-0 hover:text-secondary-12 transition-colors peer-placeholder-shown:pointer-events-none peer-disabled:pointer-events-none peer-disabled:opacity-0 h-full",
175+
class_name="opacity-100 peer-placeholder-shown:opacity-0 hover:text-secondary-12 transition-colors peer-placeholder-shown:pointer-events-none peer-disabled:pointer-events-none peer-disabled:opacity-0 h-full text-secondary-11",
175176
)
176177

177178
def _exclude_props(self) -> list[str]:

reflex_ui/components/base/input.pyi

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file was generated by `reflex/utils/pyi_generator.py`!
55
# ------------------------------------------------------
66
from collections.abc import Mapping, Sequence
7-
from typing import Any, Literal
7+
from typing import Any, ClassVar, Literal
88

99
from reflex.components.component import Component, ComponentNamespace
1010
from reflex.components.core.breakpoints import Breakpoints
@@ -18,7 +18,7 @@ INPUT_SIZE_VARIANTS = {
1818
"xs": "px-1.5 h-7 rounded-ui-xs gap-1.5",
1919
"sm": "px-2 h-8 rounded-ui-sm gap-2",
2020
"md": "px-2.5 h-9 rounded-ui-md gap-2",
21-
"lg": "px-3 h-10 rounded-lg gap-2.5",
21+
"lg": "px-3 h-10 rounded-ui-lg gap-2.5",
2222
"xl": "px-3.5 h-12 rounded-ui-xl gap-3",
2323
}
2424
LiteralControlSize = Literal["xs", "sm", "md", "lg", "xl"]
@@ -30,8 +30,8 @@ DEFAULT_INPUT_ATTRS = {
3030
}
3131

3232
class ClassNames:
33-
INPUT = "outline-none bg-transparent text-secondary-12 placeholder:text-secondary-9 text-sm leading-normal peer disabled:text-secondary-8 disabled:placeholder:text-secondary-8 w-full data-[disabled]:pointer-events-none font-medium"
34-
DIV = "flex flex-row items-center focus-within:shadow-[0px_0px_0px_2px_var(--primary-4)] focus-within:border-primary-a6 not-data-[invalid]:focus-within:hover:border-primary-a6 bg-secondary-1 shrink-0 border border-secondary-a4 hover:border-secondary-a6 transition-[color,box-shadow] text-secondary-9 [&_svg]:pointer-events-none has-data-[disabled]:border-secondary-4 has-data-[disabled]:bg-secondary-3 has-data-[disabled]:text-secondary-8 has-data-[disabled]:cursor-not-allowed cursor-text has-data-[invalid]:border-destructive-10 has-data-[invalid]:focus-within:border-destructive-a11 has-data-[invalid]:focus-within:shadow-[0px_0px_0px_2px_var(--destructive-4)] has-data-[invalid]:hover:border-destructive-a11"
33+
INPUT = "outline-none bg-transparent text-secondary-12 placeholder:text-secondary-10 text-sm leading-normal peer disabled:text-secondary-8 disabled:placeholder:text-secondary-8 w-full data-[disabled]:pointer-events-none font-medium"
34+
DIV = "flex flex-row items-center focus-within:shadow-[0px_0px_0px_2px_var(--primary-4)] focus-within:border-primary-a6 not-data-[invalid]:focus-within:hover:border-primary-a6 bg-white dark:bg-secondary-3 shrink-0 border border-secondary-4 hover:border-secondary-a6 transition-[color,box-shadow] text-secondary-9 [&_svg]:pointer-events-none has-data-[disabled]:border-secondary-4 has-data-[disabled]:bg-secondary-3 has-data-[disabled]:text-secondary-8 has-data-[disabled]:cursor-not-allowed cursor-text has-data-[invalid]:border-destructive-10 has-data-[invalid]:focus-within:border-destructive-a11 has-data-[invalid]:focus-within:shadow-[0px_0px_0px_2px_var(--destructive-4)] has-data-[invalid]:hover:border-destructive-a11 shadow-[0_1px_2px_0_rgba(0,0,0,0.02),0_1px_4px_0_rgba(0,0,0,0.02)] dark:shadow-none dark:border-secondary-5"
3535

3636
class InputBaseComponent(BaseUIComponent):
3737
@property
@@ -400,6 +400,8 @@ class InputRoot(InputBaseComponent, ReflexInput):
400400
"""Create a high level input component with simplified API."""
401401

402402
class HighLevelInput(InputBaseComponent):
403+
show_clear_button: ClassVar[bool]
404+
403405
@classmethod
404406
def create(
405407
cls,
@@ -408,7 +410,7 @@ class HighLevelInput(InputBaseComponent):
408410
| Var[Literal["lg", "md", "sm", "xl", "xs"]]
409411
| None = None,
410412
icon: Var[str] | str | None = None,
411-
show_clear_button: Var[bool] | bool | None = None,
413+
show_clear_button: ClassVar[bool] | None = None,
412414
clear_events: Var[list[EventHandler]] | list[EventHandler] | None = None,
413415
unstyled: Var[bool] | bool | None = None,
414416
style: Sequence[Mapping[str, Any]]
@@ -452,7 +454,7 @@ class Input(ComponentNamespace):
452454
| Var[Literal["lg", "md", "sm", "xl", "xs"]]
453455
| None = None,
454456
icon: Var[str] | str | None = None,
455-
show_clear_button: Var[bool] | bool | None = None,
457+
show_clear_button: ClassVar[bool] | None = None,
456458
clear_events: Var[list[EventHandler]] | list[EventHandler] | None = None,
457459
unstyled: Var[bool] | bool | None = None,
458460
style: Sequence[Mapping[str, Any]]

reflex_ui/components/base/tabs.py

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,34 @@
1010
from reflex_ui.components.base_ui import PACKAGE_NAME, BaseUIComponent
1111

1212
LiteralOrientation = Literal["horizontal", "vertical"]
13+
LiteralTabsSize = Literal["sm", "md", "lg"]
1314

1415

1516
class ClassNames:
1617
"""Class names for tabs components."""
1718

1819
ROOT = "flex flex-col gap-2"
19-
LIST = "bg-secondary-3 inline-flex gap-1 p-1 items-center justify-start rounded-ui-md relative z-0"
20-
TAB = "h-7 px-1.5 rounded-ui-sm justify-center items-center gap-1.5 inline-flex text-sm font-medium text-secondary-11 cursor-pointer z-[1] hover:text-secondary-12 transition-color text-nowrap data-[active]:text-secondary-12 data-[disabled]:cursor-not-allowed data-[disabled]:text-secondary-8"
21-
INDICATOR = "absolute top-1/2 left-0 -z-1 h-7 w-(--active-tab-width) -translate-y-1/2 translate-x-(--active-tab-left) rounded-ui-sm bg-secondary-1 shadow-small transition-all duration-200 ease-in-out"
20+
LIST = "bg-secondary-1 inline-flex items-center justify-start relative z-0 shadow-button-outline dark:border dark:border-secondary-4"
21+
TAB = "justify-center items-center inline-flex font-medium text-secondary-11 cursor-pointer z-[1] hover:text-primary-9 transition-color text-nowrap data-[active]:text-secondary-12 data-[disabled]:cursor-not-allowed data-[disabled]:text-secondary-8 text-sm"
22+
INDICATOR = "absolute left-0 inset-y-0 my-0.5 -z-1 w-(--active-tab-width) translate-x-(--active-tab-left) transition-all duration-200 ease-in-out dark:shadow-[0_1px_0_0_rgba(255,255,255,0.08)_inset] bg-white dark:bg-secondary-3 text-secondary-12 shadow-button-outline"
2223
PANEL = "flex flex-col gap-2"
24+
SIZES = {
25+
"list": {
26+
"sm": "p-0.5 rounded-ui-md gap-0.5",
27+
"md": "p-0.5 rounded-ui-md gap-0.5",
28+
"lg": "p-0.5 rounded-ui-md gap-0.5",
29+
},
30+
"tab": {
31+
"sm": "h-7 px-1.5 rounded-ui-sm gap-1",
32+
"md": "h-8 px-2 rounded-ui-sm gap-1.5",
33+
"lg": "h-9 px-2.5 rounded-ui-sm gap-2",
34+
},
35+
"indicator": {
36+
"sm": "rounded-ui-sm",
37+
"md": "rounded-ui-sm",
38+
"lg": "rounded-ui-sm",
39+
},
40+
}
2341

2442

2543
class TabsBaseComponent(BaseUIComponent):
@@ -72,13 +90,24 @@ class TabsList(TabsBaseComponent):
7290
# Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. Defaults to True.
7391
loop_focus: Var[bool]
7492

93+
# The size of the tabs list. Defaults to "sm".
94+
size: Var[LiteralTabsSize]
95+
7596
@classmethod
7697
def create(cls, *children, **props) -> BaseUIComponent:
77-
"""Create the tabs list component."""
98+
"""Create the tabs list component.
99+
100+
Returns:
101+
The component.
102+
"""
103+
size = props.pop("size", "sm")
78104
props["data-slot"] = "tabs-list"
79-
cls.set_class_name(ClassNames.LIST, props)
105+
cls.set_class_name(f"{ClassNames.LIST} {ClassNames.SIZES['list'][size]}", props)
80106
return super().create(*children, **props)
81107

108+
def _exclude_props(self) -> list[str]:
109+
return [*super()._exclude_props(), "size"]
110+
82111

83112
class TabsTab(TabsBaseComponent):
84113
"""An individual interactive tab button that toggles the corresponding panel. Renders a <button> element."""
@@ -97,13 +126,24 @@ class TabsTab(TabsBaseComponent):
97126
# The render prop
98127
render_: Var[Component]
99128

129+
# The size of the tab. Defaults to "sm".
130+
size: Var[LiteralTabsSize]
131+
100132
@classmethod
101133
def create(cls, *children, **props) -> BaseUIComponent:
102-
"""Create the tabs tab component."""
134+
"""Create the tabs tab component.
135+
136+
Returns:
137+
The component.
138+
"""
139+
size = props.pop("size", "sm")
103140
props["data-slot"] = "tabs-tab"
104-
cls.set_class_name(ClassNames.TAB, props)
141+
cls.set_class_name(f"{ClassNames.TAB} {ClassNames.SIZES['tab'][size]}", props)
105142
return super().create(*children, **props)
106143

144+
def _exclude_props(self) -> list[str]:
145+
return [*super()._exclude_props(), "size"]
146+
107147

108148
class TabsIndicator(TabsBaseComponent):
109149
"""A visual indicator that can be styled to match the position of the currently active tab. Renders a <span> element."""
@@ -116,13 +156,26 @@ class TabsIndicator(TabsBaseComponent):
116156
# The render prop
117157
render_: Var[Component]
118158

159+
# The size of the indicator. Defaults to "sm".
160+
size: Var[LiteralTabsSize]
161+
119162
@classmethod
120163
def create(cls, *children, **props) -> BaseUIComponent:
121-
"""Create the tabs indicator component."""
164+
"""Create the tabs indicator component.
165+
166+
Returns:
167+
The component.
168+
"""
169+
size = props.pop("size", "sm")
122170
props["data-slot"] = "tabs-indicator"
123-
cls.set_class_name(ClassNames.INDICATOR, props)
171+
cls.set_class_name(
172+
f"{ClassNames.INDICATOR} {ClassNames.SIZES['indicator'][size]}", props
173+
)
124174
return super().create(*children, **props)
125175

176+
def _exclude_props(self) -> list[str]:
177+
return [*super()._exclude_props(), "size"]
178+
126179

127180
class TabsPanel(TabsBaseComponent):
128181
"""A panel displayed when the corresponding tab is active. Renders a <div> element."""

0 commit comments

Comments
 (0)