DevactionUI.Choice (devaction_ui v0.1.0)

Copy Markdown View Source

Boxes to tick and options to pick, as the canvas draws them: the checkbox (with the partial state of "select all"), the radio with its description and the choice card. They are real <input>s, so the browser, the form and the keyboard do the work; the look comes from the checkbox, radio and choice-card classes.

Summary

Functions

A whole card that is the option: it gains the border and the wash of the choice when ticked.

The state of a "select all" box: :none, :some (partial) or :all, from how many of total are ticked.

Functions

checkbox(assigns)

Attributes

  • id (:string) (required)
  • name (:string) - Defaults to nil.
  • value (:string) - Defaults to "true".
  • checked (:boolean) - Defaults to false.
  • partial (:boolean) - the dash of a "select all" with only some ticked. Defaults to false.
  • label (:string) - Defaults to nil.
  • description (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["disabled", "required", "phx-click", "phx-change", "phx-value-id"].

choice_card(assigns)

A whole card that is the option: it gains the border and the wash of the choice when ticked.

Attributes

  • id (:string) (required)
  • name (:string) (required)
  • value (:string) (required)
  • type (:string) - Defaults to "radio". Must be one of "radio", or "checkbox".
  • checked (:boolean) - Defaults to false.
  • label (:string) (required)
  • description (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["disabled", "required", "phx-click", "phx-value-choice"].

Slots

  • icon - a mark at the start of the card.

radio(assigns)

Attributes

  • id (:string) (required)
  • name (:string) (required)
  • value (:string) (required)
  • checked (:boolean) - Defaults to false.
  • label (:string) (required)
  • description (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["disabled", "required", "phx-click", "phx-value-choice"].

select_all_state(total, total)

@spec select_all_state(non_neg_integer(), non_neg_integer()) :: :none | :some | :all

The state of a "select all" box: :none, :some (partial) or :all, from how many of total are ticked.