Class: NitroKit::Switch
- Defined in:
- app/components/nitro_kit/switch.rb
Instance Attribute Summary collapse
-
#checked ⇒ Object
readonly
Returns the value of attribute checked.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from Component
Instance Method Summary collapse
-
#initialize(checked: false, size: :md, description: nil, **attrs) ⇒ Switch
constructor
A new instance of Switch.
- #view_template ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(checked: false, size: :md, description: nil, **attrs) ⇒ Switch
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/components/nitro_kit/switch.rb', line 5 def initialize( checked: false, size: :md, description: nil, **attrs ) @checked = checked @size = size @description = description super(**attrs) end |
Instance Attribute Details
#checked ⇒ Object (readonly)
Returns the value of attribute checked.
18 19 20 |
# File 'app/components/nitro_kit/switch.rb', line 18 def checked @checked end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
18 19 20 |
# File 'app/components/nitro_kit/switch.rb', line 18 def description @description end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
18 19 20 |
# File 'app/components/nitro_kit/switch.rb', line 18 def size @size end |
Instance Method Details
#view_template ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/nitro_kit/switch.rb', line 20 def view_template ( **mattr( **attrs, type: "button", class: [ base_class, size_class ], data: { controller: "nk--switch", action: "nk--switch#toggle" }, role: "switch", aria: { checked: checked.to_s } ) ) do span(class: "sr-only") { description } handle end end |