Macaw.Builtin.Text (macaw v0.6.0)

Copy Markdown View Source

The words the built-in components head a field's value with (spec/05 §6): its label from the source's schema, and its unit as a reader writes it.

A schema posts a unit as its UCUM code (Cel, [mi_i]/h, {request}/s), the machine's spelling, chosen so units convert exactly. A reader sees its display symbol, with its annotations (°C, mi/h, request/s): Macaw.Units.Unit.symbol/2 with annotations: true, since without them {request}/s would read /s and say less than the code. A code with no symbol is shown as it is.

Summary

Functions

The heading of field of slot: its label (Macaw.Component.Context.label/3, the field's name without one), then its unit in parentheses when it has one: Request rate (request/s).

The role field's schema gives a state (macaw_data spec/01 §1.6): a theme's word, neutral for a state with none, for no state, for no schema, and for a word that spells no class. A theme's own word is kept, as a class it may style. It is roles/2 of the schema and field asked of the state.

role/3 of field as a function of the state, its roles read from the schema and judged once, so a component drawing many states builds them once per render (#408), not once per state.

The display symbol of a UCUM code, annotations kept, or the code itself when Macaw.Units.Unit.symbol/2 gives none.

The unit field of slot is shown in: its code's display symbol, the code itself when it has none, or nil for a field without a unit.

A value as a built-in component writes it: a time as ISO 8601, whole seconds without a fraction; a point as lon, lat; nil as nothing. A :term column's value (#481): a literal color as its CSS text, a theme's color as its name ({:color, "good"} is good), and any other term as Elixir writes it, never a raise.

words/3 of field as a function of the state, its display names read from the schema once, so a component drawing many states reads them once per render (#408).

A state's words, so color is never the only cue: its display name from the schema, else its spelling, and an en dash for no state. It is words/2 of the schema and field asked of the state.

Functions

heading(context, slot, field)

@spec heading(Macaw.Component.Context.t(), String.t(), String.t()) :: String.t()

The heading of field of slot: its label (Macaw.Component.Context.label/3, the field's name without one), then its unit in parentheses when it has one: Request rate (request/s).

role(schema, field, state)

@spec role(Macaw.Data.Schema.t() | nil, String.t(), term()) :: String.t()

The role field's schema gives a state (macaw_data spec/01 §1.6): a theme's word, neutral for a state with none, for no state, for no schema, and for a word that spells no class. A theme's own word is kept, as a class it may style. It is roles/2 of the schema and field asked of the state.

roles(schema, field)

@spec roles(Macaw.Data.Schema.t() | nil, String.t()) :: (term() -> String.t())

role/3 of field as a function of the state, its roles read from the schema and judged once, so a component drawing many states builds them once per render (#408), not once per state.

symbol(code)

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

The display symbol of a UCUM code, annotations kept, or the code itself when Macaw.Units.Unit.symbol/2 gives none.

unit(context, slot, field)

@spec unit(Macaw.Component.Context.t(), String.t(), String.t()) :: String.t() | nil

The unit field of slot is shown in: its code's display symbol, the code itself when it has none, or nil for a field without a unit.

value(t)

@spec value(term()) :: String.t()

A value as a built-in component writes it: a time as ISO 8601, whole seconds without a fraction; a point as lon, lat; nil as nothing. A :term column's value (#481): a literal color as its CSS text, a theme's color as its name ({:color, "good"} is good), and any other term as Elixir writes it, never a raise.

words(schema, field)

@spec words(Macaw.Data.Schema.t() | nil, String.t()) :: (term() -> String.t())

words/3 of field as a function of the state, its display names read from the schema once, so a component drawing many states reads them once per render (#408).

words(schema, field, state)

@spec words(Macaw.Data.Schema.t() | nil, String.t(), term()) :: String.t()

A state's words, so color is never the only cue: its display name from the schema, else its spelling, and an en dash for no state. It is words/2 of the schema and field asked of the state.