Class: AtomicView::Components::ButtonComponent

Inherits:
AtomicView::Component show all
Defined in:
lib/atomic_view/components/button_component.rb

Overview

Button

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AtomicView::Component

#class_names

Constructor Details

#initialize(label_or_options = nil, options = nil) ⇒ ButtonComponent

Returns a new instance of ButtonComponent.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/atomic_view/components/button_component.rb', line 9

def initialize(label_or_options = nil, options = nil)
  super

  if label_or_options.is_a?(Hash)
    options = label_or_options
  else
    @label = label_or_options
    options ||= {}
  end

  @variant = options.delete(:variant)
  @size = options.delete(:size) || :md

  options[:class] = opts_to_class
  @options = options
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'lib/atomic_view/components/button_component.rb', line 7

def label
  @label
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'lib/atomic_view/components/button_component.rb', line 7

def size
  @size
end

#variantObject (readonly)

Returns the value of attribute variant.



7
8
9
# File 'lib/atomic_view/components/button_component.rb', line 7

def variant
  @variant
end

Instance Method Details

#callObject



26
27
28
29
30
31
32
# File 'lib/atomic_view/components/button_component.rb', line 26

def call
  if content?
    (:button, @options) { content }
  else
    (:button, label, @options)
  end
end