Class: Primer::Beta::Spinner

Inherits:
Component
  • Object
show all
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
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

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

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

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments) ⇒ Spinner

Returns a new instance of Spinner.

Parameters:

  • size (Symbol) (defaults to: DEFAULT_SIZE)

    <%= one_of(Primer::Beta::Spinner::SIZE_MAPPINGS) %>

  • style (String) (defaults to: DEFAULT_STYLE)

    Custom element styles.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



25
26
27
28
29
30
31
32
33
34
# File 'app/components/primer/beta/spinner.rb', line 25

def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **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
end