Sha256: 0355abd04f9bf59b4a5ca64d593bb96e3503afc20beddf0f1f424ceafa0b0323

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

module Primer
  class OcticonComponent < Primer::Component
    include Primer::ClassNameHelper
    include OcticonsHelper

    SIZE_DEFAULT = :small
    SIZE_MAPPINGS = {
      SIZE_DEFAULT => 16,
      :medium => 32,
      :large => 64,
    }.freeze
    SIZE_OPTIONS = SIZE_MAPPINGS.keys

    def initialize(icon:, size: SIZE_DEFAULT, **kwargs)
      @icon, @kwargs = icon, kwargs

      @kwargs[:height] = SIZE_MAPPINGS[size.to_sym]
      @kwargs[:class] = class_names(@kwargs[:class], Primer::Classify.call(**@kwargs)[:class])
    end

    def call
      octicon(@icon, **@kwargs)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
primer_view_components-0.0.8 app/components/primer/octicon_component.rb