defmodule OutlookWeb.ArticleLive.MenuComponent do
  use OutlookWeb, :live_component

  attr :entries, :list
  # attr :target, :integer, default: 0  # @myself of the Live(View|Component) where the handlers reside
  attr :handler, :string

  @impl true
  def render(assigns) do
    ~H"""
    <div>
      <.menu_item :for={entry <- @entries} entry={entry} handler={@handler} />
    </div>
    """
  end

  def menu_item(assigns) do
    ~H"""
    <div title={@entry.description} phx-click={@handler} phx-value-modifier={@entry.name}>
      <%= @entry.label %>
    </div>
    """
  end
end
