Sha256: ace5e4b50f4c12f11c9cad4de953ac57d62d15a12bfffd6702b242cfad0b0c0e

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Primer
  # Use links for moving from one page to another. The Link component styles anchor tags with default blue styling and hover text-decoration.
  class LinkComponent < Primer::Component
    # @example 40|Default
    #   <%= render(Primer::LinkComponent.new(href: "http://www.google.com")) { "Link" } %>
    #
    # @example 40|Muted
    #   <%= render(Primer::LinkComponent.new(href: "http://www.google.com", muted: true)) { "Link" } %>
    #
    # @param href [String] URL to be used for the Link
    # @param muted [Boolean] Uses light gray for Link color, and blue on hover
    # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
    def initialize(href:, muted: false, **system_arguments)
      @system_arguments = system_arguments
      @system_arguments[:tag] = :a
      @system_arguments[:href] = href
      @system_arguments[:classes] = class_names(
        @system_arguments[:classes],
        "muted-link" => fetch_or_fallback([true, false], muted, false)
      )
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
primer_view_components-0.0.16 app/components/primer/link_component.rb
primer_view_components-0.0.15 app/components/primer/link_component.rb
primer_view_components-0.0.14 app/components/primer/link_component.rb
primer_view_components-0.0.13 app/components/primer/link_component.rb