Class: AtomicView::Components::ButtonComponent
- Inherits:
-
AtomicView::Component
- Object
- ViewComponent::Base
- AtomicView::Component
- AtomicView::Components::ButtonComponent
- Defined in:
- lib/atomic_view/components/button_component.rb
Overview
Button
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(label_or_options = nil, options = nil) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Methods inherited from AtomicView::Component
Constructor Details
#initialize(label_or_options = nil, options = nil) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/atomic_view/components/button_component.rb', line 9 def initialize( = nil, = nil) super if .is_a?(Hash) = else @label = ||= {} end @variant = .delete(:variant) @size = .delete(:size) || :md [:class] = opts_to_class @options = end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/atomic_view/components/button_component.rb', line 7 def label @label end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/atomic_view/components/button_component.rb', line 7 def size @size end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
7 8 9 |
# File 'lib/atomic_view/components/button_component.rb', line 7 def variant @variant end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/atomic_view/components/button_component.rb', line 26 def call if content? content_tag(:button, @options) { content } else content_tag(:button, label, @options) end end |