DevactionUI.InputGroup (devaction_ui v0.2.3)

Copy Markdown View Source

A text field with what the canvas puts around it: an icon at the start, an action at the end (show the password, clear, copy) and add-ons on either side (R$, https://, .devaction.app). The frame carries the focus ring, the error and the disabled look, so the field inside stays a plain <input>.

The icon, the action and the add-ons are slots: the library knows no icon set. The error is whatever the caller says with invalid, and loading swaps the end for a spinner (and then loading_label is required). An add-on is boxed (a tinted block with a line) unless it says loose (plain muted text, as .devaction.app), and mono sets it in the monospace of an amount or a code.

The field carries no error message of its own: render it under the group with an id and point the field at it with aria-describedby, which goes to the <input> through rest:

<InputGroup.input_group id="slug" invalid aria-describedby="slug-error" />
<p id="slug-error">Already taken</p>

The look comes from the .input-group* classes of devaction_ui.css, which the app must import. The focus and error rings (8% of the ink in light, 10% in dark), the error fill and the disabled fill are the custom properties --ring-field, --ring-field-error, --fill-field-error and --fill-field-off, which an app can override on the group. A readonly field is drawn as the canvas draws a secret to copy: plain fill, monospace.

Summary

Functions

The button at the end of an input_group/1: show the password, clear the field, copy the value.

Functions

input_action(assigns)

The button at the end of an input_group/1: show the password, clear the field, copy the value.

Attributes

  • label (:string) (required) - what pressing it does, read by screen readers.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required) - the icon.

input_group(assigns)

Attributes

  • id (:string) (required)
  • name (:string) - Defaults to nil.
  • value (:any) - Defaults to nil.
  • type (:string) - Defaults to "text".
  • size (:atom) - 36, 44 or 52 px high. Defaults to :md. Must be one of :sm, :md, or :lg.
  • invalid (:boolean) - Defaults to false.
  • loading (:boolean) - swaps the action for a spinner. Defaults to false.
  • loading_label (:string) - what is happening, read by screen readers; required when loading. Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["placeholder", "disabled", "readonly", "maxlength", "minlength", "inputmode", "autocomplete", "required", "min", "max", "step", "pattern", "form", "list"].

Slots

  • icon - drawn before the text, muted.
  • action - a button at the end: show the password, clear, copy.
  • prefix - an add-on glued to the start: R$, https://. Accepts attributes:
    • loose (:boolean)
    • mono (:boolean)
  • suffix - an add-on glued to the end: por marco, .devaction.app. Accepts attributes:
    • loose (:boolean)
    • mono (:boolean)
  • hint - a small key cap or text inside the field, before the action.