Class: SdrViewComponents::Elements::SpinnerComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Elements::SpinnerComponent
- Defined in:
- app/components/sdr_view_components/elements/spinner_component.rb
Overview
It spins.
Instance Attribute Summary collapse
-
#image_path ⇒ Object
readonly
Returns the value of attribute image_path.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#spinner_options ⇒ Object
readonly
Returns the value of attribute spinner_options.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(message: 'Loading...', message_classes: [], message_position: :right, hide_message: false, image_path: nil, variant: nil, classes: [], height: nil, width: nil, speed: 0.75, spinner_classes: ['mx-2'], **spinner_options) ⇒ SpinnerComponent
constructor
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength.
- #message_classes ⇒ Object
- #spinner_classes ⇒ Object
- #spinner_style ⇒ Object
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(message: 'Loading...', message_classes: [], message_position: :right, hide_message: false, image_path: nil, variant: nil, classes: [], height: nil, width: nil, speed: 0.75, spinner_classes: ['mx-2'], **spinner_options) ⇒ SpinnerComponent
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 7 def initialize(message: 'Loading...', message_classes: [], message_position: :right, hide_message: false, # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength image_path: nil, variant: nil, classes: [], height: nil, width: nil, speed: 0.75, spinner_classes: ['mx-2'], **) @message = @variant = variant @hide_message = @classes = classes @image_path = image_path # Optionally spin an image @height = height @width = width @message_classes = @speed = speed # In seconds, so a larger number is slower. The default (0.75) is the same as Bootstrap's default. @spinner_classes = spinner_classes @spinner_options = @message_position = # :bottom or :right super() end |
Instance Attribute Details
#image_path ⇒ Object (readonly)
Returns the value of attribute image_path.
25 26 27 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 25 def image_path @image_path end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
25 26 27 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 25 def @message end |
#spinner_options ⇒ Object (readonly)
Returns the value of attribute spinner_options.
25 26 27 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 25 def @spinner_options end |
Instance Method Details
#classes ⇒ Object
35 36 37 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 35 def classes merge_classes(@classes, 'd-flex', ) end |
#message_classes ⇒ Object
31 32 33 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 31 def merge_classes(@message_classes, @hide_message ? 'visually-hidden' : nil) end |
#spinner_classes ⇒ Object
27 28 29 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 27 def spinner_classes merge_classes('spinner-border', variant_class, border_class, @spinner_classes) end |
#spinner_style ⇒ Object
39 40 41 42 43 |
# File 'app/components/sdr_view_components/elements/spinner_component.rb', line 39 def spinner_style return unless @height && @width "height: #{@height}px; width: #{@width}px; --bs-spinner-animation-speed: #{@speed}s;" end |