Class: Daisy::DataInput::SelectComponent::SelectOptionComponent
- Inherits:
-
LocoMotion::BasicComponent
- Object
- LocoMotion::BaseComponent
- LocoMotion::BasicComponent
- Daisy::DataInput::SelectComponent::SelectOptionComponent
- Defined in:
- app/components/daisy/data_input/select_component.rb
Overview
Inner component for rendering individual select options as <option>
elements.
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#selected ⇒ Object
Writable so the parent Daisy::DataInput::SelectComponent can default it from its
value:when the caller didn't set it explicitly (see #render_select_options). -
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#call ⇒ String
Renders the option element with the appropriate attributes.
-
#initialize(value:, label:, selected: nil, disabled: false, css: "", html: {}, **kws) ⇒ SelectOptionComponent
constructor
Initialize a new select option component.
Methods inherited from LocoMotion::BasicComponent
Constructor Details
#initialize(value:, label:, selected: nil, disabled: false, css: "", html: {}, **kws) ⇒ SelectOptionComponent
Initialize a new select option component.
rubocop:disable Metrics/ParameterLists
81 82 83 84 85 86 87 88 89 |
# File 'app/components/daisy/data_input/select_component.rb', line 81 def initialize(value:, label:, selected: nil, disabled: false, css: "", html: {}, **kws) @value = value @label = label @selected = selected @disabled = disabled @css = css @html = html super(**kws) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
55 56 57 |
# File 'app/components/daisy/data_input/select_component.rb', line 55 def disabled @disabled end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
55 56 57 |
# File 'app/components/daisy/data_input/select_component.rb', line 55 def label @label end |
#selected ⇒ Object
Writable so the parent Daisy::DataInput::SelectComponent can default it from its
value: when the caller didn't set it explicitly (see
Daisy::DataInput::SelectComponent#render_select_options).
60 61 62 |
# File 'app/components/daisy/data_input/select_component.rb', line 60 def selected @selected end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
55 56 57 |
# File 'app/components/daisy/data_input/select_component.rb', line 55 def value @value end |
Instance Method Details
#call ⇒ String
Renders the option element with the appropriate attributes.
97 98 99 100 101 102 103 104 |
# File 'app/components/daisy/data_input/select_component.rb', line 97 def call content_tag(:option, label, { value: value, selected: selected, disabled: disabled, class: @css }.merge(@html)) end |