Class: AtomicView::Components::ButtonComponent
- Inherits:
-
ViewComponent::Form::ButtonComponent
- Object
- ViewComponent::Form::ButtonComponent
- 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(form, label_or_options = nil, options = nil) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Constructor Details
#initialize(form, 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 |
# File 'lib/atomic_view/components/button_component.rb', line 9 def initialize(form, = nil, = nil) super if .is_a?(String) @label = @options ||= {} elsif .is_a?(Hash) @options = end @variant = @options.delete(:variant) || :primary 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
22 23 24 25 26 27 28 29 30 |
# File 'lib/atomic_view/components/button_component.rb', line 22 def call @options[:class] = class_names(base_classes, variant_classes, @options[:class]) if content? content_tag(:button, @options) { content } else content_tag(:button, label, @options) end end |