Sha256: 20e73fdaf3649fb0b14988732851adbe08431b0fa23797bd78015079275c0168

Contents?: true

Size: 1.09 KB

Versions: 46

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

# :nocov:
module Ariadne
  module Yard
    # :nodoc:
    class ComponentRef
      ATTR_DEFAULTS = {
        js: false,
        examples: true,
        form_component: false,
      }.freeze

      attr_reader :klass, :attrs

      def initialize(klass, attrs)
        @klass = klass
        @attrs = attrs
      end

      def requires_js?
        @attrs.fetch(:js, ATTR_DEFAULTS[:js])
      end

      def should_have_examples?
        @attrs.fetch(:examples, ATTR_DEFAULTS[:examples])
      end

      def form_component?
        @attrs.fetch(:form_component, ATTR_DEFAULTS[:form_component])
      end

      def source_url
        @source_url ||= begin
          path = klass.name.split("::").map(&:underscore).join("/")
          "https://github.com/primer/view_components/tree/main/app/components/#{path}.rb"
        end
      end

      def lookbook_url
        @lookbook_url ||= begin
          path = klass.name.underscore.gsub("_component", "")
          "https://ariadne.style/view-components/lookbook/inspect/#{path}/default/"
        end
      end
    end
  end
end
# :nocov:

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.92 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.91 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.90 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.89.1 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.89 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.88 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.87 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.9 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.8 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.7 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.6 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.5 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.4 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.3 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.2 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86.1 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.86 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.85 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.84 lib/ariadne/yard/component_ref.rb
ariadne_view_components-0.0.83.3 lib/ariadne/yard/component_ref.rb