Class: UI::MenubarItemComponent

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

Overview

ItemComponent - ViewComponent implementation

A menu item.

Examples:

Basic usage

render UI::ItemComponent.new { "Save" }

With shortcut

render UI::ItemComponent.new do
  "Save"
  render UI::ShortcutComponent.new { "⌘S" }
end

Instance Method Summary collapse

Methods included from MenubarItemBehavior

#menubar_item_classes, #menubar_item_data_attributes, #menubar_item_html_attributes

Constructor Details

#initialize(variant: nil, inset: false, disabled: false, classes: "", **attributes) ⇒ MenubarItemComponent

Returns a new instance of MenubarItemComponent.



18
19
20
21
22
23
24
# File 'app/view_components/ui/menubar_item_component.rb', line 18

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

Instance Method Details

#callObject



26
27
28
29
30
# File 'app/view_components/ui/menubar_item_component.rb', line 26

def call
   :div, **menubar_item_html_attributes.deep_merge(@attributes) do
    content
  end
end