Skip to content

Commit 585d813

Browse files
committed
fixes
1 parent 996bb95 commit 585d813

File tree

9 files changed

+678
-118
lines changed

9 files changed

+678
-118
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ repos:
1717
files: ^reflex_ui/
1818

1919
# Run pyi check before pyright because pyright can fail if pyi files are wrong.
20-
# - repo: local
21-
# hooks:
22-
# - id: update-pyi-files
23-
# name: update-pyi-files
24-
# always_run: true
25-
# language: system
26-
# require_serial: true
27-
# description: "Update pyi files as needed"
28-
# entry: python3 scripts/make_pyi.py
20+
- repo: local
21+
hooks:
22+
- id: update-pyi-files
23+
name: update-pyi-files
24+
always_run: true
25+
language: system
26+
require_serial: true
27+
description: "Update pyi files as needed"
28+
entry: python3 scripts/make_pyi.py
2929

3030
- repo: https://github.com/RobertCraigie/pyright-python
3131
rev: v1.1.403

demo/demo/demo.py

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -58,93 +58,6 @@ def index() -> rx.Component:
5858
on_value_change=lambda value: rx.toast.success(f"Value: {value}"),
5959
on_open_change=lambda value: rx.toast.success(f"Open: {value}"),
6060
),
61-
ui.navigation_menu.root(
62-
ui.navigation_menu.list(
63-
ui.navigation_menu.item(
64-
ui.navigation_menu.trigger(
65-
"Overview",
66-
ui.navigation_menu.icon("▼"),
67-
),
68-
ui.navigation_menu.content(
69-
rx.el.ul(
70-
rx.el.li(
71-
ui.navigation_menu.link(
72-
rx.el.h3("Quick Start", class_name="font-medium text-sm"),
73-
rx.el.p("Install and assemble your first component.", class_name="text-xs text-secondary-11"),
74-
href="/quick-start",
75-
on_click=lambda: rx.toast.success("Quick Start clicked"),
76-
class_name="block p-3 rounded hover:bg-secondary-3",
77-
)
78-
),
79-
rx.el.li(
80-
ui.navigation_menu.link(
81-
rx.el.h3("Accessibility", class_name="font-medium text-sm"),
82-
rx.el.p("Learn how we build accessible components.", class_name="text-xs text-secondary-11"),
83-
href="/accessibility",
84-
on_click=lambda: rx.toast.success("Accessibility clicked"),
85-
class_name="block p-3 rounded hover:bg-secondary-3",
86-
)
87-
),
88-
rx.el.li(
89-
ui.navigation_menu.link(
90-
rx.el.h3("Releases", class_name="font-medium text-sm"),
91-
rx.el.p("See what's new in the latest versions.", class_name="text-xs text-secondary-11"),
92-
href="/releases",
93-
on_click=lambda: rx.toast.success("Releases clicked"),
94-
class_name="block p-3 rounded hover:bg-secondary-3",
95-
)
96-
),
97-
class_name="grid grid-cols-2 gap-2 w-96 p-2",
98-
)
99-
),
100-
),
101-
ui.navigation_menu.item(
102-
ui.navigation_menu.trigger(
103-
"Handbook",
104-
ui.navigation_menu.icon("▼"),
105-
),
106-
ui.navigation_menu.content(
107-
rx.el.ul(
108-
rx.el.li(
109-
ui.navigation_menu.link(
110-
rx.el.h3("Styling", class_name="font-medium text-sm"),
111-
rx.el.p("Components can be styled with CSS, Tailwind, or CSS-in-JS.", class_name="text-xs text-secondary-11"),
112-
href="/styling",
113-
on_click=lambda: rx.toast.success("Styling clicked"),
114-
class_name="block p-3 rounded hover:bg-secondary-3",
115-
)
116-
),
117-
rx.el.li(
118-
ui.navigation_menu.link(
119-
rx.el.h3("Animation", class_name="font-medium text-sm"),
120-
rx.el.p("Components can be animated with CSS or JavaScript.", class_name="text-xs text-secondary-11"),
121-
href="/animation",
122-
on_click=lambda: rx.toast.success("Animation clicked"),
123-
class_name="block p-3 rounded hover:bg-secondary-3",
124-
)
125-
),
126-
class_name="flex flex-col gap-2 w-80 p-2",
127-
)
128-
),
129-
),
130-
ui.navigation_menu.item(
131-
ui.navigation_menu.link(
132-
"GitHub",
133-
href="https://github.com/reflex-dev/reflex-ui",
134-
on_click=lambda: rx.toast.success("GitHub clicked"),
135-
),
136-
),
137-
),
138-
ui.navigation_menu.portal(
139-
ui.navigation_menu.positioner(
140-
ui.navigation_menu.popup(
141-
ui.navigation_menu.arrow(),
142-
ui.navigation_menu.viewport(),
143-
),
144-
side_offset=10,
145-
),
146-
),
147-
),
14861
ui.theme_switcher(class_name="absolute top-4 right-4"),
14962
class_name=ui.cn(
15063
"flex flex-col gap-6 items-center justify-center h-screen", "bg-secondary-1"

pyproject.toml

Lines changed: 1 addition & 1 deletion
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.8.1"]
7+
dependencies = ["reflex>=0.8.2"]
88

99
[build-system]
1010
requires = ["hatchling", "uv-dynamic-versioning"]

reflex_ui/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from .components.base.gradient_profile import gradient_profile
1515
from .components.base.input import input
1616
from .components.base.link import link
1717
from .components.base.menu import menu
18+
from .components.base.navigation_menu import navigation_menu
1819
from .components.base.popover import popover
1920
from .components.base.scroll_area import scroll_area
2021
from .components.base.select import select
@@ -41,6 +42,7 @@ _REFLEX_UI_MAPPING = {
4142
"components.base.input": ["input"],
4243
"components.base.link": ["link"],
4344
"components.base.menu": ["menu"],
45+
"components.base.navigation_menu": ["navigation_menu"],
4446
"components.base.popover": ["popover"],
4547
"components.base.scroll_area": ["scroll_area"],
4648
"components.base.select": ["select"],
@@ -78,6 +80,7 @@ __all__ = [
7880
"input",
7981
"link",
8082
"menu",
83+
"navigation_menu",
8184
"popover",
8285
"scroll_area",
8386
"select",

reflex_ui/components/base/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from .gradient_profile import gradient_profile
1515
from .input import input
1616
from .link import link
1717
from .menu import menu
18+
from .navigation_menu import navigation_menu
1819
from .popover import popover
1920
from .scroll_area import scroll_area
2021
from .select import select
@@ -43,6 +44,7 @@ __all__ = [
4344
"input",
4445
"link",
4546
"menu",
47+
"navigation_menu",
4648
"popover",
4749
"scroll_area",
4850
"select",

reflex_ui/components/base/navigation_menu.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
class ClassNames:
2020
"""Class names for navigation menu components."""
2121

22-
ROOT = "relative"
23-
LIST = "flex items-center gap-1"
22+
ROOT = "min-w-max rounded-lg bg-secondary-1 p-1 text-secondary-12"
23+
LIST = "relative flex"
2424
ITEM = "relative"
25-
TRIGGER = "flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md hover:bg-secondary-3 focus:outline-none focus-visible:ring-1 focus-visible:ring-primary-4 cursor-pointer select-none transition-colors"
26-
CONTENT = "absolute top-full left-0 mt-2 min-w-64 origin-top-left border border-secondary-a4 bg-secondary-1 shadow-large rounded-lg p-2 z-50 transition-[transform,scale,opacity] data-[ending-style]:scale-95 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"
27-
LINK = "block px-3 py-2 text-sm text-secondary-12 hover:bg-secondary-3 rounded-md cursor-pointer select-none outline-none focus:bg-secondary-3 transition-colors"
28-
ICON = "size-4 text-secondary-10 transition-transform data-[popup-open]:rotate-180"
29-
PORTAL = "relative"
30-
POSITIONER = "outline-none"
31-
POPUP = "outline-none"
32-
VIEWPORT = "relative overflow-hidden rounded-lg"
33-
ARROW = "fill-secondary-1 stroke-secondary-a4 data-[side=bottom]:top-[-8px] data-[side=left]:right-[-13px] data-[side=left]:rotate-90 data-[side=right]:left-[-13px] data-[side=right]:-rotate-90 data-[side=top]:bottom-[-8px] data-[side=top]:rotate-180"
25+
TRIGGER = "box-border flex items-center justify-center gap-1.5 h-10 px-2 xs:px-3.5 m-0 rounded-md bg-secondary-1 text-secondary-12 font-medium text-[0.925rem] xs:text-base leading-6 select-none no-underline hover:bg-secondary-3 active:bg-secondary-3 data-[popup-open]:bg-secondary-3 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary-4"
26+
CONTENT = "w-max max-w-[calc(100vw-40px)] sm:max-w-[600px] p-6 transition-[opacity,transform,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] data-[starting-style]:opacity-0 data-[ending-style]:opacity-0 data-[starting-style]:data-[activation-direction=left]:translate-x-[-50%] data-[starting-style]:data-[activation-direction=right]:translate-x-[50%] data-[ending-style]:data-[activation-direction=left]:translate-x-[50%] data-[ending-style]:data-[activation-direction=right]:translate-x-[-50%]"
27+
LINK = "block rounded-md p-2 xs:p-3 no-underline text-inherit hover:bg-secondary-3 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary-4"
28+
ICON = "transition-transform duration-200 ease-in-out data-[popup-open]:rotate-180 text-secondary-10"
29+
PORTAL = ""
30+
POSITIONER = "box-border h-[var(--positioner-height)] w-[var(--positioner-width)] max-w-[var(--available-width)] transition-[top,left,right,bottom] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] before:absolute before:content-[''] data-[instant]:transition-none data-[side=bottom]:before:top-[-10px] data-[side=bottom]:before:right-0 data-[side=bottom]:before:left-0 data-[side=bottom]:before:h-2.5 data-[side=left]:before:top-0 data-[side=left]:before:right-[-10px] data-[side=left]:before:bottom-0 data-[side=left]:before:w-2.5 data-[side=right]:before:top-0 data-[side=right]:before:bottom-0 data-[side=right]:before:left-[-10px] data-[side=right]:before:w-2.5 data-[side=top]:before:right-0 data-[side=top]:before:bottom-[-10px] data-[side=top]:before:left-0 data-[side=top]:before:h-2.5"
31+
POPUP = "relative h-[var(--popup-height)] w-max origin-[var(--transform-origin)] rounded-lg bg-secondary-1 text-secondary-12 shadow-large border border-secondary-a4 transition-[opacity,transform,width,height,scale,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] data-[ending-style]:scale-90 data-[ending-style]:opacity-0 data-[ending-style]:duration-150 data-[starting-style]:scale-90 data-[starting-style]:opacity-0 min-[500px]:w-[var(--popup-width)] xs:w-[var(--popup-width)]"
32+
VIEWPORT = "relative h-full w-full overflow-hidden"
33+
ARROW = "flex transition-[left] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] data-[side=bottom]:top-[-8px] data-[side=left]:right-[-13px] data-[side=left]:rotate-90 data-[side=right]:left-[-13px] data-[side=right]:-rotate-90 data-[side=top]:bottom-[-8px] data-[side=top]:rotate-180"
3434
BACKDROP = "fixed inset-0 z-40"
3535

3636

@@ -46,24 +46,29 @@ def import_var(self):
4646

4747

4848
class NavigationMenuRoot(NavigationMenuBaseComponent):
49-
"""Groups all parts of the navigation menu. Renders a <nav> element."""
49+
"""Groups all parts of the navigation menu. Renders a <nav> element at the root, or <div> element when nested."""
5050

5151
tag = "NavigationMenu.Root"
5252

53+
# The controlled value of the navigation menu item that should be currently open. When non-nullish, the menu will be open. When nullish, the menu will be closed. To render an uncontrolled navigation menu, use the defaultValue prop instead.
5354
value: Var[str]
5455

56+
# The uncontrolled value of the item that should be initially selected. To render a controlled navigation menu, use the value prop instead.
5557
default_value: Var[str]
5658

59+
# Callback fired when the value changes.
5760
on_value_change: EventHandler[passthrough_event_spec(str, dict)]
5861

62+
# The orientation of the navigation menu.
5963
orientation: Var[LiteralNavigationMenuOrientation]
6064

65+
# How long to wait before opening the navigation menu. Specified in milliseconds. Defaults to 50.
6166
delay: Var[int]
6267

68+
# How long to wait before closing the navigation menu. Specified in milliseconds. Defaults to 50.
6369
close_delay: Var[int]
6470

65-
actions_ref: Var[str]
66-
71+
# Event handler called after any animations complete when the navigation menu is closed.
6772
on_open_change_complete: EventHandler[passthrough_event_spec(bool)]
6873

6974
# The render prop.
@@ -241,7 +246,7 @@ class NavigationMenuPositioner(NavigationMenuBaseComponent):
241246
def create(cls, *children, **props) -> BaseUIComponent:
242247
"""Create the navigation menu positioner component."""
243248
props["data-slot"] = "navigation-menu-positioner"
244-
props.setdefault("side_offset", 4)
249+
props.setdefault("side_offset", 10)
245250
cls.set_class_name(ClassNames.POSITIONER, props)
246251
return super().create(*children, **props)
247252

0 commit comments

Comments
 (0)