Class: ViewComponent::InputComponent::InputCheckboxComponent
- Inherits:
-
Object
- Object
- ViewComponent::InputComponent::InputCheckboxComponent
- Includes:
- ComponentHelper
- Defined in:
- app/helpers/view_component/input_component/input_checkbox_component.rb
Instance Attribute Summary collapse
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#error ⇒ Object
Returns the value of attribute error.
-
#form ⇒ Object
Returns the value of attribute form.
-
#html_options ⇒ Object
Returns the value of attribute html_options.
-
#label ⇒ Object
Returns the value of attribute label.
-
#label_position ⇒ Object
Returns the value of attribute label_position.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #box_style ⇒ Object
- #check_style ⇒ Object
-
#initialize(form:, name:, label:, value:, disabled:, error:, label_position:, html_options:) ⇒ InputCheckboxComponent
constructor
A new instance of InputCheckboxComponent.
- #label_style ⇒ Object
Methods included from ComponentHelper
Constructor Details
#initialize(form:, name:, label:, value:, disabled:, error:, label_position:, html_options:) ⇒ InputCheckboxComponent
Returns a new instance of InputCheckboxComponent.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 10 def initialize(form:, name:, label:, value:, disabled:, error:, label_position:, html_options:) self.form = form self.name = name self.label = label self.label_position = label_position self.value = value self. = self.disabled = disabled self.[:disabled] = disabled self.[:class] = 'hidden peer' self.error = resolve_error(form, name, error) end |
Instance Attribute Details
#disabled ⇒ Object
Returns the value of attribute disabled.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def disabled @disabled end |
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def error @error end |
#form ⇒ Object
Returns the value of attribute form.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def form @form end |
#html_options ⇒ Object
Returns the value of attribute html_options.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def end |
#label ⇒ Object
Returns the value of attribute label.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def label @label end |
#label_position ⇒ Object
Returns the value of attribute label_position.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def label_position @label_position end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 8 def value @value end |
Instance Method Details
#box_style ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 33 def box_style if disabled 'border-disabled-color' elsif error 'border-danger-dark' else 'border-slate-grey-50 group-hover:border-primary-light group-has-[input:checked]:border-primary' end end |
#check_style ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 43 def check_style if disabled 'hidden' elsif error 'hidden group-has-[input:checked]:flex group-has-[input:checked]:text-danger-dark' else 'hidden group-has-[input:checked]:flex group-has-[input:checked]:text-primary' end end |
#label_style ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/view_component/input_component/input_checkbox_component.rb', line 23 def label_style if disabled 'text-disabled-color' elsif error 'text-danger-dark' else 'text-letter-color group-has-[input:checked]:text-primary group-hover:text-primary-light' end end |