LedgerUI.Components.ActionMenu (LedgerUI v0.2.0)

Copy Markdown View Source

The actions of one item (a table row, a card), opened by a "⋯" button, and action_button/1, the direct button for an item with a single action.

<.action_menu id={"actions-" <> c.id} label={"Actions of " <> c.name}>
  <:title>{c.name}</:title>
  <.action_menu_item navigate={~p"/companies/#{c.id}"} icon="huge-view" kbd="↵">Open</.action_menu_item>
  <.action_menu_separator />
  <.action_menu_item phx-click="delete" phx-value-id={c.id} icon="huge-delete-02" danger>
    Delete
  </.action_menu_item>
</.action_menu>

<.action_button label="Delete" icon="huge-delete-02" danger phx-click="delete" />

The server renders the ARIA (aria-haspopup/aria-expanded/aria-controls on the button, popover="manual", role="menu"/menuitem/separator); the hook only flips aria-expanded. The menu uses the Dropdown machinery through the hook LedgerUI.ActionMenu (priv/static/ledger_ui/hooks/action_menu.js, the Dropdown hook plus the row marking): top layer, flips, follows scrolling, Esc/Tab/click outside, arrows, Home/End and letters. While it is open the hook sets data-am-open on the nearest [data-am-row], tr or .ledger-ctable-row and tints it.

action_button/1 emits the lu-b button markup directly.

Summary

Functions

action_button(assigns)

Attributes

  • label (:string) (required) - Accessible name (aria-label).
  • icon (:string) - Defaults to nil.
  • danger (:boolean) - Defaults to false.
  • variant (:string) - Defaults to "outline". Must be one of "solid", "glow", "outline", "soft", "bordered", "flat", "glass", "ghost", or "dim".
  • size (:string) - Defaults to "sm". Must be one of "xs", "sm", "md", "lg", or "xl".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "download", "target", "rel", "form", "name", "value", "disabled", "type"].

Slots

  • inner_block

action_menu(assigns)

Attributes

  • id (:string) (required)
  • label (:string) (required) - Accessible name of the button.
  • placement (:string) - Defaults to "bottom-end". Must be one of "bottom-start", "bottom-end", "top-start", or "top-end".
  • class (:any) - Merged into the menu box. Defaults to nil.
  • menu_style (:string) - Inline style of the menu box. Defaults to nil.
  • anchor_class (:any) - Extra classes of the lu-anc root. Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)
  • title
  • trigger - What the button shows, in place of the "⋯" icon.
  • overlay - Extra content after the menu inside the anchor (a demo cursor).

action_menu_item(assigns)

Attributes

  • icon (:string) - Defaults to nil.
  • kbd (:string) - Defaults to nil.
  • hint (:string) - Defaults to nil.
  • danger (:boolean) - Defaults to false.
  • disabled (:boolean) - Defaults to false.
  • type (:string) - Defaults to "button".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "replace", "download", "target", "rel", "hreflang", "referrerpolicy", "form", "name", "value"].

Slots

  • inner_block (required)

action_menu_separator(assigns)

Attributes

  • class (:any) - Defaults to nil.
  • Global attributes are accepted.