Class: SdrViewComponents::Elements::ButtonComponent

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

Overview

Generic button component

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#args_for, #merge_actions, #merge_classes

Constructor Details

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

rubocop:disable Metrics/ParameterLists



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

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

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



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

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
28
# File 'app/components/sdr_view_components/elements/button_component.rb', line 19

def call
  tag.button(
    class: ComponentSupport::ButtonSupport.classes(variant: @variant, size: @size, classes: @classes,
                                                   bordered: @bordered),
    type: 'button',
    **options
  ) do
    label || content
  end
end