Class: Ui::Breadcrumb::Component::Item

Inherits:
Ui::BaseComponent
  • Object
show all
Defined in:
lib/uikit_rails/templates/components/breadcrumb/component.rb

Overview

Individual breadcrumb entry — renders as a link or current-page span.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(href: nil, current: false, **html_attrs) ⇒ Item

Returns a new instance of Item.



22
23
24
25
26
27
# File 'lib/uikit_rails/templates/components/breadcrumb/component.rb', line 22

def initialize(href: nil, current: false, **html_attrs)
  @href = href
  @current = current
  @html_attrs = html_attrs
  super()
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



20
21
22
# File 'lib/uikit_rails/templates/components/breadcrumb/component.rb', line 20

def current
  @current
end

#hrefObject (readonly)

Returns the value of attribute href.



20
21
22
# File 'lib/uikit_rails/templates/components/breadcrumb/component.rb', line 20

def href
  @href
end

#html_attrsObject (readonly)

Returns the value of attribute html_attrs.



20
21
22
# File 'lib/uikit_rails/templates/components/breadcrumb/component.rb', line 20

def html_attrs
  @html_attrs
end

Instance Method Details

#callObject



29
30
31
32
33
34
35
36
# File 'lib/uikit_rails/templates/components/breadcrumb/component.rb', line 29

def call
  if href && !current
    (:a, content, class: "ui-breadcrumb__link", href: href, **html_attrs)
  else
    (:span, content, class: "ui-breadcrumb__current", "aria-current": ("page" if current),
                                **html_attrs)
  end
end