Class: Yattho::Beta::Breadcrumbs

Inherits:
Component
  • Object
show all
Defined in:
app/components/yattho/beta/breadcrumbs.rb

Overview

Use ‘Breadcrumbs` to display page hierarchy.

#### Known issues

##### Responsiveness

‘Breadcrumbs` is not optimized for responsive designs.

Defined Under Namespace

Classes: Item

Constant Summary collapse

PADDING_MESSAGE =
"Padding system arguments are not allowed on Breadcrumbs. Consider using margins instead."
FONT_SIZE_MESSAGE =
"Breadcrumbs do not support the font_size system argument."
ARIA_LABEL =
{ label: "Breadcrumb" }.freeze
ARGS_DENYLIST =
{
  [:p, :pt, :pb, :pr, :pl, :px, :py] => PADDING_MESSAGE,
  [:font_size] => FONT_SIZE_MESSAGE
}.freeze

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

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 inherited from Component

deprecated?, generate_id

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) ⇒ Breadcrumbs

Returns a new instance of Breadcrumbs.

Examples:

Basic

<%= render(Yattho::Beta::Breadcrumbs.new) do |component| %>
  <% component.with_item(href: "/") do %>Home<% end %>
  <% component.with_item(href: "/about") do %>About<% end %>
  <% component.with_item(href: "/about/team") do %>Team<% end %>
<% end %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



42
43
44
45
46
47
# File 'app/components/yattho/beta/breadcrumbs.rb', line 42

def initialize(**system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :nav
  @system_arguments[:aria] = ARIA_LABEL
  @system_arguments[:system_arguments_denylist] = ARGS_DENYLIST
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/components/yattho/beta/breadcrumbs.rb', line 49

def render?
  items.any?
end