Class: Avo::KeyboardShortcutsComponent

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

Instance Method Summary collapse

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