Class: Polaris::SpinnerComponent

Inherits:
Component
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/components/polaris/spinner_component.rb

Constant Summary collapse

SIZE_DEFAULT =
:large
SIZE_MAPPINGS =
{
  small: "Polaris-Spinner--sizeSmall",
  large: "Polaris-Spinner--sizeLarge"
}
SIZE_OPTIONS =
SIZE_MAPPINGS.keys

Constants included from ViewHelper

ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ViewHelper

#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source

Methods included from StylesListHelper

#styles_list

Methods included from OptionHelper

#append_option, #prepend_option

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(accessibility_label: nil, size: SIZE_DEFAULT, has_focusable_parent: false, **system_arguments) ⇒ SpinnerComponent

Returns a new instance of SpinnerComponent.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/polaris/spinner_component.rb', line 18

def initialize(
  accessibility_label: nil,
  size: SIZE_DEFAULT,
  has_focusable_parent: false,
  **system_arguments
)
  @accessibility_label = accessibility_label
  @has_focusable_parent = has_focusable_parent
  @size = size

  @system_arguments = system_arguments
  @system_arguments[:tag] = :span
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "Polaris-Spinner",
    SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
  )
end

Instance Attribute Details

#has_focusable_parentObject (readonly)

Returns the value of attribute has_focusable_parent.



7
8
9
# File 'app/components/polaris/spinner_component.rb', line 7

def has_focusable_parent
  @has_focusable_parent
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'app/components/polaris/spinner_component.rb', line 7

def size
  @size
end

Instance Method Details

#render_accessibility?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/components/polaris/spinner_component.rb', line 47

def render_accessibility?
  !@has_focusable_parent && @accessibility_label.present?
end

#span_argumentsObject



37
38
39
40
41
42
43
44
45
# File 'app/components/polaris/spinner_component.rb', line 37

def span_arguments
  arguments = {
    tag: :span
  }

  arguments[:role] = :status unless @has_focusable_parent

  arguments
end