Class: Impulse::SpinnerComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Impulse::SpinnerComponent
- Defined in:
- app/components/impulse/spinner_component.rb
Constant Summary collapse
- DEFAULT_VARIANT =
:secondary- VARIANT_MAPPINGS =
{ :primary => "text-primary", DEFAULT_VARIANT => "text-secondary", :success => "text-success", :danger => "text-danger", :warning => "text-warning", :info => "text-info", :light => "text-light", :dark => "text-dark" }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(variant: DEFAULT_VARIANT, label: "Loading", **system_args) ⇒ SpinnerComponent
constructor
A new instance of SpinnerComponent.
Methods inherited from ApplicationComponent
Methods included from Helpers::AttributesHelper
Constructor Details
#initialize(variant: DEFAULT_VARIANT, label: "Loading", **system_args) ⇒ SpinnerComponent
Returns a new instance of SpinnerComponent.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/impulse/spinner_component.rb', line 15 def initialize(variant: DEFAULT_VARIANT, label: "Loading", **system_args) @system_args = system_args @system_args[:tag] ||= :div @system_args[:role] ||= :status @system_args[:"aria-label"] = label @system_args[:class] = class_names( system_args[:class], "spinner-border", VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant, DEFAULT_VARIANT)] ) end |
Instance Method Details
#call ⇒ Object
27 28 29 |
# File 'app/components/impulse/spinner_component.rb', line 27 def call render(Impulse::BaseRenderer.new(**@system_args)) end |