Macaw.Component.Announcement (macaw_component v0.1.2)

Copy Markdown View Source

An announcement request (spec/01 §1.6): %{name, text, politeness}, for a name the component declares in announces. Components never render a live region; the announcer is the host's.

iex> {:ok, d} = Macaw.Component.Declarations.new([announces: ["matches"]], nil)
iex> Macaw.Component.Announcement.new(d, name: "matches", text: "12 projects match")
{:ok, %{name: "matches", text: "12 projects match", politeness: :polite}}

Summary

Functions

A request from attributes (a keyword list or a map): name, text, and politeness, :polite by default. Every fault at once: an undeclared name is {:undeclared, name}, empty text :empty, a politeness other than the two {:politeness, value}.

Types

t()

@type t() :: %{name: String.t(), text: String.t(), politeness: :polite | :assertive}

Functions

new(declarations, attrs)

@spec new(Macaw.Component.Declarations.t(), keyword() | map()) ::
  {:ok, t()} | {:error, [Macaw.Component.fault(), ...]}

A request from attributes (a keyword list or a map): name, text, and politeness, :polite by default. Every fault at once: an undeclared name is {:undeclared, name}, empty text :empty, a politeness other than the two {:politeness, value}.