Class: Button::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- Button::Component
- 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
- #dropdown? ⇒ Boolean
- #icon_size ⇒ Object
-
#initialize(icon: nil, tooltip: nil, disabled: false, size: :md, href: nil, **html_attrs) ⇒ Component
constructor
A new instance of Component.
- #padding ⇒ Object
- #tag_name ⇒ Object
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
#dropdown? ⇒ Boolean
34 35 36 |
# File 'app/components/lookbook/button/component.rb', line 34 def dropdown? dropdown.present? end |
#icon_size ⇒ Object
22 23 24 |
# File 'app/components/lookbook/button/component.rb', line 22 def icon_size ICON_SIZES[@size] end |
#padding ⇒ Object
26 27 28 |
# File 'app/components/lookbook/button/component.rb', line 26 def padding [:xs, :sm].include?(@size) ? "p-1" : "p-2" end |
#tag_name ⇒ Object
30 31 32 |
# File 'app/components/lookbook/button/component.rb', line 30 def tag_name @href.present? ? :a : :button end |