Class: Primer::BreadcrumbComponent::BreadcrumbItem

Inherits:
Slot
  • Object
show all
Defined in:
app/components/primer/breadcrumb_component.rb

Overview

_Note: if both ‘href` and `selected: true` are passed in, `href` will be ignored and the item will not be rendered as a link._

Constant Summary

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Attribute Summary collapse

Instance Method Summary collapse

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: nil, selected: false, **system_arguments) ⇒ BreadcrumbItem

Returns a new instance of BreadcrumbItem.

Parameters:

  • href (String) (defaults to: nil)

    The URL to link to.

  • selected (Boolean) (defaults to: false)

    Whether or not the item is selected and not rendered as a link.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



35
36
37
38
39
40
41
42
43
# File 'app/components/primer/breadcrumb_component.rb', line 35

def initialize(href: nil, selected: false, **system_arguments)
  @href = href
  @system_arguments = system_arguments

  @href = nil if selected
  @system_arguments[:tag] = :li
  @system_arguments[:"aria-current"] = "page" if selected
  @system_arguments[:classes] = "breadcrumb-item #{@system_arguments[:classes]}"
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



30
31
32
# File 'app/components/primer/breadcrumb_component.rb', line 30

def href
  @href
end

#system_argumentsObject (readonly)

Returns the value of attribute system_arguments.



30
31
32
# File 'app/components/primer/breadcrumb_component.rb', line 30

def system_arguments
  @system_arguments
end