defmodule RiverConnectWeb.Components.UI.Tabs do @moduledoc """ Implementation of tabs components from https://ui.shadcn.com/docs/components/tabs ## Example: <.tabs id="settings" default="account" on_tab_changed={JS.push("tab_changed")}> <.tabs_list> <.tabs_trigger value="account">Account <.tabs_trigger value="password">Password <.tabs_content value="account"> <.card> <.card_content class="p-6"> Account settings go here <.tabs_content value="password"> <.card> <.card_content class="p-6"> Password settings go here """ use RiverConnectWeb.Components.UI, :component @doc """ Primary tabs component that serves as a container for tab triggers and content. """ attr :id, :string, required: true, doc: "Unique identifier for the tabs component" attr :default, :string, default: nil, doc: "Default selected tab value" attr :class, :string, default: nil attr :"on-tab-changed", :any, default: nil, doc: "Handler for tab change events" attr :rest, :global slot :inner_block, required: true def tabs(assigns) do # Collect event mappings event_map = add_event_mapping(%{}, assigns, "tab-changed", :"on-tab-changed") assigns = assigns |> assign(:event_map, json(event_map)) |> assign( :options, json(%{ defaultValue: assigns.default }) ) ~H"""
{render_slot(@inner_block)}
""" end @doc """ Container for tab triggers that provides proper styling and ARIA attributes. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def tabs_list(assigns) do ~H"""
{render_slot(@inner_block)}
""" end @doc """ Individual tab button that activates its corresponding content panel. """ attr :value, :string, required: true, doc: "Unique value that identifies this tab" attr :class, :string, default: nil attr :disabled, :boolean, default: false attr :rest, :global slot :inner_block, required: true def tabs_trigger(assigns) do ~H""" """ end @doc """ Content panel that corresponds to a tab trigger. """ attr :value, :string, required: true, doc: "Value that matches a tab trigger" attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def tabs_content(assigns) do ~H""" """ end end