Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.2 kB · 39 lines
Elixir
at main
12345678910111213141516171819202122232425262728293031323334353637383940defmodule TrackerWeb.SectionHeader do @moduledoc """ The heading above a `TrackerWeb.RowList` — a small uppercase title, a hairline rule filling the width the title leaves, and the number of rows in the list underneath.
Affordances for the list — a filter form, a toggle — go in `:controls`, which shares the header's line with the title and drops to a line of its own on a narrow screen. """ use Phoenix.Component
@doc """ Renders the header.
## Examples
<SectionHeader.section_header title="Packages" count={length(@subs)} /> <RowList.row_list id="package-subscriptions"> ... </RowList.row_list> """ attr :title, :string, required: true attr :count, :integer, default: nil attr :class, :string, default: nil
slot :controls, doc: "affordances for the list — a filter form, a toggle, a link"
def section_header(assigns) do ~H""" <div class={if @class in [nil, ""], do: "section-header", else: "section-header #{@class}"}> <h2>{@title}</h2> <span class="rule"></span> <span :if={@controls != []} class="section-controls">{render_slot(@controls)}</span> <span :if={!is_nil(@count)} class="n">{@count}</span> </div> """ endend