PhoenixKitProjects.Web.Components.SmartMenuLink (PhoenixKitProjects v0.4.0)

Copy Markdown View Source

Embed-mode aware <li> entry for use inside <.table_row_menu>.

Behaves like <.smart_link> (renders a real <a href> in navigate mode, fires the shared open_embed event in emit mode), but produces the menu-item styling that <.table_row_menu_link> / <.table_row_menu_button> apply.

Use everywhere this module's tables need an Edit / View / per-row navigation entry inside a 3-dots dropdown.

Example

<.table_row_menu id={"row-menu-#{task.uuid}"}>
  <.smart_menu_link
    navigate={Paths.edit_task(task.uuid)}
    emit={{PhoenixKitProjects.Web.TaskFormLive,
           %{"live_action" => "edit", "id" => task.uuid}}}
    embed_mode={@embed_mode}
    icon="hero-pencil"
    label={gettext("Edit")}
  />
  <.table_row_menu_button
    phx-click="delete"
    phx-value-uuid={task.uuid}
    icon="hero-trash"
    label={gettext("Delete")}
    variant="error"
  />
</.table_row_menu>

Summary

Functions

smart_menu_link(assigns)

Attributes

  • navigate (:string) (required)
  • emit (:any) (required) - {TargetLV :: module(), session_overrides :: map()}.
  • embed_mode (:atom) - Defaults to :navigate. Must be one of :navigate, or :emit.
  • icon (:string) - Defaults to nil.
  • label (:string) (required)
  • variant (:string) - Defaults to "default".
  • Global attributes are accepted. Supports all globals plus: ["data-id", "title", "aria-label"].