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"""