Class: Avo::KeyboardShortcutsComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/avo/keyboard_shortcuts_component.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods inherited from BaseComponent

#component_name, #hotkey_badge

Methods included from ApplicationHelper

#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #manual_frame_cookie_name, #manual_frame_remembered?, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_header_menu_items, #render_license_warning, #root_path_without_url, #rtl?, #safe_blob_path, #safe_blob_representation_url, #safe_blob_url, #text_direction, #ui, #wrap_in_modal

Methods included from SummaryChartHelper

#summary_chart_params_for

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#render_shortcut_keys(shortcut) ⇒ Object



82
83
84
85
86
87
88
# File 'app/components/avo/keyboard_shortcuts_component.rb', line 82

def render_shortcut_keys(shortcut)
  if shortcut[:any_of].present?
    render_shortcut_alternatives(shortcut[:any_of])
  else
    render_chord(shortcut[:keys])
  end
end

#sectionsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/components/avo/keyboard_shortcuts_component.rb', line 4

def sections
  @sections ||= [
    build_section(
      "Navigation",
      [
        shortcut(action: "Show keyboard shortcuts", keys: ["?"]),
        shortcut(action: "Focus Global Search", keys: {mac: ["Cmd", "K"], other: ["Ctrl", "K"]}),
        shortcut(action: "Focus page content", keys: ["Shift", "T"]),
        shortcut(action: "Toggle sidebar", keys: ["Shift", "\\"]),
        shortcut(action: "Close modal", keys: ["Esc"]),
        shortcut(
          action: "Navigate options in the modal",
          any_of: [[""], [""]],
          keys_aria_label: "Up arrow or down arrow"
        ),
        shortcut(action: "Go back", keys: ["B"]),
        shortcut(action: "Toggle keyboard shortcut badges", keys: ["Shift", "K"])
      ]
    ),
    build_section(
      "Edit view",
      [
        shortcut(action: "Submit form", keys: {mac: ["Cmd", ""], other: ["Ctrl", ""]}),
        shortcut(action: "Unfocus field", keys: ["Esc"]),
        shortcut(action: "Go to index", keys: ["I"])
      ]
    ),
    build_section(
      "Show view",
      [
        shortcut(action: "Delete record", keys: ["D"]),
        shortcut(action: "Edit record", keys: ["E"]),
        shortcut(action: "Open actions", keys: ["A"]),
        shortcut(action: "Go to index", keys: ["I"])
      ]
    ),
    build_section(
      "Action",
      [
        shortcut(action: "Run action", keys: {mac: ["Cmd", ""], other: ["Ctrl", ""]}),
        shortcut(action: "Cancel action", keys: ["Esc"])
      ]
    ),
    build_section(
      "Appearance",
      [
        shortcut(action: "Cycle color scheme (auto / light / dark)", keys: ["Shift", "M"]),
        shortcut(action: "Cycle neutral theme", keys: ["Shift", "N"]),
        shortcut(action: "Cycle accent color", keys: ["Shift", "A"])
      ]
    ),
    build_section(
      "Index view",
      [
        shortcut(action: "Focus search", keys: ["/"]),
        shortcut(action: "Create new record", keys: ["C"]),
        shortcut(action: "Open actions", keys: ["A"]),
        shortcut(
          action: "Focus table and move to next / previous row",
          any_of: [["J"], ["K"]],
          keys_aria_label: "J or K"
        ),
        shortcut(
          action: "Navigate rows (when table is focused)",
          any_of: [[""], [""]],
          keys_aria_label: "Up arrow or down arrow"
        ),
        shortcut(action: "Open record", keys: [""]),
        shortcut(action: "Select / deselect row", keys: ["Space"]),
        shortcut(action: "Clear row focus / deselect rows", keys: ["Esc"]),
        shortcut(action: "Table view", keys: ["V", "T"]),
        shortcut(action: "Grid view", keys: ["V", "G"]),
        shortcut(action: "Map view", keys: ["V", "M"])
      ]
    )
  ]
end