Class: Form::SwitchComponent

Inherits:
CheckboxComponent
  • Object
show all
Defined in:
app/components/spark/form/switch_component.rb

Instance Method Summary collapse

Instance Method Details

#before_renderObject



8
9
10
11
# File 'app/components/spark/form/switch_component.rb', line 8

def before_render
  add_class(size) if size
  add_class(join_class("align-#{align}")) if align
end

#input_attrsObject



24
25
26
27
28
# File 'app/components/spark/form/switch_component.rb', line 24

def input_attrs
  super.merge({
    class: join_class("input")
  })
end

#renderObject



13
14
15
16
17
18
19
20
21
22
# File 'app/components/spark/form/switch_component.rb', line 13

def render
  (:div, class: classnames) do
    component("form/label", text: label, class: join_class("label")) do
      concat(tag(:input, input_attrs))
      concat (:span, class: join_class("panel")) {
        (:span, nil, class: join_class("tick"))
      }
    end
  end
end