defmodule Skua.Components.Menu do @moduledoc """ A dropdown menu — a trigger button that opens a top-layer menu of actions. <.menu id="actions"> <:trigger>Actions <.menu_label>Project <.menu_item icon="hero-pencil" shortcut="⌘R" phx-click="rename">Rename <.menu_item shortcut="⌘D" phx-click="duplicate">Duplicate <.menu_separator /> <.menu_item danger phx-click="delete">Delete project Built on the same top-layer `PanelStack` as the popover, with the W3C APG menu keyboard model (Arrow up/down move between items, Enter/Space activate, Escape closes, Home/End jump). Activating an item closes the menu. """ use Phoenix.Component @doc "The menu: a trigger button + a top-layer `role=menu` panel of items." attr :id, :string, required: true attr :trigger_variant, :string, default: "secondary", values: ~w(primary secondary ghost danger) attr :width, :string, default: nil attr :placement, :string, default: "bottom", values: ~w(bottom right) attr :class, :any, default: nil attr :rest, :global slot :trigger, required: true slot :inner_block, required: true def menu(assigns) do ~H""" """ end @doc "A menu action. `danger` styles it destructive; `shortcut`/`icon` are optional." attr :danger, :boolean, default: false attr :icon, :string, default: nil, doc: "a heroicon name, e.g. \"hero-pencil\"" attr :shortcut, :string, default: nil attr :class, :any, default: nil attr :rest, :global, include: ~w(disabled) slot :inner_block, required: true def menu_item(assigns) do ~H""" """ end @doc "A small uppercase section label inside a menu." slot :inner_block, required: true def menu_label(assigns) do ~H""" """ end @doc "A divider between menu sections." def menu_separator(assigns) do ~H""" """ end end