-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreadcrumb.rb
More file actions
54 lines (52 loc) · 2.14 KB
/
breadcrumb.rb
File metadata and controls
54 lines (52 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true
module Flowbite
# Renders a breadcrumb navigation component.
#
# Use {Flowbite::Breadcrumb} and the child {Flowbite::Breadcrumb::Item}
# components to create and indicate a series of page structure and URLs to
# help the user navigate through the website.
#
# Breadcrumbs consist of the following components:
#
# - {Flowbite::Breadcrumb}: Container for breadcrumb items.
# - {Flowbite::Breadcrumb::HomeIcon}: Home icon for the first breadcrumb item.
# - {Flowbite::Breadcrumb::SeparatorIcon}: Separator between breadcrumb items.
# - {Flowbite::Breadcrumb::Item}: An individual breadcrumb item.
# - {Flowbite::Breadcrumb::Item::Current}: An individual breadcrumb item
# without a link, usually used for the current page in the breadcrumb trail.
# - {Flowbite::Breadcrumb::Item::First}: An individual breadcrumb item with a
# home icon on it.
#
# @example Usage
# <%= render(Flowbite::Breadcrumb.new) do |breadcrumb| %>
# <% breadcrumb.with_item do %>
# <%= render(Flowbite::Breadcrumb::Item::First.new(href: "/")) { "Root page" } %>
# <% end %>
# <% breadcrumb.with_item do %>
# <%= render(Flowbite::Breadcrumb::Item.new(href: "/projects")) { "Parent page" } %>
# <% end %>
# <% breadcrumb.with_item do %>
# <%= render(Flowbite::Breadcrumb::Item::Current.new) { "Current Page" } %>
# <% end %>
# <% end %>
#
# @viewcomponent_slot [Flowbite::Breadcrumb::Item] items The items of the
# breadcrumb trail. Use {Flowbite::Breadcrumb::Item::First} for the first
# item to get a home icon, and {Flowbite::Breadcrumb::Item::Current} for the
# last item to render it without a link.
#
# @lookbook_embed BreadcrumbPreview
# @see https://flowbite.com/docs/components/breadcrumb/
class Breadcrumb < ViewComponent::Base
renders_many :items
def call
content_tag(:nav, class: "flex", "aria-label": "Breadcrumb") do
content_tag(:ol, class: "inline-flex items-center space-x-1 md:space-x-2 rtl:space-x-reverse") do
items.each do |item|
concat(item)
end
end
end
end
end
end