Class: UI::DropdownMenuItemComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
DropdownMenuItemBehavior
Defined in:
app/view_components/ui/dropdown_menu_item_component.rb

Overview

ItemComponent - ViewComponent implementation

Instance Method Summary collapse

Methods included from DropdownMenuItemBehavior

#dropdown_menu_item_classes, #dropdown_menu_item_data_attributes, #dropdown_menu_item_html_attributes

Constructor Details

#initialize(href: nil, inset: false, variant: "default", classes: "", **attributes) ⇒ DropdownMenuItemComponent

Returns a new instance of DropdownMenuItemComponent.



7
8
9
10
11
12
13
# File 'app/view_components/ui/dropdown_menu_item_component.rb', line 7

def initialize(href: nil, inset: false, variant: "default", classes: "", **attributes)
  @href = href
  @inset = inset
  @variant = variant
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



15
16
17
18
19
20
# File 'app/view_components/ui/dropdown_menu_item_component.rb', line 15

def call
  tag_name = @href ? :a : :div
   tag_name, **dropdown_menu_item_html_attributes.merge(@attributes.except(:data)) do
    content
  end
end