defmodule PhiaUi.Components.MegaMenu do @moduledoc """ Full-width mega menu navigation component. Requires the `PhiaMegaMenu` JavaScript hook registered in `app.js`. Provides six components: - `mega_menu/1` — root container with JS hook anchor - `mega_menu_trigger/1` — trigger button - `mega_menu_content/1` — full-width content panel - `mega_menu_section/1` — column section with title - `mega_menu_item/1` — link item with icon + title + description - `mega_menu_featured/1` — highlighted promotional item """ use Phoenix.Component import PhiaUi.ClassMerger, only: [cn: 1] # --------------------------------------------------------------------------- # mega_menu/1 # --------------------------------------------------------------------------- attr(:id, :string, required: true) attr(:class, :string, default: nil) attr(:rest, :global) slot(:inner_block, required: true) def mega_menu(assigns) do ~H"""
{render_slot(@inner_block)}
""" end # --------------------------------------------------------------------------- # mega_menu_trigger/1 # --------------------------------------------------------------------------- attr(:class, :string, default: nil) attr(:rest, :global) slot(:inner_block, required: true) def mega_menu_trigger(assigns) do ~H""" """ end # --------------------------------------------------------------------------- # mega_menu_content/1 # --------------------------------------------------------------------------- attr(:class, :string, default: nil) attr(:cols, :atom, values: [:auto, :"2", :"3", :"4"], default: :auto) attr(:rest, :global) slot(:inner_block, required: true) def mega_menu_content(assigns) do ~H"""
{render_slot(@inner_block)}
""" end # --------------------------------------------------------------------------- # mega_menu_section/1 # --------------------------------------------------------------------------- attr(:title, :string, default: nil) attr(:class, :string, default: nil) attr(:rest, :global) slot(:inner_block, required: true) def mega_menu_section(assigns) do ~H"""

{@title}

{render_slot(@inner_block)}
""" end # --------------------------------------------------------------------------- # mega_menu_item/1 # --------------------------------------------------------------------------- attr(:href, :string, default: "#") attr(:title, :string, required: true) attr(:description, :string, default: nil) attr(:class, :string, default: nil) attr(:rest, :global) slot(:icon) def mega_menu_item(assigns) do ~H""" {render_slot(@icon)}

{@title}

{@description}

""" end # --------------------------------------------------------------------------- # mega_menu_featured/1 # --------------------------------------------------------------------------- attr(:href, :string, default: "#") attr(:title, :string, default: nil) attr(:description, :string, default: nil) attr(:class, :string, default: nil) attr(:rest, :global) slot(:image) slot(:inner_block) def mega_menu_featured(assigns) do ~H"""
{render_slot(@image)}

{@title}

{@description}

{render_slot(@inner_block)}
""" end # --------------------------------------------------------------------------- # Private helpers # --------------------------------------------------------------------------- defp mega_menu_cols_class(_), do: "" defp mega_menu_grid_class(:auto), do: "grid gap-6 grid-cols-auto" defp mega_menu_grid_class(:"2"), do: "grid gap-6 grid-cols-2" defp mega_menu_grid_class(:"3"), do: "grid gap-6 grid-cols-3" defp mega_menu_grid_class(:"4"), do: "grid gap-6 grid-cols-4" end