Class: JetUi::Breadcrumbs::ItemComponent

Inherits:
JetUi::BaseComponent show all
Defined in:
app/components/jet_ui/breadcrumbs/item_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(label = nil, href: nil, **options) ⇒ ItemComponent

Returns a new instance of ItemComponent.



6
7
8
9
10
# File 'app/components/jet_ui/breadcrumbs/item_component.rb', line 6

def initialize(label = nil, href: nil, **options)
  @label  = label
  @href   = href
  @options = options
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/components/jet_ui/breadcrumbs/item_component.rb', line 12

def call
   :li, class: 'breadcrumbs__item' do
    text = @label.presence || content
    if @href
      link_to text, @href, class: class_names('breadcrumbs__link', @options.delete(:class)), **@options
    else
       :span, text, class: class_names('breadcrumbs__current', @options.delete(:class)),
                               'aria-current': 'page', **@options
    end
  end
end