Class: IconButton::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- IconButton::Component
- Defined in:
- app/components/lookbook/icon_button/component.rb
Constant Summary collapse
- ICON_SIZES =
{ xs: 3, sm: 3.5, md: 4, lg: 6 }
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#tooltip ⇒ Object
readonly
Returns the value of attribute tooltip.
Instance Method Summary collapse
- #icon_size ⇒ Object
- #id ⇒ Object
-
#initialize(id: nil, 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(id: nil, icon: nil, tooltip: nil, disabled: false, size: :md, href: nil, **html_attrs) ⇒ Component
Returns a new instance of Component.
14 15 16 17 18 19 20 21 22 |
# File 'app/components/lookbook/icon_button/component.rb', line 14 def initialize(id: nil, icon: nil, tooltip: nil, disabled: false, size: :md, href: nil, **html_attrs) @id = id @icon = icon @tooltip = tooltip @disabled = disabled @size = size @href = href super(**html_attrs) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
12 13 14 |
# File 'app/components/lookbook/icon_button/component.rb', line 12 def disabled @disabled end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
12 13 14 |
# File 'app/components/lookbook/icon_button/component.rb', line 12 def href @href end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
12 13 14 |
# File 'app/components/lookbook/icon_button/component.rb', line 12 def icon @icon end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
12 13 14 |
# File 'app/components/lookbook/icon_button/component.rb', line 12 def size @size end |
#tooltip ⇒ Object (readonly)
Returns the value of attribute tooltip.
12 13 14 |
# File 'app/components/lookbook/icon_button/component.rb', line 12 def tooltip @tooltip end |
Instance Method Details
#icon_size ⇒ Object
28 29 30 |
# File 'app/components/lookbook/icon_button/component.rb', line 28 def icon_size ICON_SIZES[size] end |
#id ⇒ Object
24 25 26 |
# File 'app/components/lookbook/icon_button/component.rb', line 24 def id @id ||= Utils.temp_id(prefix: "button") end |
#padding ⇒ Object
32 33 34 |
# File 'app/components/lookbook/icon_button/component.rb', line 32 def padding [:xs, :sm].include?(size) ? "p-1" : "p-2" end |
#tag_name ⇒ Object
36 37 38 |
# File 'app/components/lookbook/icon_button/component.rb', line 36 def tag_name href.present? ? :a : :button end |