Class: Primer::Forms::ToggleSwitch
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Primer::Forms::ToggleSwitch
- Defined in:
- app/lib/primer/forms/toggle_switch.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(input:) ⇒ ToggleSwitch
constructor
A new instance of ToggleSwitch.
- #label_id ⇒ Object
Methods inherited from BaseComponent
compile!, #content, #input?, #perform_render, #render?, #to_component, #type
Methods included from ActsAsComponent
#compile!, extended, #renders_templates
Methods included from ClassNameHelper
Constructor Details
#initialize(input:) ⇒ ToggleSwitch
Returns a new instance of ToggleSwitch.
9 10 11 12 13 14 |
# File 'app/lib/primer/forms/toggle_switch.rb', line 9 def initialize(input:) @input = input @input.add_label_classes("FormControl-label") @input.label_arguments[:id] = label_id @input.add_input_aria(:labelledby, label_id) end |
Instance Method Details
#label_id ⇒ Object
16 17 18 |
# File 'app/lib/primer/forms/toggle_switch.rb', line 16 def label_id @label_id ||= "label-#{@input.base_id}" end |