Class: SliderComponent

Inherits:
Component show all
Defined in:
app/components/slider_component.rb

Overview

Slider — range slider control.

Usage:

Slider(min: 0, max: 100, value: 50, name: "volume")
Slider(min: 0, max: 10, step: 1, labeled: true, color: :blue)

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/components/slider_component.rb', line 21

def to_s
  classes = class_names(
    "ui",
    color,
    { "labeled" => labeled,
      "vertical" => vertical,
      "reversed" => reversed,
      "disabled" => disabled },
    "slider"
  )

  data = {
    controller: "fui-slider",
    fui_slider_min_value: min,
    fui_slider_max_value: max,
    fui_slider_start_value: value,
    fui_slider_step_value: step
  }

  name_el = name ? tag.input(type: "hidden", name: name, value: value) : nil

  tag.div(class: classes, data: data) {
    safe_join([ name_el, @content ])
  }
end