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
-
#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: [], **options) ⇒ IconButtonComponent
constructor
A new instance of IconButtonComponent.
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(icon:, label:, classes: [], **options) ⇒ IconButtonComponent
Returns a new instance of IconButtonComponent.
7 8 9 10 11 12 13 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 7 def initialize(icon:, label:, classes: [], **) @icon = icon @label = label @classes = classes @options = super() end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
19 20 21 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 19 def label @label end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 19 def @options end |
Instance Method Details
#before_render ⇒ Object
15 16 17 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 15 def before_render raise SdrViewComponents::Error::UnknownComponentIcon, "Unknown icon type: #{@icon}" unless end |
#button_icon ⇒ Object
25 26 27 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 25 def helpers.public_send(:"#{@icon}_icon") end |
#classes ⇒ Object
21 22 23 |
# File 'app/components/sdr_view_components/elements/icon_button_component.rb', line 21 def classes merge_classes(%w[border border-0], @classes) end |