Class: Fluxbit::Form::CheckboxInputComponent
- Inherits:
-
Component
- Object
- Component
- Fluxbit::Form::CheckboxInputComponent
- Defined in:
- app/components/fluxbit/form/checkbox_input_component.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form: nil, field: nil, label: nil, helper_text: nil, helper_popover: nil, helper_popover_placement: "right", **props) ⇒ CheckboxInputComponent
constructor
rubocop: enable Layout/LineLength.
- #input ⇒ Object
Constructor Details
#initialize(form: nil, field: nil, label: nil, helper_text: nil, helper_popover: nil, helper_popover_placement: "right", **props) ⇒ CheckboxInputComponent
rubocop: enable Layout/LineLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/fluxbit/form/checkbox_input_component.rb', line 20 def initialize(form: nil, field: nil, label: nil, helper_text: nil, helper_popover: nil, helper_popover_placement: "right", **props) super @form = form @field = field @object = form&.object @props = props @label = label_value(label, @object, field, id) @helper_text = define_helper_text(helper_text, @object, field) @helper_popover = define_helper_popover(helper_popover, @object, field) @helper_popover_placement = helper_popover_placement @props[:type] = @props[:type].to_s.in?(%w[checkbox radio]) ? @props[:type].to_s : "checkbox" add(class: styles[:checkbox], to: @props, first_element: true) if @props[:type] == "checkbox" add(class: styles[:base], to: @props, first_element: true) end |
Instance Method Details
#call ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/components/fluxbit/form/checkbox_input_component.rb', line 45 def call if @helper_text content_tag :div, { class: "flex" } do concat content_tag(:div, input, { class: styles[:input_div] }) concat content_tag(:div, { class: styles[:helper_div] }) do concat label concat helper_text end end else content_tag :div, { class: styles[:no_helper_div] } do concat input concat label end end end |
#input ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/components/fluxbit/form/checkbox_input_component.rb', line 37 def input if @form.nil? content_tag :input, content, @props else @form.text_field(@field, **@props) end end |