Riddler.Screens.Type.Button (Riddler v0.1.0)

Copy Markdown View Source

A control a visitor presses, and what pressing it means.

outcome is required and is the name of what the press raises - the whole reason a button is worth declaring rather than drawing. writes is what the press sets, a map whose keys address a response and whose values are the two-element constant form, and the host applies it; this package carries it through resolution unchanged. style is a name a renderer owns, and a style this package does not recognize is passed through rather than refused, because presentation is not this package's to enumerate. validates defaults to true, and the opt-out is what lets a Back button leave a half-filled screen without an error.

iex> node = %{type: "button", key: "plan_business", label: "Take the business plan", outcome: "business_chosen", writes: %{"responses.plan" => ["const", "business"]}}
iex> Riddler.Screens.Type.Button.validate(node)
[]

iex> node = %{type: "button", key: "plan_business", label: "Go", outcome: "chosen", writes: %{"plan" => ["const", "business"]}}
iex> [finding] = Riddler.Screens.Type.Button.validate(node)
iex> finding.code
"document.invalid_writes"