Class: SdrViewComponents::Elements::IconButtonLinkComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/sdr_view_components/elements/icon_button_link_component.rb

Overview

Component for a button which is an icon

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#args_for, #merge_actions, #merge_classes

Constructor Details

#initialize(icon:, label:, classes: [], icon_classes: [], link: nil, **options) ⇒ IconButtonLinkComponent

rubocop:disable Metrics/ParameterLists



7
8
9
10
11
12
13
14
15
# File 'app/components/sdr_view_components/elements/icon_button_link_component.rb', line 7

def initialize(icon:, label:, classes: [], icon_classes: [], link: nil, **options) # rubocop:disable Metrics/ParameterLists
  @icon = icon
  @label = label
  @classes = classes
  @link = link
  @options = options
  @icon_classes = icon_classes
  super()
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



17
18
19
# File 'app/components/sdr_view_components/elements/icon_button_link_component.rb', line 17

def label
  @label
end

Returns the value of attribute link.



17
18
19
# File 'app/components/sdr_view_components/elements/icon_button_link_component.rb', line 17

def link
  @link
end

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'app/components/sdr_view_components/elements/icon_button_link_component.rb', line 17

def options
  @options
end

Instance Method Details

#button_iconObject



23
24
25
# File 'app/components/sdr_view_components/elements/icon_button_link_component.rb', line 23

def button_icon
  helpers.public_send(:"#{@icon}_icon", classes: @icon_classes)
end

#classesObject



19
20
21
# File 'app/components/sdr_view_components/elements/icon_button_link_component.rb', line 19

def classes
  merge_classes(%w[border border-0], @classes)
end