|
| 1 | +<div class="alert alert-warning"> |
| 2 | + Since this page is an iframe, you need to click here first, and then press the shortcut. |
| 3 | +</div> |
| 4 | +<% |
| 5 | + |
| 6 | + command_list_actions = [ |
| 7 | + { label: 'Search on Google', |
| 8 | + command: 'https://www.google.com/search?q=_1_', |
| 9 | + placeholder: 'Search text', |
| 10 | + category: 'search', |
| 11 | + target: '_blank' }, |
| 12 | + { label: 'Go to component', |
| 13 | + command: '/lookbook/inspect/_1_/themes', |
| 14 | + placeholder: 'badge, button, avatar, etc.', |
| 15 | + category: 'link' }, |
| 16 | + ].group_by { |action| action[:category] } |
| 17 | + |
| 18 | +%> |
| 19 | +<div data-controller="command-list" class="command-list"> |
| 20 | + <a href="#" class="nav-item me-3 p-1 text-decoration-none"> |
| 21 | + <div class="input-group command-list-button ms-2" data-bs-toggle="modal" data-bs-target="#command-list-modal"> |
| 22 | + <span class="input-group-text" id="basic-addon1"><i class="fa fa-search"></i></span> |
| 23 | + <div class="form-control form-control-sm text-center py-2"> |
| 24 | + <%= t('command_list.press') %> |
| 25 | + <kbd class="command-list-icon" data-command-list-target="metaKey"></kbd> + <kbd class="command-list-icon">K</kbd> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + </a> |
| 29 | + |
| 30 | + <div id="command-list-modal" class="modal" tabindex="-1" data-command-list-target="list"> |
| 31 | + <div class="modal-dialog"> |
| 32 | + <div class="modal-content"> |
| 33 | + <div class="modal-body"> |
| 34 | + <div class="input-group mb-3"> |
| 35 | + <span class="input-group-text" id="basic-addon1"><i class="fa fa-search"></i></span> |
| 36 | + <input autocomplete="off" |
| 37 | + type="text" |
| 38 | + class="form-control" |
| 39 | + data-command-list-target="searchField" |
| 40 | + data-action="keydown.up->command-list#previousItem |
| 41 | + keydown.enter->command-list#performCommand |
| 42 | + keydown.down->command-list#nextItem"> |
| 43 | + </div> |
| 44 | + |
| 45 | + <div class="list-group" data-command-list-target="listGroup"> |
| 46 | + <% command_list_actions.each do |category, actions| %> |
| 47 | + <div class="form-label mt-2 fw-medium"><%= t("command_list.#{category}") %></div> |
| 48 | + <% actions.each do |action| %> |
| 49 | + <a class="list-group-item" href="#" |
| 50 | + data-action="click->command-list#selectCommand" |
| 51 | + data-command-list-target="listItem" |
| 52 | + data-placeholder="<%= action[:placeholder] || '' %>" |
| 53 | + data-command="<%= action[:command] %>" |
| 54 | + data-target="<%= action[:target] || '' %>"> |
| 55 | + <%= action[:label] %> |
| 56 | + </a> |
| 57 | + <% end %> |
| 58 | + <% end %> |
| 59 | + </div> |
| 60 | + |
| 61 | + </div> |
| 62 | + <div class="modal-footer d-flex command-list-footer"> |
| 63 | + <small class="pe-1"><kbd class="command-list-icon">⏎</kbd> <%= t('command_list.to_select') %></small> |
| 64 | + <small class="pe-1"> |
| 65 | + <kbd class="command-list-icon">↑</kbd> |
| 66 | + <kbd class="command-list-icon">↓</kbd> |
| 67 | + <%= t('command_list.to_navigate') %> |
| 68 | + </small> |
| 69 | + <small class="pe-1"><kbd class="command-list-icon">ESC</kbd> <%= t('command_list.to_exit') %></small> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + |
| 75 | +</div> |
0 commit comments