Method: Primer::Beta::Link#initialize

Defined in:
app/components/primer/beta/link.rb

#initialize(href: nil, scheme: DEFAULT_SCHEME, muted: false, underline: false, **system_arguments) ⇒ Link

Returns a new instance of Link.

Parameters:

  • href (String) (defaults to: nil)

    URL to be used for the Link. Required. If the requirements are not met an error will be raised in non production environments. In production, an empty link element will be rendered.

  • scheme (Symbol) (defaults to: DEFAULT_SCHEME)

    <%= one_of(Primer::Beta::Link::SCHEME_MAPPINGS.keys) %>

  • muted (Boolean) (defaults to: false)

    Uses light gray for Link color, and blue on hover.

  • underline (Boolean) (defaults to: false)

    Whether or not to underline the link.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>

[View source]

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/components/primer/beta/link.rb', line 64

def initialize(href: nil, scheme: DEFAULT_SCHEME, muted: false, underline: false, **system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)

  @id = @system_arguments[:id]

  @system_arguments[:tag] = :a
  @system_arguments[:href] = href
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)],
    "Link",
    "Link--muted" => muted,
    "Link--underline" => underline
  )
end