Class: SdrViewComponents::Elements::IconButtonComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Elements::IconButtonComponent
- Defined in:
- app/components/sdr_view_components/elements/icon_button_component.rb
Overview
Component for a button which is an icon
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #before_render ⇒ Object
- #button_icon ⇒ Object
- #classes ⇒ Object
-
#initialize(icon:, label:, classes: [], disabled: false, **options) ⇒ IconButtonComponent
constructor
A new instance of IconButtonComponent.
Methods inherited from BaseComponent
#args_for, #mark_label_required, #merge_actions, #merge_classes
Constructor Details
#initialize(icon:, label:, classes: [], disabled: false, **options) ⇒ IconButtonComponent
Returns a new instance of IconButtonComponent.
7 8 9 10 11 12 13 14 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 7 def initialize(icon:, label:, classes: [], disabled: false, **) @icon = icon @label = label @classes = classes @disabled = disabled @options = super() end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
20 21 22 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 20 def disabled @disabled end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
20 21 22 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 20 def label @label end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 20 def @options end |
Instance Method Details
#before_render ⇒ Object
16 17 18 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 16 def before_render raise SdrViewComponents::Error::UnknownComponentIcon, "Unknown icon type: #{@icon}" unless end |
#button_icon ⇒ Object
26 27 28 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 26 def helpers.public_send(:"#{@icon}_icon") end |
#classes ⇒ Object
22 23 24 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 22 def classes merge_classes(%w[border border-0], @classes) end |