Skip to content

Commit b95bf6f

Browse files
Add prop descriptions and remove state from demo
- Add descriptive comments above each prop following existing patterns - Include default values and event handler descriptions - Remove state management from context menu demo integration - Maintain functionality while simplifying demo code Co-Authored-By: Carlos Cutillas <[email protected]>
1 parent 7497132 commit b95bf6f

File tree

2 files changed

+9
-33
lines changed

2 files changed

+9
-33
lines changed

demo/demo/demo.py

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88

99
class State(rx.State):
1010
seed: int = 0
11-
context_menu_action: str = "No action selected"
12-
13-
def handle_context_action(self, action: str):
14-
"""Handle context menu action."""
15-
self.context_menu_action = f"Selected: {action}"
1611

1712

1813
def index() -> rx.Component:
@@ -74,43 +69,21 @@ def index() -> rx.Component:
7469
context_menu.portal(
7570
context_menu.positioner(
7671
context_menu.popup(
77-
context_menu.item(
78-
"Copy",
79-
on_click=State.handle_context_action("Copy")
80-
),
81-
context_menu.item(
82-
"Cut",
83-
on_click=State.handle_context_action("Cut")
84-
),
85-
context_menu.item(
86-
"Paste",
87-
on_click=State.handle_context_action("Paste")
88-
),
72+
context_menu.item("Copy"),
73+
context_menu.item("Cut"),
74+
context_menu.item("Paste"),
8975
context_menu.separator(),
9076
context_menu.group(
9177
context_menu.group_label("Actions"),
92-
context_menu.item(
93-
"Delete",
94-
on_click=State.handle_context_action("Delete")
95-
),
96-
context_menu.item(
97-
"Rename",
98-
on_click=State.handle_context_action("Rename")
99-
),
78+
context_menu.item("Delete"),
79+
context_menu.item("Rename"),
10080
),
10181
context_menu.separator(),
102-
context_menu.item(
103-
"Properties",
104-
on_click=State.handle_context_action("Properties")
105-
)
82+
context_menu.item("Properties")
10683
)
10784
)
10885
)
10986
),
110-
rx.el.div(
111-
State.context_menu_action,
112-
class_name="mt-4 p-2 bg-blue-100 rounded text-sm"
113-
),
11487
ui.theme_switcher(class_name="absolute top-4 right-4"),
11588
class_name=ui.cn(
11689
"flex flex-col gap-6 items-center justify-center h-screen", "bg-secondary-1"

reflex_ui/components/base/context_menu.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class ContextMenuPortal(ContextMenuBaseComponent):
101101
tag = "ContextMenu.Portal"
102102

103103
container: Var[str]
104+
# Whether to keep the portal mounted when closed. Defaults to False.
104105
keep_mounted: Var[bool]
105106

106107
@classmethod
@@ -132,6 +133,7 @@ class ContextMenuPositioner(ContextMenuBaseComponent):
132133
tag = "ContextMenu.Positioner"
133134

134135
collision_avoidance: Var[bool | LiteralCollisionAvoidance]
136+
# How to align the popup relative to the trigger. Defaults to "center".
135137
align: Var[LiteralAlign]
136138
align_offset: Var[int]
137139
side: Var[LiteralSide]
@@ -208,6 +210,7 @@ class ContextMenuSeparator(ContextMenuBaseComponent):
208210

209211
tag = "ContextMenu.Separator"
210212

213+
# The orientation of the separator. Defaults to "horizontal".
211214
orientation: Var[LiteralMenuOrientation]
212215
render_: Var[Component]
213216

0 commit comments

Comments
 (0)