Class: FoxTail::Sidebar::MenuItemComponent

Inherits:
ClickableComponent
  • Object
show all
Defined in:
app/components/fox_tail/sidebar/menu_item_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(html_attributes = {}) ⇒ MenuItemComponent

Returns a new instance of MenuItemComponent.



82
83
84
85
86
87
# File 'app/components/fox_tail/sidebar/menu_item_component.rb', line 82

def initialize(html_attributes = {})
  super

  options[:id] ||= "menu_item_#{SecureRandom.alphanumeric 16}"
  options[:menu_id] ||= "#{options[:id]}_menu"
end

Instance Method Details

#before_renderObject



93
94
95
96
97
98
99
# File 'app/components/fox_tail/sidebar/menu_item_component.rb', line 93

def before_render
  super

  if menu?
    with_right_icon "chevron-down" unless right_visual
  end
end

#callObject



101
102
103
104
105
106
107
108
109
110
# File 'app/components/fox_tail/sidebar/menu_item_component.rb', line 101

def call
   :li do
    if menu?
      concat render_collapsible_trigger
      concat render_menu
    else
      render_item
    end
  end
end

#link?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'app/components/fox_tail/sidebar/menu_item_component.rb', line 89

def link?
  menu? ? false : super
end