defmodule EasyPage.Components.Tabber.Body do @moduledoc ~s""" A component which takes :tab slots. Renders whichever :tab slot is currently selected, based on title. Titles must be unique. > #### Warning {: .warning} > > Most of Tabber's magic is in the backend, not the components. > You are probably better off copying the source code so you can customize it for your app. ```elixir def render(assigns) do ~H\"\"\" <:tab title="Tab A"> <:tab title="Tab B"> <:tab title="Tab C">

Meow

\"\"\" end ``` """ use Phoenix.Component attr(:tabber, :map, required: true) slot :tab, doc: "The body of a tab." do attr(:title, :string, required: true) end def body(assigns) do ~H""" <%= if !!@tabber.ctl.current_tab do %>
<%= for %{title: title} = tab <- @tab do %>
{render_slot(tab)}
<% end %>
<% end %> """ end end