Class: Pajamas::ButtonComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/pajamas/button_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(category: :primary, variant: :default, size: :medium, type: :button, disabled: false, loading: false, block: false, selected: false, icon: nil, href: nil, target: nil, method: nil, button_options: {}, button_text_classes: nil, icon_classes: nil) ⇒ ButtonComponent

Returns a new instance of ButtonComponent.

Parameters:

  • category (Symbol) (defaults to: :primary)
  • variant (Symbol) (defaults to: :default)
  • size (Symbol) (defaults to: :medium)
  • type (Symbol) (defaults to: :button)
  • disabled (Boolean) (defaults to: false)
  • loading (Boolean) (defaults to: false)
  • block (Boolean) (defaults to: false)
  • selected (Boolean) (defaults to: false)
  • icon (String) (defaults to: nil)
  • href (String) (defaults to: nil)
  • target (String) (defaults to: nil)
  • method (Symbol) (defaults to: nil)
  • button_options (Hash) (defaults to: {})
  • button_text_classes (String) (defaults to: nil)
  • icon_classes (String) (defaults to: nil)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/components/pajamas/button_component.rb', line 20

def initialize(
  category: :primary,
  variant: :default,
  size: :medium,
  type: :button,
  disabled: false,
  loading: false,
  block: false,
  selected: false,
  icon: nil,
  href: nil,
  target: nil,
  method: nil,
  button_options: {},
  button_text_classes: nil,
  icon_classes: nil
)
  @category = filter_attribute(category.to_sym, CATEGORY_OPTIONS)
  @variant = filter_attribute(variant.to_sym, VARIANT_OPTIONS)
  @size = filter_attribute(size.to_sym, SIZE_OPTIONS)
  @type = filter_attribute(type.to_sym, TYPE_OPTIONS, default: :button)
  @disabled = disabled
  @loading = loading
  @block = block
  @selected = selected
  @icon = icon
  @href = href
  @target = filter_attribute(target, TARGET_OPTIONS)
  @method = filter_attribute(method, METHOD_OPTIONS)
  @button_options = button_options
  @button_text_classes = button_text_classes
  @icon_classes = icon_classes
end