Class: Bs5::SpinnerComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bs5::SpinnerComponent
- Includes:
- ActiveModel::Validations
- Defined in:
- app/components/bs5/spinner_component.rb
Constant Summary collapse
- STYLES =
%i[primary secondary success danger warning info light dark].freeze
- SIZES =
{ small: :sm, large: :lg }.freeze
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #before_render ⇒ Object
- #component_attributes ⇒ Object
- #component_class ⇒ Object
-
#initialize(options = {}) ⇒ SpinnerComponent
constructor
A new instance of SpinnerComponent.
Constructor Details
#initialize(options = {}) ⇒ SpinnerComponent
Returns a new instance of SpinnerComponent.
13 14 15 16 17 18 19 20 |
# File 'app/components/bs5/spinner_component.rb', line 13 def initialize( = {}) @options = .symbolize_keys @text = @options.delete(:text) @color = @options.delete(:color)&.to_sym @grow = @options.delete(:grow) @size = @options.delete(:size)&.to_sym end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
8 9 10 |
# File 'app/components/bs5/spinner_component.rb', line 8 def color @color end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'app/components/bs5/spinner_component.rb', line 8 def @options end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
8 9 10 |
# File 'app/components/bs5/spinner_component.rb', line 8 def size @size end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
8 9 10 |
# File 'app/components/bs5/spinner_component.rb', line 8 def text @text end |
Instance Method Details
#before_render ⇒ Object
22 23 24 |
# File 'app/components/bs5/spinner_component.rb', line 22 def before_render raise errors..to_sentence if invalid? end |
#component_attributes ⇒ Object
26 27 28 29 30 |
# File 'app/components/bs5/spinner_component.rb', line 26 def component_attributes [:class] = component_class [:role] = 'status' end |
#component_class ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/components/bs5/spinner_component.rb', line 32 def component_class class_names = Array([:class]) class_names << shape_class class_names << contextual_class class_names << size_class class_names.compact.join(' ') end |