Class: UI::DropdownMenuItem
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::DropdownMenuItem
- Includes:
- DropdownMenuItemBehavior
- Defined in:
- app/components/ui/dropdown_menu_item.rb
Overview
Item - Phlex implementation
Individual menu item that can be rendered as a link or div. Uses DropdownMenuItemBehavior concern for shared styling logic.
Instance Method Summary collapse
-
#initialize(href: nil, inset: false, variant: "default", classes: "", **attributes) ⇒ DropdownMenuItem
constructor
A new instance of DropdownMenuItem.
- #view_template(&block) ⇒ Object
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) ⇒ DropdownMenuItem
Returns a new instance of DropdownMenuItem.
21 22 23 24 25 26 27 |
# File 'app/components/ui/dropdown_menu_item.rb', line 21 def initialize(href: nil, inset: false, variant: "default", classes: "", **attributes) @href = href @inset = inset @variant = variant @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/components/ui/dropdown_menu_item.rb', line 29 def view_template(&block) if @href a(**.deep_merge(@attributes)) do yield if block_given? end else div(**.deep_merge(@attributes)) do yield if block_given? end end end |