Plushie.Widget.QrCode (Plushie v0.7.0)

Copy Markdown View Source

QR Code, renders a QR code from a data string.

Props

NameTypeDefaultDescription
dataString.t() | atom()requiredData to encode in the QR code. Required.
cell_sizenumber()nilSize of each QR module in pixels. Default: 4.0.
total_sizenumber()nilTotal size of the QR code in pixels. Derives cell_size from this.
cell_colorString.t()nilColor of dark modules. Default: black.
backgroundString.t()nilColor of light modules. Default: white.
error_correction:low | :medium | :quartile | :highnilError correction level: :low, :medium, :quartile, :high.
altString.t() | atom()nilAccessible label for the QR code.
descriptionString.t() | atom()nilExtended accessible description.
event_rateinteger()nilMax events per second for coalescable events.
a11y%Plushie.Type.A11y{} | map() | keyword()%{role: :image}Accessibility annotations.

Constructor

QrCode.new(id, data)
QrCode.new(id, data, opts)

Summary

Functions

Accessibility annotations.

Accessible label for the QR code.

Color of light modules. Default: white.

Converts this widget struct to a ui_node() map.

Color of dark modules. Default: black.

Size of each QR module in pixels. Default: 4.0.

Data to encode in the QR code. Required.

Extended accessible description.

Error correction level: :low, :medium, :quartile, :high.

Max events per second for coalescable events.

Creates a new widget struct with the given positional args and keyword options.

Creates a :qr_code widget.

Total size of the QR code in pixels. Derives cell_size from this.

Applies keyword options to an existing widget struct.

Types

option()

@type option() ::
  ((((((({:cell_size, number()} | {:total_size, number()})
        | {:cell_color, atom() | String.t() | map()})
       | {:background, atom() | String.t() | map()})
      | {:error_correction, :low | :medium | :quartile | :high})
     | {:alt, String.t() | atom()})
    | {:description, String.t() | atom()})
   | {:event_rate, integer()})
  | {:a11y,
     %Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword()}

t()

@type t() :: %Plushie.Widget.QrCode{
  a11y:
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  alt:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  background:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  cell_color:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  cell_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  data:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  description:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  error_correction:
    (:low | :medium | :quartile | :high)
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  event_rate:
    integer()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t(),
  total_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil
}

Functions

a11y(widget, descriptor)

@spec a11y(
  widget :: t(),
  value ::
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | nil
) :: t()

Accessibility annotations.

Accepts %Plushie.Type.A11y{} | map() | keyword().

alt(widget, descriptor)

@spec alt(widget :: t(), value :: (String.t() | atom()) | nil) :: t()

Accessible label for the QR code.

Accepts String.t() | atom().

background(widget, descriptor)

@spec background(widget :: t(), value :: (atom() | String.t() | map()) | nil) :: t()

Color of light modules. Default: white.

Accepts String.t().

build(widget)

@spec build(widget :: t()) :: Plushie.Widget.ui_node()

Converts this widget struct to a ui_node() map.

cell_color(widget, descriptor)

@spec cell_color(widget :: t(), value :: (atom() | String.t() | map()) | nil) :: t()

Color of dark modules. Default: black.

Accepts String.t().

cell_size(widget, descriptor)

@spec cell_size(widget :: t(), value :: number() | nil) :: t()

Size of each QR module in pixels. Default: 4.0.

Accepts number().

data(widget, descriptor)

@spec data(widget :: t(), value :: (String.t() | atom()) | nil) :: t()

Data to encode in the QR code. Required.

Accepts String.t() | atom().

description(widget, descriptor)

@spec description(widget :: t(), value :: (String.t() | atom()) | nil) :: t()

Extended accessible description.

Accepts String.t() | atom().

error_correction(widget, descriptor)

@spec error_correction(
  widget :: t(),
  value :: (:low | :medium | :quartile | :high) | nil
) :: t()

Error correction level: :low, :medium, :quartile, :high.

Accepts :low | :medium | :quartile | :high.

event_rate(widget, descriptor)

@spec event_rate(widget :: t(), value :: integer() | nil) :: t()

Max events per second for coalescable events.

Accepts integer().

new(id, data, opts \\ [])

Creates a new widget struct with the given positional args and keyword options.

Arguments

  • id - unique widget identifier
  • data - Data to encode in the QR code. Required.
  • opts - keyword list of optional props

qr_code(id, opts \\ [])

(macro)

Creates a :qr_code widget.

Shorthand for new/2. Import this macro to use the widget name directly in view functions:

import Plushie.Widget.QrCode, only: [qr_code: 2]

qr_code("my-id", prop: value)

total_size(widget, descriptor)

@spec total_size(widget :: t(), value :: number() | nil) :: t()

Total size of the QR code in pixels. Derives cell_size from this.

Accepts number().

with_options(widget, opts)

@spec with_options(widget :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing widget struct.