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