Class: ElementComponent::Components::Spinner

Inherits:
Element
  • Object
show all
Defined in:
lib/element_component/components/spinner.rb

Constant Summary collapse

VALID_VARIANTS =
%i[primary secondary success danger warning info light dark].freeze
VALID_TYPES =
%i[border grow].freeze

Instance Attribute Summary

Attributes inherited from Element

#attributes, #contents, #element, #html

Instance Method Summary collapse

Methods inherited from Element

#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #reset_attributes!, #reset_contents!

Constructor Details

#initialize(type: :border, variant: nil, **attributes, &block) ⇒ Spinner

Returns a new instance of Spinner.



9
10
11
12
13
14
15
16
# File 'lib/element_component/components/spinner.rb', line 9

def initialize(type: :border, variant: nil, **attributes, &block)
  super("div", &block)

  add_attribute(class: "spinner-#{type}")
  add_attribute(class: "text-#{variant}") if variant
  add_attribute(role: "status")
  add_attribute(attributes) unless attributes.empty?
end