LineaUI.Component.Helpers (linea_ui v0.1.1)

Copy Markdown View Source

What every component shares: ids, form fields and the color vocabulary.

The colors are LineOne's: neutral, primary, secondary, accent, info, success, warning, error. In dark mode LineOne paints primary with accent, so every primary style carries its dark: accent counterpart.

Summary

Functions

Fills id, name, value and errors from field when one is given.

"true" or "false", for data-* and aria-* attributes.

The color names every colored component accepts.

A unique DOM id, for a component that needs one and was not given it.

Turns an Ecto-style error tuple into text. Set your own translator with

Functions

assign_field(assigns)

@spec assign_field(map()) :: map()

Fills id, name, value and errors from field when one is given.

errors is the list of translated messages, shown only once the field has been used (Phoenix.Component.used_input?/1).

bool(arg)

@spec bool(boolean()) :: String.t()

"true" or "false", for data-* and aria-* attributes.

colors()

@spec colors() :: [String.t()]

The color names every colored component accepts.

gen_id(prefix \\ "linea")

@spec gen_id(String.t()) :: String.t()

A unique DOM id, for a component that needs one and was not given it.

translate_error(message)

@spec translate_error({String.t(), keyword()} | String.t()) :: String.t()

Turns an Ecto-style error tuple into text. Set your own translator with

config :linea_ui, :translate_error, &MyAppWeb.CoreComponents.translate_error/1