Class: Button::Component

Inherits:
Lookbook::BaseComponent
  • Object
show all
Defined in:
app/components/lookbook/button/component.rb

Constant Summary collapse

ICON_SIZES =
{
  xs: 3,
  sm: 3.5,
  md: 4,
  lg: 6
}

Instance Method Summary collapse

Constructor Details

#initialize(icon: nil, tooltip: nil, disabled: false, size: :md, href: nil, **html_attrs) ⇒ Component

Returns a new instance of Component.



13
14
15
16
17
18
19
20
# File 'app/components/lookbook/button/component.rb', line 13

def initialize(icon: nil, tooltip: nil, disabled: false, size: :md, href: nil, **html_attrs)
  @icon = icon
  @tooltip = tooltip
  @disabled = disabled
  @size = size
  @href = href
  super(**html_attrs)
end

Instance Method Details

Returns:

  • (Boolean)


34
35
36
# File 'app/components/lookbook/button/component.rb', line 34

def dropdown?
  dropdown.present?
end

#icon_sizeObject



22
23
24
# File 'app/components/lookbook/button/component.rb', line 22

def icon_size
  ICON_SIZES[@size]
end

#paddingObject



26
27
28
# File 'app/components/lookbook/button/component.rb', line 26

def padding
  [:xs, :sm].include?(@size) ? "p-1" : "p-2"
end

#tag_nameObject



30
31
32
# File 'app/components/lookbook/button/component.rb', line 30

def tag_name
  @href.present? ? :a : :button
end