Class: SdrViewComponents::Elements::ButtonLinkComponent

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

Overview

Component for a button that is a link

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#args_for, #merge_actions, #merge_classes

Constructor Details

#initialize(link:, label: nil, variant: :primary, classes: [], bordered: true, size: nil, **options) ⇒ ButtonLinkComponent

rubocop:disable Metrics/ParameterLists



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

def initialize(link:, label: nil, variant: :primary, classes: [], bordered: true, size: nil, **options) # rubocop:disable Metrics/ParameterLists
  @link = link
  @label = label
  @variant = variant
  @options = options
  @classes = classes
  @bordered = bordered
  @size = size
  super()
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



18
19
20
# File 'app/components/sdr_view_components/elements/button_link_component.rb', line 18

def label
  @label
end

Returns the value of attribute link.



18
19
20
# File 'app/components/sdr_view_components/elements/button_link_component.rb', line 18

def link
  @link
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
# File 'app/components/sdr_view_components/elements/button_link_component.rb', line 20

def call
  link_to(link, class: ComponentSupport::ButtonSupport.classes(classes: @classes, variant: @variant,
                                                               bordered: @bordered, size: @size),
                **@options) do
    label || content
  end
end