Class: Arara::SelectItemComponent
- Inherits:
-
ActionView::Component::Base
- Object
- ActionView::Component::Base
- Arara::SelectItemComponent
- Includes:
- BaseComponent
- Defined in:
- app/components/arara/select_item_component.rb
Instance Attribute Summary collapse
-
#blank ⇒ Object
readonly
Returns the value of attribute blank.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#selected ⇒ Object
readonly
Returns the value of attribute selected.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #default_html_class ⇒ Object
- #html_options ⇒ Object
-
#initialize(value: nil, label: nil, blank: false, selected: false, disabled: false, **kw) ⇒ SelectItemComponent
constructor
A new instance of SelectItemComponent.
Methods included from BaseComponent
#default_data_controller, #default_html_tag, #html_class, #html_content, #html_data, #html_tag, included
Constructor Details
#initialize(value: nil, label: nil, blank: false, selected: false, disabled: false, **kw) ⇒ SelectItemComponent
Returns a new instance of SelectItemComponent.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/arara/select_item_component.rb', line 11 def initialize(value: nil, label: nil, blank: false, selected: false, disabled: false, **kw) super(tag: "li", **kw) @value = value @label = label @blank = blank @disabled = disabled @selected = selected if blank @value = "" label = nil end end |
Instance Attribute Details
#blank ⇒ Object (readonly)
Returns the value of attribute blank.
4 5 6 |
# File 'app/components/arara/select_item_component.rb', line 4 def blank @blank end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
4 5 6 |
# File 'app/components/arara/select_item_component.rb', line 4 def disabled @disabled end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'app/components/arara/select_item_component.rb', line 4 def label @label end |
#selected ⇒ Object (readonly)
Returns the value of attribute selected.
4 5 6 |
# File 'app/components/arara/select_item_component.rb', line 4 def selected @selected end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'app/components/arara/select_item_component.rb', line 4 def value @value end |
Instance Method Details
#default_html_class ⇒ Object
25 26 27 28 |
# File 'app/components/arara/select_item_component.rb', line 25 def default_html_class return "mdc-list-item mdc-list-item--selected" if selected "mdc-list-item" end |
#html_options ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/arara/select_item_component.rb', line 30 def opts = super opts[:data] ||= {} opts[:aria] ||= {} opts[:role] = "option" opts[:aria][:selected] = selected opts[:tabindex] = "-1" opts[:data][:value] = value opts[:disabled] = "" if disabled opts end |