Class: RailsOmnibar::Item::Help

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_omnibar/item/help.rb

Instance Attribute Summary

Attributes inherited from Base

#icon, #if, #modal_html, #suggested, #title, #type, #url

Instance Method Summary collapse

Methods inherited from Base

#as_json, #render?

Constructor Details

#initialize(title: 'Help', for_commands:, custom_content: nil, icon: 'question', suggested: true) ⇒ Help

Returns a new instance of Help.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rails_omnibar/item/help.rb', line 8

def initialize(title: 'Help', for_commands:, custom_content: nil, icon: 'question', suggested: true)
  super title: title, suggested: suggested, icon: icon, type: :help, modal_html: <<~HTML
    <span>Usage:<span>
    <ul>
      <li>Type a few letters to get results</li>
      <li>Use the arrow keys (↑/↓) on your keyboard to select a result</li>
      <li>Hit Enter to open a result</li>
      <li>Hit Escape to close</li>
    </ul>
    <span>Available actions:<span>
    <ul>
      #{custom_content&.then { |c| "<li>#{c}</li>" } }
      #{for_commands.map do |h|
        "<li><b>#{h.description}</b><br>Example: `#{h.example}`</li>"
      end.join}
    </ul>
  HTML
end