Sha256: 979bbf4e14d22eaf63166611ec424268a47fa411d6c2bebf2e56bd0e373a68d4

Contents?: true

Size: 1.63 KB

Versions: 26

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

module Primer
  module Beta
    # Use `Spinner` to let users know that content is being loaded.
    class Spinner < 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::Beta::Spinner.new) %>
      #
      # @example Small
      #   <%= render(Primer::Beta::Spinner.new(size: :small)) %>
      #
      # @example Large
      #   <%= render(Primer::Beta::Spinner.new(size: :large)) %>
      #
      # @param size [Symbol] <%= one_of(Primer::Beta::Spinner::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
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.6.3 app/components/primer/beta/spinner.rb
primer_view_components-0.6.0 app/components/primer/beta/spinner.rb
primer_view_components-0.5.1 app/components/primer/beta/spinner.rb
primer_view_components-0.5.0 app/components/primer/beta/spinner.rb
primer_view_components-0.4.0 app/components/primer/beta/spinner.rb
primer_view_components-0.3.1 app/components/primer/beta/spinner.rb
primer_view_components-0.3.0 app/components/primer/beta/spinner.rb
primer_view_components-0.2.0 app/components/primer/beta/spinner.rb
primer_view_components-0.1.9 app/components/primer/beta/spinner.rb
primer_view_components-0.1.8 app/components/primer/beta/spinner.rb
primer_view_components-0.1.7 app/components/primer/beta/spinner.rb
primer_view_components-0.1.6 app/components/primer/beta/spinner.rb
primer_view_components-0.1.5 app/components/primer/beta/spinner.rb
primer_view_components-0.1.4 app/components/primer/beta/spinner.rb
primer_view_components-0.1.3 app/components/primer/beta/spinner.rb
primer_view_components-0.1.2 app/components/primer/beta/spinner.rb
primer_view_components-0.1.1 app/components/primer/beta/spinner.rb
primer_view_components-0.1.0 app/components/primer/beta/spinner.rb
primer_view_components-0.0.123 app/components/primer/beta/spinner.rb
primer_view_components-0.0.122 app/components/primer/beta/spinner.rb