defmodule PetalComponents.Table do use Phoenix.Component import PetalComponents.Avatar import PetalComponents.Helpers attr(:class, :string, default: "", doc: "CSS class") attr(:rest, :global) slot(:inner_block, required: false) def table(assigns) do ~H""" <%= render_slot(@inner_block) %>
""" end attr(:class, :string, default: "", doc: "CSS class") attr(:rest, :global, include: ~w(colspan rowspan)) slot(:inner_block, required: false) def th(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end attr(:class, :string, default: "", doc: "CSS class") attr(:rest, :global) slot(:inner_block, required: false) def tr(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end attr(:class, :string, default: "", doc: "CSS class") attr(:rest, :global, include: ~w(colspan headers rowspan)) slot(:inner_block, required: false) def td(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end attr(:class, :string, default: "", doc: "CSS class") attr(:label, :string, default: nil, doc: "Adds a label your user, e.g name") attr(:sub_label, :string, default: nil, doc: "Adds a sub-label your to your user, e.g title") attr(:rest, :global) attr(:avatar_assigns, :map, default: nil, doc: "if using an avatar, this map will be passed to the avatar component as props" ) def user_inner_td(assigns) do ~H"""
<%= if @avatar_assigns do %> <.avatar {@avatar_assigns} /> <% end %>
<%= @label %>
<%= @sub_label %>
""" end end