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