Class: Primer::BreadcrumbComponent

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

Overview

Use breadcrumbs to display page hierarchy within a section of the site. All of the items in the breadcrumb “trail” are links except for the final item, which is a plain string indicating the current page.

Defined Under Namespace

Classes: ItemComponent

Constant Summary

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(**system_arguments) ⇒ BreadcrumbComponent

Returns a new instance of BreadcrumbComponent.

Examples:

Basic

<%= render(Primer::BreadcrumbComponent.new) do |component| %>
  <% component.item(href: "/") do %>Home<% end %>
  <% component.item(href: "/about") do %>About<% end %>
  <% component.item(selected: true) do %>Team<% end %>
<% end %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



23
24
25
26
27
# File 'app/components/primer/breadcrumb_component.rb', line 23

def initialize(**system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] = :nav
  @system_arguments[:aria] = { label: "Breadcrumb" }
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


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

def render?
  items.any?
end