Skip to content

Commit d3a04ac

Browse files
authored
some changes (#30)
1 parent 8863931 commit d3a04ac

File tree

9 files changed

+120
-15
lines changed

9 files changed

+120
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "reflex-ui"
33
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"
6-
requires-python = ">=3.13"
6+
requires-python = ">=3.12"
77
dependencies = ["reflex (>=0.8.0)"]
88

99
[build-system]

reflex_ui/components/base/card.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ def create(cls, *children, **props):
106106
footer = props.pop("footer", "")
107107

108108
return CardRoot.create(
109-
CardHeader.create(
110-
CardTitle.create(title) if title else None,
111-
CardDescription.create(description) if description else None,
109+
(
110+
CardHeader.create(
111+
CardTitle.create(title) if title else None,
112+
CardDescription.create(description) if description else None,
113+
)
114+
if title or description
115+
else None
112116
),
113117
CardContent.create(content) if content else None,
114118
CardFooter.create(footer) if footer else None,

reflex_ui/components/base/link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def create(cls, *children, **props) -> ReactRouterLink:
6868
children.append(
6969
hi(
7070
"LinkSquare02Icon",
71-
class_name="absolute top-1/2 -translate-y-1/2 right-[-1.375rem] group-hover/link:opacity-100 text-secondary-9 opacity-0",
71+
class_name="absolute top-1/2 -translate-y-1/2 right-[-1.25rem] group-hover/link:opacity-100 text-secondary-9 opacity-0",
7272
),
7373
)
7474

reflex_ui/components/base/menu.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ def create(cls, *children, **props) -> BaseUIComponent:
529529
class HighLevelMenu(MenuRoot):
530530
"""High level wrapper for the Menu component."""
531531

532+
# The trigger component to use for the menu
533+
trigger: Var[Component | None]
534+
532535
# The list of items to display in the menu dropdown - can be strings or tuples of (label, on_click_handler)
533536
items: Var[list[str | tuple[str, EventHandler]]]
534537

@@ -577,6 +580,7 @@ def create(cls, *children, **props) -> BaseUIComponent:
577580
}
578581
portal_props = {k: props.pop(k) for k in cls._portal_props & props.keys()}
579582

583+
trigger = props.pop("trigger", None)
580584
items = props.pop("items", [])
581585
size = trigger_props.get("size", "md")
582586
trigger_label = trigger_props.get("placeholder", "Open Menu")
@@ -593,6 +597,7 @@ def create_menu_item(item: str | tuple[str, EventHandler]) -> BaseUIComponent:
593597
on_click=on_click_handler,
594598
size=size,
595599
),
600+
key=label,
596601
**item_props,
597602
)
598603
return MenuItem.create(
@@ -603,6 +608,7 @@ def create_menu_item(item: str | tuple[str, EventHandler]) -> BaseUIComponent:
603608
disabled=props.get("disabled", False),
604609
size=size,
605610
),
611+
key=item,
606612
**item_props,
607613
)
608614

@@ -613,13 +619,17 @@ def create_menu_item(item: str | tuple[str, EventHandler]) -> BaseUIComponent:
613619

614620
return MenuRoot.create(
615621
MenuTrigger.create(
616-
render_=button(
617-
trigger_label,
618-
select_arrow(class_name="size-4 text-secondary-9"),
619-
variant="outline",
620-
class_name=ClassNames.TRIGGER,
621-
disabled=props.get("disabled", False),
622-
size=size,
622+
render_=(
623+
trigger
624+
if trigger
625+
else button(
626+
trigger_label,
627+
select_arrow(class_name="size-4 text-secondary-9"),
628+
variant="outline",
629+
class_name=ClassNames.TRIGGER,
630+
disabled=props.get("disabled", False),
631+
size=size,
632+
)
623633
),
624634
),
625635
MenuPortal.create(

reflex_ui/components/base/menu.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ class HighLevelMenu(MenuRoot):
846846
def create(
847847
cls,
848848
*children,
849+
trigger: Component | Var[Component | None] | None = None,
849850
items: Var[list[str | tuple[str, EventHandler]]]
850851
| list[str | tuple[str, EventHandler]]
851852
| None = None,
@@ -905,6 +906,7 @@ class HighLevelMenu(MenuRoot):
905906
906907
Args:
907908
*children: Additional children to include in the menu.
909+
trigger: The trigger component to use for the menu
908910
items: The list of items to display in the menu dropdown - can be strings or tuples of (label, on_click_handler)
909911
placeholder: The placeholder text to display when no item is selected
910912
size: The size of the menu. Defaults to "md".
@@ -957,6 +959,7 @@ class Menu(ComponentNamespace):
957959
@staticmethod
958960
def __call__(
959961
*children,
962+
trigger: Component | Var[Component | None] | None = None,
960963
items: Var[list[str | tuple[str, EventHandler]]]
961964
| list[str | tuple[str, EventHandler]]
962965
| None = None,
@@ -1016,6 +1019,7 @@ class Menu(ComponentNamespace):
10161019
10171020
Args:
10181021
*children: Additional children to include in the menu.
1022+
trigger: The trigger component to use for the menu
10191023
items: The list of items to display in the menu dropdown - can be strings or tuples of (label, on_click_handler)
10201024
placeholder: The placeholder text to display when no item is selected
10211025
size: The size of the menu. Defaults to "md".

reflex_ui/components/base/select.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ def create(cls, *children, **props) -> BaseUIComponent:
478478
disabled=props.get("disabled", False),
479479
),
480480
value=item,
481+
key=item,
481482
),
482483
)
483484
else:
@@ -496,6 +497,7 @@ def create(cls, *children, **props) -> BaseUIComponent:
496497
class_name=ClassNames.ITEM,
497498
),
498499
value=item,
500+
key=item,
499501
)
500502
for item in items
501503
]

reflex_ui/components/base/tooltip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ClassNames:
2121
"""Class names for tooltip components."""
2222

2323
TRIGGER = "inline-flex items-center justify-center"
24-
POPUP = "z-50 rounded-sm bg-secondary-12 px-3 py-1.5 text-balance text-sm font-medium text-secondary-1 shadow-small transition-all duration-150 data-[ending-style]:scale-90 data-[ending-style]:opacity-0 data-[starting-style]:scale-90 data-[starting-style]:opacity-0"
24+
POPUP = "z-50 rounded-sm bg-secondary-12 px-2.5 py-1.5 text-balance text-sm font-medium text-secondary-1 shadow-small transition-all duration-150 data-[ending-style]:scale-90 data-[ending-style]:opacity-0 data-[starting-style]:scale-90 data-[starting-style]:opacity-0"
2525
ARROW = "data-[side=bottom]:top-[-7.5px] data-[side=left]:right-[-12.5px] data-[side=left]:rotate-90 data-[side=right]:left-[-12.5px] data-[side=right]:-rotate-90 data-[side=top]:bottom-[-7.5px] data-[side=top]:rotate-180"
2626

2727

reflex_ui/components/base/tooltip.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LiteralTrackCursorAxis = Literal["none", "bottom", "x", "y"]
2020

2121
class ClassNames:
2222
TRIGGER = "inline-flex items-center justify-center"
23-
POPUP = "z-50 rounded-sm bg-secondary-12 px-3 py-1.5 text-balance text-sm font-medium text-secondary-1 shadow-small transition-all duration-150 data-[ending-style]:scale-90 data-[ending-style]:opacity-0 data-[starting-style]:scale-90 data-[starting-style]:opacity-0"
23+
POPUP = "z-50 rounded-sm bg-secondary-12 px-2.5 py-1.5 text-balance text-sm font-medium text-secondary-1 shadow-small transition-all duration-150 data-[ending-style]:scale-90 data-[ending-style]:opacity-0 data-[starting-style]:scale-90 data-[starting-style]:opacity-0"
2424
ARROW = "data-[side=bottom]:top-[-7.5px] data-[side=left]:right-[-12.5px] data-[side=left]:rotate-90 data-[side=right]:left-[-12.5px] data-[side=right]:-rotate-90 data-[side=top]:bottom-[-7.5px] data-[side=top]:rotate-180"
2525

2626
class TooltipBaseComponent(BaseUIComponent):

0 commit comments

Comments
 (0)