Class: Panda::Core::Admin::ButtonComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/button_component.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text: "Button", action: nil, href: "#", icon: nil, size: :regular, id: nil, as_button: false, **attrs) ⇒ ButtonComponent

Returns a new instance of ButtonComponent.



7
8
9
10
11
12
13
14
15
16
# File 'app/components/panda/core/admin/button_component.rb', line 7

def initialize(text: "Button", action: nil, href: "#", icon: nil, size: :regular, id: nil, as_button: false, **attrs)
  @text = text
  @action = action
  @href = href
  @icon = icon
  @size = size
  @id = id
  @as_button = as_button
  super(**attrs)
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



18
19
20
# File 'app/components/panda/core/admin/button_component.rb', line 18

def action
  @action
end

#as_buttonObject (readonly)

Returns the value of attribute as_button.



18
19
20
# File 'app/components/panda/core/admin/button_component.rb', line 18

def as_button
  @as_button
end

#hrefObject (readonly)

Returns the value of attribute href.



18
19
20
# File 'app/components/panda/core/admin/button_component.rb', line 18

def href
  @href
end

#iconObject (readonly)

Returns the value of attribute icon.



18
19
20
# File 'app/components/panda/core/admin/button_component.rb', line 18

def icon
  @icon
end

#idObject (readonly)

Returns the value of attribute id.



18
19
20
# File 'app/components/panda/core/admin/button_component.rb', line 18

def id
  @id
end

#sizeObject (readonly)

Returns the value of attribute size.



18
19
20
# File 'app/components/panda/core/admin/button_component.rb', line 18

def size
  @size
end

#textObject (readonly)

Returns the value of attribute text.



18
19
20
# File 'app/components/panda/core/admin/button_component.rb', line 18

def text
  @text
end

Instance Method Details

#default_attrsObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/panda/core/admin/button_component.rb', line 20

def default_attrs
  base = {
    class: button_classes,
    id: @id
  }

  if @as_button
    base.merge(type: "button")
  else
    base.merge(href: @href)
  end
end