Sha256: a1c23bb26c9ec3356d4075cb47b88e0a6dcd71d1ffaad81068a5adfe037322e8

Contents?: true

Size: 1.56 KB

Versions: 51

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module Primer
  # Use `Spinner` to let users know that content is being loaded.
  class SpinnerComponent < Primer::Component
    status :beta

    DEFAULT_SIZE = :medium
    SIZE_MAPPINGS = {
      :small => 16,
      DEFAULT_SIZE => 32,
      :large => 64
    }.freeze
    SIZE_OPTIONS = SIZE_MAPPINGS.keys
    # Setting `box-sizing: content-box` allows consumers to add padding
    # to the spinner without shrinking the icon
    DEFAULT_STYLE = "box-sizing: content-box; color: var(--color-icon-primary);"

    #
    # @example Default
    #   <%= render(Primer::SpinnerComponent.new) %>
    #
    # @example Small
    #   <%= render(Primer::SpinnerComponent.new(size: :small)) %>
    #
    # @example Large
    #   <%= render(Primer::SpinnerComponent.new(size: :large)) %>
    #
    # @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
    # @param style [String] Custom element styles.
    # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
    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
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
primer_view_components-0.0.94 app/components/primer/spinner_component.rb
primer_view_components-0.0.93 app/components/primer/spinner_component.rb
primer_view_components-0.0.92 app/components/primer/spinner_component.rb
primer_view_components-0.0.91 app/components/primer/spinner_component.rb
primer_view_components-0.0.90 app/components/primer/spinner_component.rb
primer_view_components-0.0.89 app/components/primer/spinner_component.rb
primer_view_components-0.0.88 app/components/primer/spinner_component.rb
primer_view_components-0.0.87 app/components/primer/spinner_component.rb
primer_view_components-0.0.86 app/components/primer/spinner_component.rb
primer_view_components-0.0.85 app/components/primer/spinner_component.rb
primer_view_components-0.0.84 app/components/primer/spinner_component.rb
primer_view_components-0.0.83 app/components/primer/spinner_component.rb
primer_view_components-0.0.82 app/components/primer/spinner_component.rb
primer_view_components-0.0.81 app/components/primer/spinner_component.rb
primer_view_components-0.0.80 app/components/primer/spinner_component.rb
primer_view_components-0.0.79 app/components/primer/spinner_component.rb
primer_view_components-0.0.78 app/components/primer/spinner_component.rb
primer_view_components-0.0.77 app/components/primer/spinner_component.rb
primer_view_components-0.0.76 app/components/primer/spinner_component.rb
primer_view_components-0.0.75 app/components/primer/spinner_component.rb