Class: Primer::LinkComponent

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

Constant Summary

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Methods included from ClassNameHelper

#class_names

Constructor Details

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

Returns a new instance of LinkComponent.



5
6
7
8
9
10
11
12
13
# File 'app/components/primer/link_component.rb', line 5

def initialize(href:, muted: false, **kwargs)
  @kwargs = kwargs
  @kwargs[:tag] = :a
  @kwargs[:href] = href
  @kwargs[:classes] = class_names(
    @kwargs[:classes],
    "muted-link" => fetch_or_fallback([true, false], muted, false)
  )
end

Instance Method Details

#callObject



15
16
17
# File 'app/components/primer/link_component.rb', line 15

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