Class: Button::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- Button::Component
- Defined in:
- app/components/lookbook/button/component.rb
Instance Attribute Summary collapse
-
#button_attrs ⇒ Object
readonly
Returns the value of attribute button_attrs.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #before_render ⇒ Object
- #button_component ⇒ Object
- #dropdown? ⇒ Boolean
- #icon_button? ⇒ Boolean
-
#initialize(id: nil, icon: nil, **html_attrs) ⇒ Component
constructor
A new instance of Component.
- #text_button? ⇒ Boolean
Constructor Details
#initialize(id: nil, icon: nil, **html_attrs) ⇒ Component
Returns a new instance of Component.
7 8 9 10 11 |
# File 'app/components/lookbook/button/component.rb', line 7 def initialize(id: nil, icon: nil, **html_attrs) @id = id @icon = icon @button_attrs = html_attrs end |
Instance Attribute Details
#button_attrs ⇒ Object (readonly)
Returns the value of attribute button_attrs.
5 6 7 |
# File 'app/components/lookbook/button/component.rb', line 5 def @button_attrs end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
5 6 7 |
# File 'app/components/lookbook/button/component.rb', line 5 def icon @icon end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'app/components/lookbook/button/component.rb', line 5 def id @id end |
Instance Method Details
#before_render ⇒ Object
25 26 27 28 29 |
# File 'app/components/lookbook/button/component.rb', line 25 def before_render if dropdown? && id.nil? raise "Dropdown buttons must be given an ID" end end |
#button_component ⇒ Object
31 32 33 |
# File 'app/components/lookbook/button/component.rb', line 31 def ? IconButton::Component : TextButton::Component end |
#dropdown? ⇒ Boolean
13 14 15 |
# File 'app/components/lookbook/button/component.rb', line 13 def dropdown? dropdown.present? end |
#icon_button? ⇒ Boolean
21 22 23 |
# File 'app/components/lookbook/button/component.rb', line 21 def ! && icon end |
#text_button? ⇒ Boolean
17 18 19 |
# File 'app/components/lookbook/button/component.rb', line 17 def content.present? end |