Class: UI::MenubarShortcut

Inherits:
Phlex::HTML
  • Object
show all
Includes:
MenubarShortcutBehavior
Defined in:
app/components/ui/menubar_shortcut.rb

Overview

Shortcut - Phlex implementation

Displays keyboard shortcut hint for menu items.

Examples:

Basic usage

render UI::Item.new do
  plain "New Tab"
  render UI::Shortcut.new { "Ctrl+T" }
end

Instance Method Summary collapse

Methods included from MenubarShortcutBehavior

#menubar_shortcut_classes, #menubar_shortcut_data_attributes, #menubar_shortcut_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ MenubarShortcut

Returns a new instance of MenubarShortcut.

Parameters:

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



17
18
19
20
# File 'app/components/ui/menubar_shortcut.rb', line 17

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



22
23
24
25
26
# File 'app/components/ui/menubar_shortcut.rb', line 22

def view_template(&block)
  span(**menubar_shortcut_html_attributes.deep_merge(@attributes)) do
    yield if block_given?
  end
end