Class: Primer::LinkComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/link_component.rb

Overview

Use links for moving from one page to another. The Link component styles anchor tags with default blue styling and hover text-decoration.

Constant Summary

Constants inherited from Component

Component::STATUSES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ViewHelper

#primer

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(href:, muted: false, **system_arguments) ⇒ LinkComponent

Returns a new instance of LinkComponent.

Examples:

Default

<%= render(Primer::LinkComponent.new(href: "http://www.google.com")) { "Link" } %>

Muted

<%= render(Primer::LinkComponent.new(href: "http://www.google.com", muted: true)) { "Link" } %>

Parameters:

  • href (String)

    URL to be used for the Link

  • muted (Boolean) (defaults to: false)

    Uses light gray for Link color, and blue on hover

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



15
16
17
18
19
20
21
22
23
# File 'app/components/primer/link_component.rb', line 15

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

Class Method Details

.statusObject



29
30
31
# File 'app/components/primer/link_component.rb', line 29

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

Instance Method Details

#callObject



25
26
27
# File 'app/components/primer/link_component.rb', line 25

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