Class: Railsboot::BreadcrumbComponent

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

Overview

ViewComponent: renders the breadcrumb block.

Renders a <nav> element wrapping an ordered list of breadcrumb items
provided via the items slot (see Railsboot::Breadcrumb::ItemComponent).

Instance Method Summary collapse

Constructor Details

#initialize(wrapper_attributes: {}, **html_attributes) ⇒ BreadcrumbComponent

Returns a new instance of BreadcrumbComponent.

Parameters:

  • wrapper_attributes (Hash) (defaults to: {})

    the wrapper attributes option

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    additional CSS classes, merged with the component's own classes

  • :tag (String)

    HTML tag to render for the element



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/components/railsboot/breadcrumb_component.rb', line 13

def initialize(wrapper_attributes: {}, **html_attributes)
  @wrapper_attributes = wrapper_attributes
  @html_attributes = html_attributes

  @html_attributes[:tag] = "nav"
  @html_attributes[:class] = class_names(
    html_attributes.delete(:class)
  ).presence

  @wrapper_attributes[:tag] = "ol"
  @wrapper_attributes[:class] = class_names(
    "breadcrumb",
    wrapper_attributes.delete(:class)
  )
end