Class: Primer::Beta::Spinner
- Defined in:
- app/components/primer/beta/spinner.rb
Overview
Use ‘Spinner` to let users know that content is being loaded.
Constant Summary collapse
- DEFAULT_SIZE =
:medium
- SIZE_MAPPINGS =
{ :small => 16, DEFAULT_SIZE => 32, :large => 64 }.freeze
- DEFAULT_SR_TEXT =
"Loading"
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys
- DEFAULT_STYLE =
Setting ‘box-sizing: content-box` allows consumers to add padding to the spinner without shrinking the icon
"box-sizing: content-box; color: var(--color-icon-primary);"
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
-
#initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, sr_text: DEFAULT_SR_TEXT, **system_arguments) ⇒ Spinner
constructor
A new instance of Spinner.
- #no_aria_label? ⇒ Boolean
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, sr_text: DEFAULT_SR_TEXT, **system_arguments) ⇒ Spinner
Returns a new instance of Spinner.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/primer/beta/spinner.rb', line 26 def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, sr_text: DEFAULT_SR_TEXT, **system_arguments) @system_arguments = deny_tag_argument(**system_arguments) @system_arguments[:tag] = :svg @system_arguments[:style] ||= style @system_arguments[:animation] = :rotate @system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)] @system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)] @system_arguments[:viewBox] = "0 0 16 16" @system_arguments[:fill] = :none @system_arguments[:aria] ||= {} @sr_text = sr_text if no_aria_label? @system_arguments[:aria][:hidden] = true else @system_arguments[:role] = "img" end @target = extract_data(:target, @system_arguments) @hidden = @system_arguments.delete(:hidden) end |
Instance Method Details
#no_aria_label? ⇒ Boolean
48 49 50 51 |
# File 'app/components/primer/beta/spinner.rb', line 48 def no_aria_label? !@system_arguments[:aria][:label] && !@system_arguments[:"aria-label"] && !@system_arguments[:aria][:labelledby] && !@system_arguments[:"aria-labelledby"] end |