LedgerUI.Components.Range (LedgerUI v0.2.0)

Copy Markdown View Source

Range slider: a rounded track with a round thumb, one value or a range of two.

<.range name="volume" value={50} color="primary" />
<.range field={@form[:level]} label="Level" min={0} max={10} size="lg" show_value />
<.range name="discount" label="Desconto" value={12} max={30} show_value value_format="%{value}%" />
<.range start_name="from" end_name="to" value={{40, 280}} min={0} max={500} />
<.range name="weight" orientation="vertical" value={40} />

The slider is the design's lu-sl (.tr track, .fl fill, .th thumbs). The LedgerUI.Range hook (priv/static/ledger_ui/hooks/range.js) drags the thumbs, takes the arrow keys, Home, End and Page Up/Down (it adds role="slider" and the ARIA values to the thumbs), keeps the value text, the fill and the marks in step, and writes the value to hidden inputs named like the field, firing a bubbling input event so phx-change runs.

Deviations from the README: color has no default (no c-* class, the neutral look) and filled defaults to true (filled={false} is the design's "sem filled"); the value is not a native <input type="range"> but hidden inputs.

Summary

Functions

Renders a range slider.

Same as range/1 (same attributes and slots), under the name the design vitrine uses.

Functions

range(assigns)

Renders a range slider.

Attributes

  • id (:string) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • value (:any)
  • field (Phoenix.HTML.FormField) - Defaults to nil.
  • min (:any) - Defaults to 0.
  • max (:any) - Defaults to 100.
  • step (:any) - Defaults to 1.
  • color (:string) - Defaults to nil.Must be one of nil, "neutral", "primary", "secondary", "info", "success", "warning", or "error".
  • size (:string) - Defaults to "md". Must be one of "sm", "md", or "lg".
  • fill (:string) - Defaults to nil.
  • variant (:string) - Defaults to "canvas". Must be one of "canvas", or "classic".
  • start_field (Phoenix.HTML.FormField) - Defaults to nil.
  • end_field (Phoenix.HTML.FormField) - Defaults to nil.
  • start_name (:string) - Defaults to nil.
  • end_name (:string) - Defaults to nil.
  • orientation (:string) - Defaults to "horizontal". Must be one of "horizontal", or "vertical".
  • height (:string) - Defaults to "8rem".
  • filled (:boolean) - Defaults to true.
  • show_value (:boolean) - Defaults to false.
  • value_format (:string) - Defaults to "%{value}".
  • marks (:list) - Defaults to [].
  • steppers (:boolean) - Defaults to false.
  • decrease_label (:string) - Defaults to "Decrease".
  • increase_label (:string) - Defaults to "Increase".
  • label (:string) - Defaults to nil.
  • label_class (:any) - Defaults to nil.
  • help (:string) - Defaults to nil.
  • errors (:list) - Defaults to [].
  • disabled (:boolean) - Defaults to false.
  • wrapper_class (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

range_slider(assigns)

Same as range/1 (same attributes and slots), under the name the design vitrine uses.

Attributes

  • id (:string) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • value (:any)
  • field (Phoenix.HTML.FormField) - Defaults to nil.
  • min (:any) - Defaults to 0.
  • max (:any) - Defaults to 100.
  • step (:any) - Defaults to 1.
  • color (:string) - Defaults to nil.Must be one of nil, "neutral", "primary", "secondary", "info", "success", "warning", or "error".
  • size (:string) - Defaults to "md". Must be one of "sm", "md", or "lg".
  • fill (:string) - Defaults to nil.
  • variant (:string) - Defaults to "canvas". Must be one of "canvas", or "classic".
  • start_field (Phoenix.HTML.FormField) - Defaults to nil.
  • end_field (Phoenix.HTML.FormField) - Defaults to nil.
  • start_name (:string) - Defaults to nil.
  • end_name (:string) - Defaults to nil.
  • orientation (:string) - Defaults to "horizontal". Must be one of "horizontal", or "vertical".
  • height (:string) - Defaults to "8rem".
  • filled (:boolean) - Defaults to true.
  • show_value (:boolean) - Defaults to false.
  • value_format (:string) - Defaults to "%{value}".
  • marks (:list) - Defaults to [].
  • steppers (:boolean) - Defaults to false.
  • decrease_label (:string) - Defaults to "Decrease".
  • increase_label (:string) - Defaults to "Increase".
  • label (:string) - Defaults to nil.
  • label_class (:any) - Defaults to nil.
  • help (:string) - Defaults to nil.
  • errors (:list) - Defaults to [].
  • disabled (:boolean) - Defaults to false.
  • wrapper_class (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.