Class: ShadcnPhlexcomponents::Breadcrumb

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/breadcrumb.rb

Constant Summary

Constants inherited from Base

ShadcnPhlexcomponents::Base::SANITIZER_ALLOWED_ATTRIBUTES, ShadcnPhlexcomponents::Base::SANITIZER_ALLOWED_TAGS, ShadcnPhlexcomponents::Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #default_attributes, #find_as_child, #icon, #initialize, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

This class inherits a constructor from ShadcnPhlexcomponents::Base

Instance Method Details

#ellipsis(**attributes) ⇒ Object



30
31
32
# File 'lib/shadcn_phlexcomponents/components/breadcrumb.rb', line 30

def ellipsis(**attributes)
  BreadcrumbEllipsis(**attributes)
end

#item(**attributes) ⇒ Object



14
15
16
# File 'lib/shadcn_phlexcomponents/components/breadcrumb.rb', line 14

def item(**attributes, &)
  BreadcrumbItem(**attributes, &)
end


18
19
20
# File 'lib/shadcn_phlexcomponents/components/breadcrumb.rb', line 18

def link(name = nil, options = nil, html_options = nil, &)
  BreadcrumbLink(name, options, html_options, &)
end


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/shadcn_phlexcomponents/components/breadcrumb.rb', line 34

def links(collection)
  collection.each_with_index do |link, index|
    if index == collection.size - 1
      item do
        page { link[:name] }
      end
    else
      item do
        link(link[:name], link[:path])
      end
    end

    if index < collection.size - 1
      separator
    end
  end

  nil
end

#page(**attributes) ⇒ Object



26
27
28
# File 'lib/shadcn_phlexcomponents/components/breadcrumb.rb', line 26

def page(**attributes, &)
  BreadcrumbPage(**attributes, &)
end

#separator(**attributes) ⇒ Object



22
23
24
# File 'lib/shadcn_phlexcomponents/components/breadcrumb.rb', line 22

def separator(**attributes, &)
  BreadcrumbSeparator(**attributes, &)
end

#view_template ⇒ Object



54
55
56
57
58
# File 'lib/shadcn_phlexcomponents/components/breadcrumb.rb', line 54

def view_template(&)
  nav(aria: { label: "breadcrumb" }) do
    ol(**@attributes, &)
  end
end