Class: Primer::BreadcrumbComponent::ItemComponent

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

Overview

This component is part of ‘Primer::BreadcrumbComponent` and should not be used as a standalone component.

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

Returns a new instance of ItemComponent.



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

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 Method Details

#callObject



46
47
48
49
50
51
52
53
54
# File 'app/components/primer/breadcrumb_component.rb', line 46

def call
  render(Primer::BaseComponent.new(**@system_arguments)) do
    if @href.present?
      render(Primer::LinkComponent.new(href: @href)) { content }
    else
      content
    end
  end
end