SaltDnsWeb. CoreComponents
(Salt v1.0.0)
The components of the Salt web interface: on Tailwind utilities and
the colour tokens of assets/css/app.css. The design system (tokens, the
band, the logo and the components) is described in docs/design.md; a
page is built from these and adds layout utilities only.
Every component renders under the browser pages' content security policy:
no inline style, no inline script, no event handler attribute. The one
piece of browser code in the console, copying to the clipboard, is a
colocated hook in SaltDnsWeb.Console.Components.
Summary
Functions
A small label with a tone: neutral, ok, warn, bad, info,
violet or brand.
A button, or a link that looks like one when it has href, navigate or
patch. variant: plain (the default), primary (the one main action
of a form or page) or danger (removes or stops something, with
data-confirm). size: md or sm.
A notice inside the page, for a state the reader must know about. tone
is one of the status tones.
What a list says when it is empty: what is missing, and what to do about
it (inner_block, actions).
A flash notice, at the top right; a click dismisses it.
The heading of a page: its title, a line under it, and the page's own actions on the right.
A Heroicon: hero-<name> (outline, 24 px),
-solid, -mini (20 px) or -micro (16 px). Size and colour come from
class. Decorative: give the element around it a label when the icon
alone carries meaning.
An input with its label, help and errors. A Phoenix.HTML.FormField
gives the name, id, value and errors.
A section of a page: a titled surface. flush drops the inner padding,
for a table that fills it.
A table: dense rows and a sticky header on a wide screen; below sm each
row becomes a compact stacked card instead of a sideways-scrolling table.
The card's title is the column marked mobile={:title} (the first column
when none is marked); a column marked mobile={:badge} sits at its right.
Every other column is a label and value pair, two to a line; a long value
takes the whole width with mobile={:value} (no visible label) or
mobile={:block} (its label above it). mobile={:hidden} keeps a
secondary column for wide screens only; the more slot carries those
fields behind a text disclosure on a phone.
Translates an error message using gettext.
Translates the errors for a field from a keyword list of errors.
Functions
A small label with a tone: neutral, ok, warn, bad, info,
violet or brand.
Attributes
id(:string) - Defaults tonil.tone(:string) - Defaults to"neutral". Must be one of"neutral","ok","warn","bad","info","violet", or"brand".icon(:string) - Defaults tonil.class(:any) - Defaults tonil.
Slots
inner_block(required)
A button, or a link that looks like one when it has href, navigate or
patch. variant: plain (the default), primary (the one main action
of a form or page) or danger (removes or stops something, with
data-confirm). size: md or sm.
<.button variant="primary">Save</.button>
<.button navigate={~p"/"}>Organisations</.button>
<.button variant="danger" size="sm" data-confirm="Revoke it?">Revoke</.button>Attributes
variant(:string) - Defaults to"plain". Must be one of"primary","plain", or"danger".size(:string) - Defaults to"md". Must be one of"sm", or"md".class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["href", "navigate", "patch", "method", "download", "name", "value", "disabled", "form", "type", "rel", "phx-click", "phx-value-id", "phx-value-name", "phx-value-type", "phx-disable-with", "data-confirm"].
Slots
inner_block(required)
A notice inside the page, for a state the reader must know about. tone
is one of the status tones.
<.callout id="frozen" tone="warn" icon="hero-pause-circle" title="Frozen">
Changes are not accepted.
</.callout>Attributes
id(:string) - Defaults tonil.tone(:string) - Defaults to"info". Must be one of"info","ok","warn","bad", or"neutral".icon(:string) - Defaults tonil.title(:string) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_blockactions
What a list says when it is empty: what is missing, and what to do about
it (inner_block, actions).
<.empty_state id="no-zones" icon="hero-globe-alt" title="No zones yet">
Add the first domain the organisation manages.
</.empty_state>Attributes
id(:string) - Defaults tonil.icon(:string) - Defaults to"hero-inbox".title(:string) (required)class(:any) - Defaults tonil.
Slots
inner_blockactions
A flash notice, at the top right; a click dismisses it.
<.flash kind={:info} flash={@flash} />Attributes
id(:string) - the optional id of flash container.flash(:map) - the map of flash messages to display. Defaults to%{}.title(:string) - Defaults tonil.kind(:atom) - used for styling and flash lookup. Must be one of:info, or:error.- Global attributes are accepted. the arbitrary HTML attributes to add to the flash container.
Slots
inner_block- the optional inner block that renders the flash message.
The heading of a page: its title, a line under it, and the page's own actions on the right.
Attributes
id(:string) - Defaults tonil.
Slots
inner_block(required)subtitleactions
A Heroicon: hero-<name> (outline, 24 px),
-solid, -mini (20 px) or -micro (16 px). Size and colour come from
class. Decorative: give the element around it a label when the icon
alone carries meaning.
<.icon name="hero-x-mark" />
<.icon name="hero-arrow-path" class="ml-1 size-3 motion-safe:animate-spin" />Attributes
name(:string) (required)class(:any) - Defaults to"size-4".
An input with its label, help and errors. A Phoenix.HTML.FormField
gives the name, id, value and errors.
type="select" takes options (and prompt); type="checkbox" is for
one boolean; help is a sentence under the field. class styles the
wrapper, input_class the field itself.
<.input field={@form[:email]} type="email" label="Address" />
<.input field={@form[:role]} type="select" label="Role" options={@roles} />Attributes
id(:any) - Defaults tonil.name(:any)label(:string) - Defaults tonil.help(:string) - Defaults tonil.value(:any)type(:string) - Defaults to"text". Must be one of"checkbox","color","date","datetime-local","email","file","month","number","password","search","select","tel","text","textarea","time","url","week", or"hidden".field(Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].errors(:list) - Defaults to[].checked(:boolean) - the checked flag for checkbox inputs.prompt(:string) - the prompt for select inputs. Defaults tonil.options(:list) - the options to pass to Phoenix.HTML.Form.options_for_select/2.multiple(:boolean) - the multiple flag for select inputs. Defaults tofalse.class(:any) - classes for the field's wrapper (its width, say). Defaults tonil.input_class(:any) - classes for the input, select or textarea itself. Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["accept", "autocomplete", "autocapitalize", "capture", "cols", "disabled", "form", "inputmode", "list", "max", "maxlength", "min", "minlength", "multiple", "pattern", "placeholder", "readonly", "required", "rows", "size", "spellcheck", "step", "tabindex", "phx-mounted", "phx-debounce", "phx-blur", "phx-focus"].
A section of a page: a titled surface. flush drops the inner padding,
for a table that fills it.
<.panel id="dkim" title="DKIM keys">
<:actions><.button size="sm">Generate</.button></:actions>
...
</.panel>Attributes
id(:string) - Defaults tonil.title(:string) - Defaults tonil.flush(:boolean) - Defaults tofalse.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)subtitleactions
A table: dense rows and a sticky header on a wide screen; below sm each
row becomes a compact stacked card instead of a sideways-scrolling table.
The card's title is the column marked mobile={:title} (the first column
when none is marked); a column marked mobile={:badge} sits at its right.
Every other column is a label and value pair, two to a line; a long value
takes the whole width with mobile={:value} (no visible label) or
mobile={:block} (its label above it). mobile={:hidden} keeps a
secondary column for wide screens only; the more slot carries those
fields behind a text disclosure on a phone.
The first column stays in view when the table scrolls sideways on a wide
screen, and its text wraps rather than being cut off. rows may be a
list or a stream (@streams.name); id is the tbody's. A column's
class aligns it (text-right for numbers) or sets its font (font-mono
for identifiers).
<.table id="zones" rows={@zones}>
<:col :let={zone} label="Zone" mobile={:title}>{zone.name}</:col>
<:col :let={zone} label="Status" mobile={:badge}>
<.status_badge tone={zone.tone}>{zone.label}</.status_badge>
</:col>
<:col :let={zone} label="Added">{zone.added}</:col>
</.table>A table that already sits inside a <.panel> passes plain so that it
does not draw a second border.
Attributes
id(:string) (required)rows(:list) (required)row_id(:any) - the function for generating the row id. Defaults tonil.row_click(:any) - the function for handling phx-click on each row. Defaults tonil.row_class(:any) - the function giving a row's extra classes. Defaults tonil.row_item(:any) - maps each row before the slots. Defaults to&Function.identity/1.plain(:boolean) - draw no border or background around the table. Defaults tofalse.class(:any) - Defaults tonil.stack(:boolean) - below sm each row becomes a stacked card; false keeps a scrolling table. Defaults totrue.
Slots
col(required) - Accepts attributes:label(:string)class(:any)mobile(:atom) - the column's place in a phone's card (default :fact). Must be one of:title,:badge,:fact,:block,:value, or:hidden.
action- the slot for showing user actions in the last table column.more- secondary fields for a phone, behind a More disclosure.
Translates an error message using gettext.
Translates the errors for a field from a keyword list of errors.