Class: Fluxbit::BreadcrumbComponent::Item

Inherits:
Component
  • Object
show all
Includes:
Config::BreadcrumbComponent
Defined in:
app/components/fluxbit/breadcrumb_component.rb

Constant Summary

Constants inherited from Component

Component::ComponentObj

Instance Method Summary collapse

Methods inherited from Component

#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?

Methods included from IconHelpers

#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon

Constructor Details

#initialize(**props) ⇒ Item

Returns a new instance of Item.



32
33
34
35
36
37
38
39
# File 'app/components/fluxbit/breadcrumb_component.rb', line 32

def initialize(**props)
  super
  @props = props
  @current_page = @props.delete(:current_page)
  @href = @props.delete(:href)
  @icon = @props.delete(:icon)
  @remove_dropdown_arrow = options(@props.delete(:remove_dropdown_arrow), default: false)
end

Instance Method Details

#callObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/components/fluxbit/breadcrumb_component.rb', line 41

def call
  item_content = content || ""
  add class: styles[:item][:href][(@current_page || @href.blank?) ? :off : :on], to: @props
  if dropdown? && !@remove_dropdown_arrow
    item_content += chevron_down(class: "ms-3")
    add class: styles[:item][:click_cursor], to: @props
  end

  @props["data-dropdown-toggle"] = dropdown.get_item if dropdown?

  tag.li(class: styles[:item][:base]) do
    concat chevron_right(class: styles[:item][:chevron], stroke_width: 1)
    if @current_page || @href.blank?
      concat anyicon(@icon, class: styles[:item][:icon]) if @icon
      concat tag.span(item_content, **@props)
    else
      concat(tag.a(href: @href, **@props) do
        concat(anyicon(@icon, class: styles[:item][:icon])) if @icon
        concat item_content
      end)
    end
    concat(dropdown&.to_s || "")
  end
end