Class: BulmaPhlex::Breadcrumb
- Defined in:
- lib/bulma_phlex/breadcrumb.rb
Overview
Renders a [Bulma breadcrumb](bulma.io/documentation/components/breadcrumb/) component. It supports options for alignment (centered, right-aligned), separator style (arrow, bullet, dot, or succeeds (greater than)), and size (small, medium, large).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(align: nil, separator: nil, size: nil, **html_attributes) ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
-
#item(label, href: nil, icon: nil) ⇒ Object
Adds a breadcrumb item to the component.
- #view_template ⇒ Object
Constructor Details
#initialize(align: nil, separator: nil, size: nil, **html_attributes) ⇒ Breadcrumb
Returns a new instance of Breadcrumb.
18 19 20 21 22 23 24 25 |
# File 'lib/bulma_phlex/breadcrumb.rb', line 18 def initialize(align: nil, separator: nil, size: nil, **html_attributes) @align = align @separator = separator @size = size @html_attributes = html_attributes @items = [] end |
Class Method Details
.new(align: nil, separator: nil, size: nil, **html_attributes) ⇒ Object
Parameters
-
‘align` — Breadcrumb alignment: `“centered”` or `“right”`
-
‘separator` — Breadcrumb separator style: `“arrow”`, `“bullet”`, `“dot”`, or `“succeeds”`
-
‘size` — Alternate size: `“small”`, `“medium”`, or `“large”`
-
‘**html_attributes` — Additional HTML attributes for the `<nav>` element
14 15 16 |
# File 'lib/bulma_phlex/breadcrumb.rb', line 14 def self.new(align: nil, separator: nil, size: nil, **html_attributes) super end |
Instance Method Details
#item(label, href: nil, icon: nil) ⇒ Object
Adds a breadcrumb item to the component. The last item added will be rendered as the active item.
Parameters
-
‘label` (positional) — The text label for the breadcrumb item
-
‘href` — URL for the breadcrumb item; not required on last item / current page
-
‘icon` — Optional icon class for the breadcrumb item (e.g. `“fa-solid fa-home”`)
48 49 50 |
# File 'lib/bulma_phlex/breadcrumb.rb', line 48 def item(label, href: nil, icon: nil) @items << { label:, icon:, html_attributes: { href: href } } end |
#view_template ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bulma_phlex/breadcrumb.rb', line 27 def view_template(&) vanish(&) return if @items.empty? nav(**mix(@html_attributes, class: nav_classes, aria: { label: "breadcrumbs" })) do ul do @items[0...-1].each do |item| render_item(item) end render_last_item end end end |