Search documentation of Plushie

# Plushie.Widget.QrCode (Plushie v0.7.2)

Copy Markdown View Source

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

## Props

Name | Type | Default | Description
--- | --- | --- | ---
`data` | `String.t() | atom()` | required | Data to encode in the QR code. Required.
`cell_size` | `number()` | `nil` | Size of each QR module in pixels. Default: 4.0.
`total_size` | `number()` | `nil` | Total size of the QR code in pixels. Derives cell_size from this.
`cell_color` | `String.t()` | `nil` | Color of dark modules. Default: black.
`background` | `String.t()` | `nil` | Color of light modules. Default: white.
`error_correction` | `:low | :medium | :quartile | :high` | `nil` | Error correction level: `:low`, `:medium`, `:quartile`, `:high`.
`alt` | `String.t() | atom()` | `nil` | Accessible label for the QR code.
`description` | `String.t() | atom()` | `nil` | Extended accessible description.
`event_rate` | `integer()` | `nil` | Max 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

### Types

option()
t()

### Functions

a11y(widget, descriptor)

Accessibility annotations.

alt(widget, descriptor)

Accessible label for the QR code.

background(widget, descriptor)

Color of light modules. Default: white.

build(widget)

Converts this widget struct to a `ui_node()` map.

cell_color(widget, descriptor)

Color of dark modules. Default: black.

cell_size(widget, descriptor)

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

data(widget, descriptor)

Data to encode in the QR code. Required.

description(widget, descriptor)

Extended accessible description.

error_correction(widget, descriptor)

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

event_rate(widget, descriptor)

Max events per second for coalescable events.

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

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

qr_code(id, opts \\ [])

Creates a `:qr_code` widget.

total_size(widget, descriptor)

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

with_options(widget, opts)

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.