defmodule Observer.Web.Components.Core do @moduledoc """ Provides core UI components. """ use Observer.Web, :html alias Phoenix.HTML.Form @doc ~S""" Renders a table with generic metric log styling. ## Examples <.table_tracing id="users" rows={@users}> <:col :let={user} label="id"><%= user.id %> <:col :let={user} label="username"><%= user.username %> """ attr :id, :string, required: true attr :rows, :list, required: true attr :row_id, :any, default: nil, doc: "the function for generating the row id" attr :row_click, :any, default: nil, doc: "the function for handling phx-click on each row" attr :transition, :boolean, default: false attr :row_item, :any, default: &Function.identity/1, doc: "the function for mapping each row before calling the :col slots" slot :col, required: true do attr :label, :string end def table_tracing(assigns) do assigns = with %{rows: %Phoenix.LiveView.LiveStream{}} <- assigns do assign(assigns, row_id: assigns.row_id || fn {id, _item} -> id end) end ~H"""
| {col[:label]} |
|---|
|
{render_slot(col, @row_item.(row))}
|
{entry.content}
"""
attr :id, :string, required: true
attr :expandable?, :boolean, default: true
attr :summary_class, :any, default: nil
attr :title, :string, default: nil
slot :summary, required: true
slot :inner_block
def disclosure(assigns) do
~H"""
|
{render_slot(col, @row_item.(row))}
|
| {col[:label]} |
|---|
|
{render_slot(col, @row_item.(row))}
|