Skip to content

Commit

Permalink
action_menu and list_action_menu Python components (deephaven#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed May 1, 2024
1 parent 5bc8d47 commit b9742e0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
24 changes: 23 additions & 1 deletion plugins/ui/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def action_group():
"Aaa",
"Bbb",
"Ccc",
action=action,
on_action=on_action,
),
ui.text(action),
Expand All @@ -227,6 +226,29 @@ def action_group():
ag = action_group()
```

## ActionMenu (string values)
ActionMenu combines an ActionButton with a Menu for simple "more actions" use cases.

```python
@ui.component
def action_menu():
[action, on_action] = ui.use_state()

return ui.flex(
ui.action_menu(
"Aaa",
"Bbb",
"Ccc",
on_action=on_action,
),
ui.text(action),
direction="column",
)


ag = action_menu()
```

## Picker (string values)

The `ui.picker` component can be used to select from a list of items. Here's a basic example for selecting from a list of string values and displaying the selected key in a text field.
Expand Down
1 change: 1 addition & 0 deletions plugins/ui/src/deephaven/ui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
__all__ = [
"action_button",
"action_group",
"action_menu",
"button",
"button_group",
"checkbox",
Expand Down
12 changes: 12 additions & 0 deletions plugins/ui/src/deephaven/ui/components/action_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from ..elements import BaseElement


def action_menu(*children, **props):
"""
ActionMenu combines an ActionButton with a Menu for simple "more actions" use cases.
Args:
children: A list of Item or primitive elements.
**props: Any other ActionMenu prop.
"""
return BaseElement(f"deephaven.ui.components.ActionMenu", *children, **props)
2 changes: 2 additions & 0 deletions plugins/ui/src/js/src/elements/ElementConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ export const ELEMENT_NAME = {

/** Other Components */
actionGroup: uiComponentName('ActionGroup'),
actionMenu: uiComponentName('ActionMenu'),
fragment: uiComponentName('Fragment'),
item: uiComponentName('Item'),
listActionGroup: uiComponentName('ListActionGroup'),
listActionMenu: uiComponentName('ListActionMenu'),
listView: uiComponentName('ListView'),
picker: uiComponentName('Picker'),
section: uiComponentName('Section'),
Expand Down

0 comments on commit b9742e0

Please sign in to comment.