Sha256: 5421d8c3664e433a57f86f25062dcc9e94c1060eaa4f622eba39039af1a68450

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 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 auto|Default
    #   <%= render(Primer::LinkComponent.new(href: "http://www.google.com")) { "Link" } %>
    #
    # @example auto|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_boolean(muted, false)
      )
    end

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

    def self.status
      Primer::Component::STATUSES[:beta]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
primer_view_components-0.0.21 app/components/primer/link_component.rb
primer_view_components-0.0.20 app/components/primer/link_component.rb
primer_view_components-0.0.19 app/components/primer/link_component.rb