Sha256: 30f118653f8ef45fe887e062b019353e60a087907212f9fd1ab2140f7185a2d3

Contents?: true

Size: 844 Bytes

Versions: 108

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

module Primer
  module Beta
    # Use `Markdown` to wrap markdown content.
    class Markdown < Primer::Component
      status :beta

      DEFAULT_TAG = :div
      TAG_OPTIONS = [DEFAULT_TAG, :article, :td].freeze

      # @param tag [Symbol] <%= one_of(Primer::Beta::Markdown::TAG_OPTIONS) %>
      # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
      def initialize(tag: DEFAULT_TAG, **system_arguments)
        @system_arguments = system_arguments
        @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)

        @system_arguments[:classes] = class_names(
          "markdown-body",
          system_arguments[:classes]
        )
      end

      def call
        render(Primer::BaseComponent.new(**@system_arguments)) { content }
      end
    end
  end
end

Version data entries

108 entries across 108 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.19.0 app/components/primer/beta/markdown.rb
primer_view_components-0.15.1 app/components/primer/beta/markdown.rb
primer_view_components-0.15.0 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.18.1 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.17.1 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.17.0 app/components/primer/beta/markdown.rb
primer_view_components-0.14.0 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.16.0 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.15.0 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.14.0 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.13.1 app/components/primer/beta/markdown.rb
primer_view_components-0.13.2 app/components/primer/beta/markdown.rb
primer_view_components-0.13.1 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.13.0 app/components/primer/beta/markdown.rb
primer_view_components-0.13.0 app/components/primer/beta/markdown.rb
primer_view_components-0.12.0 app/components/primer/beta/markdown.rb
primer_view_components-0.11.0 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.12.1 app/components/primer/beta/markdown.rb
primer_view_components-0.10.0 app/components/primer/beta/markdown.rb
openproject-primer_view_components-0.11.0 app/components/primer/beta/markdown.rb