defmodule Shino.UI.Table do @moduledoc """ Provides table related components. > Displays a responsive table. ## Examples A table for data: ```heex A list of your recent invoices. Invoice Status Method Amount INV001 Paid Credit Card $250.00 INV002 Pending PayPal $150.00 Total $400.00 ``` A table for data and actions: ```heex A list of your recent invoices. Invoice Status Method Amount Actions INV001 Paid Credit Card $250.00 <.link>Show INV002 Pending PayPal $150.00 <.link>Show Total $400.00 ``` A table using stream: ```heex Invoice Status Method Amount <%= id %> <%= invoice.status %> <%= invoice.method %> <%= invoice.amount %> ``` > Notice the `id` and `phx-update` attr on ``, and `id` attr > on ``. ## References * [shadcn/ui - Table](https://ui.shadcn.com/docs/components/table) """ use Shino.UI, :component @doc """ The root contains all the parts of a table. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def root(assigns) do ~H"""
<%= render_slot(@inner_block) %>
""" end @doc """ Renders a table caption. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def caption(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end @doc """ Renders a table header. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def header(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end @doc """ Renders a table body. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def body(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end @doc """ Renders a table footer. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def footer(assigns) do ~H""" tr]:last:border-b-0", @class])} {@rest}> <%= render_slot(@inner_block) %> """ end @doc """ Renders a table row. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def row(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end @doc """ Renders a table head. """ attr :class, :string, default: nil attr :rest, :global slot :inner_block, required: true def head(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end @doc """ Renders a table cell. """ attr :class, :string, default: nil attr :rest, :global, include: ~w(colspan) slot :inner_block, required: true def cell(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end end