Sha256: d9ce564cbb9b8f1b84a35661db55e434fefe570026fdf204829a233c4af7c09e

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require "view_component/version"

module Primer
  # @private
  class Component < ViewComponent::Base
    include ViewComponent::SlotableV2 unless ViewComponent::VERSION::STRING.to_f >= 2.28
    include ClassNameHelper
    include FetchOrFallbackHelper
    include TestSelectorHelper
    include JoinStyleArgumentsHelper
    include ViewHelper
    include Status::Dsl

    private

    def deprecated_component_warning(new_class: nil, version: nil)
      return if Rails.env.production? || silence_deprecations?

      message = "#{self.class.name} is deprecated"
      message += " and will be removed in v#{version}." if version
      message += " Use #{new_class.name} instead." if new_class

      ActiveSupport::Deprecation.warn(message)
    end

    def validate_aria_label
      aria_label = @system_arguments[:"aria-label"] || @system_arguments.dig(:aria, :label)
      raise ArgumentError, "`aria-label` is required." if aria_label.nil? && !Rails.env.production?
    end

    def silence_deprecations?
      Rails.application.config.primer_view_components.silence_deprecations
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
primer_view_components-0.0.41 app/components/primer/component.rb
primer_view_components-0.0.40 app/components/primer/component.rb