Class: Form::SwitchComponent
- Inherits:
-
CheckboxComponent
- Object
- CheckboxComponent
- Form::SwitchComponent
- Defined in:
- app/components/spark/form/switch_component.rb
Constant Summary collapse
- SIZE =
i[small medium].freeze
- ALIGNMENT =
i[left right].freeze
Instance Method Summary collapse
Instance Method Details
#before_render ⇒ Object
11 12 13 14 |
# File 'app/components/spark/form/switch_component.rb', line 11 def before_render add_class(size) add_class(join_class("align-#{align}")) if align end |
#input_attrs ⇒ Object
27 28 29 30 31 |
# File 'app/components/spark/form/switch_component.rb', line 27 def input_attrs super.merge({ class: join_class("input") }) end |
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/spark/form/switch_component.rb', line 16 def render content_tag(:div, class: classnames) do component("form/label", text: label, class: join_class("label")) do concat(tag(:input, input_attrs)) concat content_tag(:span, class: join_class("panel")) { content_tag(:span, nil, class: join_class("tick")) } end end end |