Class: IronAdmin::Form::CheckboxComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Form::CheckboxComponent
- Includes:
- Concerns::FormInputBehavior
- Defined in:
- app/components/iron_admin/form/checkbox_component.rb
Overview
Renders a checkbox input.
Instance Attribute Summary collapse
-
#checked ⇒ Boolean
readonly
Whether checkbox is checked.
-
#label ⇒ String?
readonly
Label text.
-
#name ⇒ String
readonly
Checkbox name attribute.
Instance Method Summary collapse
-
#checkbox_classes ⇒ String
private
CSS classes for checkbox input.
-
#initialize(name:, checked: false, label: nil, disabled: false, field: nil, current_user: nil) ⇒ CheckboxComponent
constructor
A new instance of CheckboxComponent.
-
#label_classes ⇒ String
private
CSS classes for label text.
Constructor Details
#initialize(name:, checked: false, label: nil, disabled: false, field: nil, current_user: nil) ⇒ CheckboxComponent
Returns a new instance of CheckboxComponent.
31 32 33 34 35 36 37 38 |
# File 'app/components/iron_admin/form/checkbox_component.rb', line 31 def initialize(name:, checked: false, label: nil, disabled: false, field: nil, current_user: nil) @name = name @checked = checked @label = label @disabled = disabled @field = field @current_user = current_user end |
Instance Attribute Details
#checked ⇒ Boolean (readonly)
Returns Whether checkbox is checked.
20 21 22 |
# File 'app/components/iron_admin/form/checkbox_component.rb', line 20 def checked @checked end |
#label ⇒ String? (readonly)
Returns Label text.
23 24 25 |
# File 'app/components/iron_admin/form/checkbox_component.rb', line 23 def label @label end |
#name ⇒ String (readonly)
Returns Checkbox name attribute.
17 18 19 |
# File 'app/components/iron_admin/form/checkbox_component.rb', line 17 def name @name end |
Instance Method Details
#checkbox_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for checkbox input.
42 43 44 45 |
# File 'app/components/iron_admin/form/checkbox_component.rb', line 42 def checkbox_classes "h-4 w-4 rounded border-gray-300 text-indigo-600 #{theme.checkbox_checked} " \ "transition duration-150 ease-in-out" end |
#label_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for label text.
49 50 51 |
# File 'app/components/iron_admin/form/checkbox_component.rb', line 49 def label_classes "text-sm #{theme.body_text}" end |