Class: Yattho::Beta::Spinner

Inherits:
Component
  • Object
show all
Defined in:
app/components/yattho/beta/spinner.rb

Overview

Use ‘Spinner` to let users know that content is being loaded.

Direct Known Subclasses

SpinnerComponent

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

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

Constructor Details

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

Returns a new instance of Spinner.

Examples:

Default

<%= render(Yattho::Beta::Spinner.new) %>

Small

<%= render(Yattho::Beta::Spinner.new(size: :small)) %>

Large

<%= render(Yattho::Beta::Spinner.new(size: :large)) %>

Parameters:

  • size (Symbol) (defaults to: DEFAULT_SIZE)

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

  • style (String) (defaults to: DEFAULT_STYLE)

    Custom element styles.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



33
34
35
36
37
38
39
40
41
42
# File 'app/components/yattho/beta/spinner.rb', line 33

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