openproject-primer_view_components 0.95.0 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/app/assets/javascripts/primer_view_components.js +11 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/assets/styles/primer_view_components.css +1 -1
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_bar.css +1 -1
  8. data/app/components/primer/alpha/action_bar.css.map +1 -1
  9. data/app/components/primer/alpha/action_list/item.rb +5 -1
  10. data/app/components/primer/alpha/action_list.css +1 -1
  11. data/app/components/primer/alpha/action_list.css.json +13 -11
  12. data/app/components/primer/alpha/action_list.css.map +1 -1
  13. data/app/components/primer/alpha/action_list.pcss +12 -0
  14. data/app/components/primer/alpha/action_menu/action_menu_element.d.ts +6 -0
  15. data/app/components/primer/alpha/action_menu/action_menu_element.js +389 -84
  16. data/app/components/primer/alpha/action_menu/action_menu_element.ts +439 -78
  17. data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.d.ts +4 -1
  18. data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.js +37 -13
  19. data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.ts +41 -12
  20. data/app/components/primer/alpha/action_menu/menu.html.erb +27 -19
  21. data/app/components/primer/alpha/action_menu/menu.rb +7 -0
  22. data/app/components/primer/alpha/action_menu/primary_menu.rb +15 -0
  23. data/app/components/primer/alpha/action_menu.rb +55 -0
  24. data/app/components/primer/alpha/auto_complete.css +1 -1
  25. data/app/components/primer/alpha/auto_complete.css.map +1 -1
  26. data/app/components/primer/alpha/banner.css +1 -1
  27. data/app/components/primer/alpha/banner.css.map +1 -1
  28. data/app/components/primer/alpha/button_marketing.css +1 -1
  29. data/app/components/primer/alpha/button_marketing.css.map +1 -1
  30. data/app/components/primer/alpha/dialog.css +1 -1
  31. data/app/components/primer/alpha/dialog.css.map +1 -1
  32. data/app/components/primer/alpha/dropdown/menu.rb +1 -1
  33. data/app/components/primer/alpha/dropdown.css +1 -1
  34. data/app/components/primer/alpha/dropdown.css.json +1 -1
  35. data/app/components/primer/alpha/dropdown.css.map +1 -1
  36. data/app/components/primer/alpha/layout.css +1 -1
  37. data/app/components/primer/alpha/layout.css.json +3 -3
  38. data/app/components/primer/alpha/layout.css.map +1 -1
  39. data/app/components/primer/alpha/menu.css +1 -1
  40. data/app/components/primer/alpha/menu.css.json +3 -3
  41. data/app/components/primer/alpha/menu.css.map +1 -1
  42. data/app/components/primer/alpha/overlay.css +1 -1
  43. data/app/components/primer/alpha/overlay.css.map +1 -1
  44. data/app/components/primer/alpha/segmented_control.css +1 -1
  45. data/app/components/primer/alpha/segmented_control.css.json +1 -1
  46. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  47. data/app/components/primer/alpha/select_panel.css +1 -1
  48. data/app/components/primer/alpha/select_panel.css.map +1 -1
  49. data/app/components/primer/alpha/skeleton_box.css +1 -1
  50. data/app/components/primer/alpha/skeleton_box.css.map +1 -1
  51. data/app/components/primer/alpha/stack.css +1 -1
  52. data/app/components/primer/alpha/stack.css.map +1 -1
  53. data/app/components/primer/alpha/stack_item.css +1 -1
  54. data/app/components/primer/alpha/stack_item.css.map +1 -1
  55. data/app/components/primer/alpha/tab_nav.css +1 -1
  56. data/app/components/primer/alpha/tab_nav.css.map +1 -1
  57. data/app/components/primer/alpha/text_field.css +1 -1
  58. data/app/components/primer/alpha/text_field.css.map +1 -1
  59. data/app/components/primer/alpha/toggle_switch.css +1 -1
  60. data/app/components/primer/alpha/toggle_switch.css.map +1 -1
  61. data/app/components/primer/alpha/tree_view.css +1 -1
  62. data/app/components/primer/alpha/tree_view.css.json +3 -3
  63. data/app/components/primer/alpha/tree_view.css.map +1 -1
  64. data/app/components/primer/alpha/underline_nav.css +1 -1
  65. data/app/components/primer/alpha/underline_nav.css.map +1 -1
  66. data/app/components/primer/beta/border_box.css +1 -1
  67. data/app/components/primer/beta/border_box.css.json +5 -5
  68. data/app/components/primer/beta/border_box.css.map +1 -1
  69. data/app/components/primer/beta/button.css +1 -1
  70. data/app/components/primer/beta/button.css.map +1 -1
  71. data/app/components/primer/beta/button.pcss +97 -0
  72. data/app/components/primer/beta/button.rb +15 -3
  73. data/app/components/primer/beta/counter.css +1 -1
  74. data/app/components/primer/beta/counter.css.map +1 -1
  75. data/app/components/primer/beta/flash.css +1 -1
  76. data/app/components/primer/beta/flash.css.map +1 -1
  77. data/app/components/primer/beta/link.css +1 -1
  78. data/app/components/primer/beta/link.css.json +1 -1
  79. data/app/components/primer/beta/link.css.map +1 -1
  80. data/app/components/primer/beta/popover.css +1 -1
  81. data/app/components/primer/beta/popover.css.map +1 -1
  82. data/app/components/primer/beta/progress_bar.css +1 -1
  83. data/app/components/primer/beta/progress_bar.css.map +1 -1
  84. data/app/components/primer/beta/relative_time.rb +7 -1
  85. data/app/components/primer/beta/state.css +1 -1
  86. data/app/components/primer/beta/state.css.json +2 -2
  87. data/app/components/primer/beta/state.css.map +1 -1
  88. data/app/components/primer/beta/timeline_item.css +1 -1
  89. data/app/components/primer/beta/timeline_item.css.map +1 -1
  90. data/app/components/primer/open_project/border_grid.css +1 -1
  91. data/app/components/primer/open_project/border_grid.css.map +1 -1
  92. data/app/components/primer/open_project/color_field.css +1 -1
  93. data/app/components/primer/open_project/color_field.css.map +1 -1
  94. data/app/components/primer/open_project/inline_message.css +1 -1
  95. data/app/components/primer/open_project/inline_message.css.map +1 -1
  96. data/app/components/primer/open_project/input_group.css +1 -1
  97. data/app/components/primer/open_project/input_group.css.map +1 -1
  98. data/app/components/primer/open_project/keybinding_hint/chords.d.ts +5 -0
  99. data/app/components/primer/open_project/keybinding_hint/chords.js +29 -0
  100. data/app/components/primer/open_project/keybinding_hint/chords.ts +38 -0
  101. data/app/components/primer/open_project/keybinding_hint/key_names.d.ts +16 -0
  102. data/app/components/primer/open_project/keybinding_hint/key_names.js +107 -0
  103. data/app/components/primer/open_project/keybinding_hint/key_names.ts +116 -0
  104. data/app/components/primer/open_project/keybinding_hint/localized_names.d.ts +22 -0
  105. data/app/components/primer/open_project/keybinding_hint/localized_names.js +47 -0
  106. data/app/components/primer/open_project/keybinding_hint/localized_names.ts +71 -0
  107. data/app/components/primer/open_project/keybinding_hint/names.rb +92 -0
  108. data/app/components/primer/open_project/keybinding_hint/names_from_scope.d.ts +21 -0
  109. data/app/components/primer/open_project/keybinding_hint/names_from_scope.js +81 -0
  110. data/app/components/primer/open_project/keybinding_hint/names_from_scope.ts +96 -0
  111. data/app/components/primer/open_project/keybinding_hint/platform.d.ts +10 -0
  112. data/app/components/primer/open_project/keybinding_hint/platform.js +24 -0
  113. data/app/components/primer/open_project/keybinding_hint/platform.ts +34 -0
  114. data/app/components/primer/open_project/keybinding_hint/platform_override.d.ts +2 -0
  115. data/app/components/primer/open_project/keybinding_hint/platform_override.js +4 -0
  116. data/app/components/primer/open_project/keybinding_hint/platform_override.ts +7 -0
  117. data/app/components/primer/open_project/keybinding_hint.css +1 -0
  118. data/app/components/primer/open_project/keybinding_hint.css.json +10 -0
  119. data/app/components/primer/open_project/keybinding_hint.css.map +1 -0
  120. data/app/components/primer/open_project/keybinding_hint.html.erb +4 -0
  121. data/app/components/primer/open_project/keybinding_hint.pcss +65 -0
  122. data/app/components/primer/open_project/keybinding_hint.rb +112 -0
  123. data/app/components/primer/open_project/keybinding_hint_element.d.ts +31 -0
  124. data/app/components/primer/open_project/keybinding_hint_element.js +183 -0
  125. data/app/components/primer/open_project/keybinding_hint_element.ts +152 -0
  126. data/app/components/primer/open_project/page_header.css +1 -1
  127. data/app/components/primer/open_project/page_header.css.json +2 -2
  128. data/app/components/primer/open_project/page_header.css.map +1 -1
  129. data/app/components/primer/open_project/pagination.css +1 -1
  130. data/app/components/primer/open_project/pagination.css.json +1 -1
  131. data/app/components/primer/open_project/pagination.css.map +1 -1
  132. data/app/components/primer/open_project/sub_header.css +1 -1
  133. data/app/components/primer/open_project/sub_header.css.map +1 -1
  134. data/app/components/primer/primer.d.ts +1 -0
  135. data/app/components/primer/primer.js +1 -0
  136. data/app/components/primer/primer.pcss +1 -0
  137. data/app/components/primer/primer.ts +1 -0
  138. data/app/components/primer/truncate.css +1 -1
  139. data/app/components/primer/truncate.css.json +3 -4
  140. data/app/components/primer/truncate.css.map +1 -1
  141. data/app/controllers/primer/view_components/action_menu_controller.rb +35 -0
  142. data/app/views/primer/view_components/action_menu/deferred.html.erb +25 -11
  143. data/app/views/primer/view_components/action_menu/deferred_form.html.erb +10 -0
  144. data/app/views/primer/view_components/action_menu/deferred_preload.html.erb +7 -1
  145. data/config/locales/en.yml +179 -0
  146. data/config/routes.rb +1 -0
  147. data/lib/primer/accessibility.rb +1 -2
  148. data/lib/primer/classify.rb +1 -2
  149. data/lib/primer/view_components/version.rb +1 -1
  150. data/previews/primer/alpha/action_menu_preview/deferred_refresh.html.erb +34 -0
  151. data/previews/primer/alpha/action_menu_preview/deferred_refresh_form.html.erb +9 -0
  152. data/previews/primer/alpha/action_menu_preview.rb +14 -0
  153. data/previews/primer/open_project/keybinding_hint_preview/full_format.html.erb +3 -0
  154. data/previews/primer/open_project/keybinding_hint_preview/in_action_list.html.erb +12 -0
  155. data/previews/primer/open_project/keybinding_hint_preview/in_button.html.erb +24 -0
  156. data/previews/primer/open_project/keybinding_hint_preview/platforms.html.erb +8 -0
  157. data/previews/primer/open_project/keybinding_hint_preview/playground.html.erb +4 -0
  158. data/previews/primer/open_project/keybinding_hint_preview/prose.html.erb +3 -0
  159. data/previews/primer/open_project/keybinding_hint_preview/schemes.html.erb +6 -0
  160. data/previews/primer/open_project/keybinding_hint_preview/sequence.html.erb +1 -0
  161. data/previews/primer/open_project/keybinding_hint_preview/sizes.html.erb +4 -0
  162. data/previews/primer/open_project/keybinding_hint_preview.rb +71 -0
  163. data/static/arguments.json +53 -1
  164. data/static/audited_at.json +1 -0
  165. data/static/classes.json +12 -0
  166. data/static/classnames.cjs +4 -0
  167. data/static/classnames.js +4 -0
  168. data/static/constants.json +35 -0
  169. data/static/info_arch.json +234 -8
  170. data/static/previews.json +164 -0
  171. data/static/statuses.json +1 -0
  172. metadata +42 -5
  173. data/app/components/primer/alpha/text_field.css.json +0 -134
  174. data/app/components/primer/alpha/toggle_switch.css.json +0 -40
  175. data/app/components/primer/alpha/underline_nav.css.json +0 -26
  176. data/app/components/primer/beta/button.css.json +0 -86
@@ -46,3 +46,182 @@ en:
46
46
 
47
47
  tree_view:
48
48
  label_empty_sub_tree: "No items"
49
+
50
+ keybinding_hint:
51
+ then: "then"
52
+ keys:
53
+ alt:
54
+ condensed: { apple: "⌥", other: "Alt" }
55
+ full: { apple: "Option", other: "Alt" }
56
+ accessible: { apple: "option", other: "alt" }
57
+ arrowdown:
58
+ full: { other: "Down Arrow" }
59
+ accessible: { other: "down arrow" }
60
+ arrowleft:
61
+ full: { other: "Left Arrow" }
62
+ accessible: { other: "left arrow" }
63
+ arrowright:
64
+ full: { other: "Right Arrow" }
65
+ accessible: { other: "right arrow" }
66
+ arrowup:
67
+ full: { other: "Up Arrow" }
68
+ accessible: { other: "up arrow" }
69
+ backspace:
70
+ full: { other: "Backspace" }
71
+ accessible: { other: "backspace" }
72
+ capslock:
73
+ condensed: { other: "CapsLock" }
74
+ full: { other: "Caps Lock" }
75
+ accessible: { other: "caps lock" }
76
+ control:
77
+ condensed: { apple: "⌃", other: "Ctrl" }
78
+ full: { other: "Control" }
79
+ accessible: { other: "control" }
80
+ delete:
81
+ condensed: { other: "Del" }
82
+ full: { other: "Delete" }
83
+ accessible: { other: "delete" }
84
+ end:
85
+ condensed: { other: "End" }
86
+ full: { other: "End" }
87
+ accessible: { other: "end" }
88
+ enter:
89
+ full: { other: "Enter" }
90
+ accessible: { other: "enter" }
91
+ escape:
92
+ condensed: { other: "Esc" }
93
+ full: { other: "Escape" }
94
+ accessible: { other: "escape" }
95
+ function:
96
+ condensed: { other: "Fn" }
97
+ full: { other: "Function" }
98
+ accessible: { other: "function" }
99
+ home:
100
+ condensed: { other: "Home" }
101
+ full: { other: "Home" }
102
+ accessible: { other: "home" }
103
+ insert:
104
+ condensed: { other: "Ins" }
105
+ full: { other: "Insert" }
106
+ accessible: { other: "insert" }
107
+ meta:
108
+ condensed: { apple: "⌘", windows: "Win", other: "Meta" }
109
+ full: { apple: "Command", windows: "Windows", other: "Meta" }
110
+ accessible: { apple: "command", windows: "Windows", other: "meta" }
111
+ pagedown:
112
+ condensed: { other: "PgDn" }
113
+ full: { other: "Page Down" }
114
+ accessible: { other: "page down" }
115
+ pageup:
116
+ condensed: { other: "PgUp" }
117
+ full: { other: "Page Up" }
118
+ accessible: { other: "page up" }
119
+ plus:
120
+ full: { other: "Plus" }
121
+ accessible: { other: "plus" }
122
+ printscreen:
123
+ condensed: { other: "PrtScn" }
124
+ full: { other: "Print Screen" }
125
+ accessible: { other: "print screen" }
126
+ shift:
127
+ full: { other: "Shift" }
128
+ accessible: { other: "shift" }
129
+ space:
130
+ full: { other: "Space" }
131
+ accessible: { other: "space" }
132
+ tab:
133
+ full: { other: "Tab" }
134
+ accessible: { other: "tab" }
135
+ ampersand:
136
+ key: "&"
137
+ accessible: { other: "ampersand" }
138
+ asterisk:
139
+ key: "*"
140
+ accessible: { other: "asterisk" }
141
+ at:
142
+ key: "@"
143
+ accessible: { other: "at" }
144
+ backslash:
145
+ key: "\\"
146
+ accessible: { other: "backslash" }
147
+ backtick:
148
+ key: "`"
149
+ accessible: { other: "backtick" }
150
+ caret:
151
+ key: "^"
152
+ accessible: { other: "caret" }
153
+ colon:
154
+ key: ":"
155
+ accessible: { other: "colon" }
156
+ comma:
157
+ key: ","
158
+ accessible: { other: "comma" }
159
+ dash:
160
+ key: "-"
161
+ accessible: { other: "dash" }
162
+ dollar_sign:
163
+ key: "$"
164
+ accessible: { other: "dollar sign" }
165
+ double_quote:
166
+ key: "\""
167
+ accessible: { other: "double quote" }
168
+ equals:
169
+ key: "="
170
+ accessible: { other: "equals" }
171
+ exclamation_point:
172
+ key: "!"
173
+ accessible: { other: "exclamation point" }
174
+ forward_slash:
175
+ key: "/"
176
+ accessible: { other: "forward slash" }
177
+ hash:
178
+ key: "#"
179
+ accessible: { other: "hash" }
180
+ left_angle_bracket:
181
+ key: "<"
182
+ accessible: { other: "left angle bracket" }
183
+ left_bracket:
184
+ key: "["
185
+ accessible: { other: "left bracket" }
186
+ left_curly_brace:
187
+ key: "{"
188
+ accessible: { other: "left curly brace" }
189
+ left_parenthesis:
190
+ key: "("
191
+ accessible: { other: "left parenthesis" }
192
+ percent:
193
+ key: "%"
194
+ accessible: { other: "percent" }
195
+ period:
196
+ key: "."
197
+ accessible: { other: "period" }
198
+ pipe:
199
+ key: "|"
200
+ accessible: { other: "pipe" }
201
+ question_mark:
202
+ key: "?"
203
+ accessible: { other: "question mark" }
204
+ right_angle_bracket:
205
+ key: ">"
206
+ accessible: { other: "right angle bracket" }
207
+ right_bracket:
208
+ key: "]"
209
+ accessible: { other: "right bracket" }
210
+ right_curly_brace:
211
+ key: "}"
212
+ accessible: { other: "right curly brace" }
213
+ right_parenthesis:
214
+ key: ")"
215
+ accessible: { other: "right parenthesis" }
216
+ semicolon:
217
+ key: ";"
218
+ accessible: { other: "semicolon" }
219
+ single_quote:
220
+ key: "'"
221
+ accessible: { other: "single quote" }
222
+ tilde:
223
+ key: "~"
224
+ accessible: { other: "tilde" }
225
+ underscore:
226
+ key: "_"
227
+ accessible: { other: "underscore" }
data/config/routes.rb CHANGED
@@ -28,6 +28,7 @@ Primer::ViewComponents::Engine.routes.draw do
28
28
  post "/action_menu/form_action", to: "action_menu#form_action", as: :action_menu_form_action
29
29
  get "/action_menu/deferred", to: "action_menu#deferred", as: :action_menu_deferred
30
30
  get "/action_menu/deferred_preload", to: "action_menu#deferred_preload", as: :action_menu_deferred_preload
31
+ get "/action_menu/deferred_form", to: "action_menu#deferred_form", as: :action_menu_deferred_form
31
32
 
32
33
  get "/include_fragment/deferred", to: "include_fragment#deferred", as: :include_fragment_deferred
33
34
  end
@@ -41,9 +41,8 @@ module Primer
41
41
  }
42
42
  }.freeze
43
43
 
44
- # rubocop:disable Style/ClassMethodsDefinitions
44
+ # rubocop:disable-next Style/ClassMethodsDefinitions
45
45
  class << self
46
- # rubocop:enable Style/ClassMethodsDefinitions
47
46
 
48
47
  def ignore_preview?(preview_class)
49
48
  IGNORED_PREVIEWS.include?(preview_class)
@@ -98,9 +98,8 @@ module Primer
98
98
  else
99
99
  next if val.nil?
100
100
 
101
- # rubocop:disable Style/RescueModifier
101
+ # rubocop:disable-next Style/RescueModifier
102
102
  found = (LOOKUP[key][val][0] rescue nil) || validate(key, val, 0)
103
- # rubocop:enable Style/RescueModifier
104
103
  if found
105
104
  result << found
106
105
  result << TMP_PREFIX_CACHE[found] if TMP_PREFIX_CACHE.key?(found)
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 95
8
+ MINOR = 96
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -0,0 +1,34 @@
1
+ <%= render(Primer::Alpha::ActionMenu.new(menu_id: "deferred", preload: preload, src: primer_view_components.action_menu_deferred_path)) do |menu| %>
2
+ <% menu.with_show_button { "Menu with refreshable content" } %>
3
+ <% end %>
4
+
5
+ <%= render(Primer::Beta::Button.new(id: "deferred-refresh-button", ml: 2)) { "Refresh" } %>
6
+ <%= render(Primer::Beta::Button.new(id: "deferred-reload-button", ml: 2)) { "Reload" } %>
7
+
8
+ <%# Used by the "Show dialog" item rendered by ActionMenuController#deferred. %>
9
+ <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: "Confirm deletion")) do |d| %>
10
+ <%= render(Primer::Alpha::Dialog::Body.new()) do %>
11
+ Are you sure you want to delete this?
12
+ <% end %>
13
+ <%= render(Primer::Alpha::Dialog::Footer.new()) do %>
14
+ <%= render(Primer::Beta::Button.new(data: { "close-dialog-id": "my-dialog" })) { "Cancel" } %>
15
+ <%= render(Primer::Beta::Button.new(scheme: :danger)) { "Delete" } %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <script type="text/javascript">
20
+ (() => {
21
+ let count = 0
22
+ document.getElementById("deferred-refresh-button").addEventListener("click", () => {
23
+ const menu = document.querySelector("action-menu")
24
+ const url = new URL(menu.getAttribute("src"), window.location.href)
25
+ count += 1
26
+ url.searchParams.set("label", `Refreshed ${count}`)
27
+ menu.setAttribute("src", `${url.pathname}${url.search}`)
28
+ })
29
+
30
+ document.getElementById("deferred-reload-button").addEventListener("click", () => {
31
+ document.querySelector("action-menu").refresh()
32
+ })
33
+ })()
34
+ </script>
@@ -0,0 +1,9 @@
1
+ <%= form_with(url: primer_view_components.action_menu_form_action_path(format: route_format)) do |f| %>
2
+ <%= render(Primer::Alpha::ActionMenu.new(select_variant: select_variant, dynamic_label: true, dynamic_label_prefix: "Strategy", menu_id: "deferred-form", src: primer_view_components.action_menu_deferred_form_path(variant: (select_variant if select_variant == :single)), form_arguments: { builder: f, name: "foo" })) do |menu| %>
3
+ <% menu.with_show_button { "Strategy" } %>
4
+ <% end %>
5
+ <hr>
6
+ <div>
7
+ <%= f.submit(class: "Button--secondary Button--medium Button") %>
8
+ </div>
9
+ <% end %>
@@ -310,6 +310,20 @@ module Primer
310
310
  render_with_template(locals: { nest_in_sub_menu: nest_in_sub_menu })
311
311
  end
312
312
 
313
+ # @label Deferred refresh
314
+ #
315
+ # @param preload toggle
316
+ def deferred_refresh(preload: false)
317
+ render_with_template(locals: { preload: preload.to_s == "true" })
318
+ end
319
+
320
+ # @label Deferred refresh with form
321
+ #
322
+ # @hidden
323
+ def deferred_refresh_form(route_format: :json, select_variant: :multiple)
324
+ render_with_template(locals: { route_format: route_format, select_variant: select_variant.to_sym })
325
+ end
326
+
313
327
  # @label With deferred content near the bottom of the viewport
314
328
  #
315
329
  # @hidden
@@ -0,0 +1,3 @@
1
+ <%= render(Primer::Beta::Text.new(tag: :p)) do %>
2
+ Press <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Shift+p", format: :full, data: { platform: "other" })) %> to open the command palette.
3
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%= render(Primer::Alpha::ActionList.new(aria: { label: "Comment actions" })) do |list| %>
2
+ <% list.with_item(label: "Add comment") %>
3
+ <% list.with_item(label: "Save") do |item| %>
4
+ <% item.with_trailing_visual_keybinding_hint(keys: "Mod+Enter", data: { platform: "other" }) %>
5
+ <% end %>
6
+ <% list.with_item(label: "Preview") do |item| %>
7
+ <% item.with_trailing_visual_keybinding_hint(keys: "Mod+Shift+p", data: { platform: "other" }) %>
8
+ <% end %>
9
+ <% list.with_item(label: "Delete", scheme: :danger) do |item| %>
10
+ <% item.with_trailing_visual_keybinding_hint(keys: "Mod+Backspace", data: { platform: "other" }) %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <%= render(Primer::Box.new(display: :flex, style: "flex-direction: column; gap: var(--base-size-16)")) do %>
2
+ <% %i[default primary danger invisible].each do |scheme| %>
3
+ <%= render(Primer::Box.new(display: :flex, style: "gap: var(--base-size-8); align-items: center; flex-wrap: wrap")) do %>
4
+ <% %i[small medium large].each do |size| %>
5
+ <%= render(Primer::Beta::Button.new(scheme: scheme, size: size)) do |button| %>
6
+ <% button.with_trailing_visual_keybinding_hint(keys: "Mod+s", data: { platform: "other" }) %>
7
+ <%= "#{scheme} #{size}" %>
8
+ <% end %>
9
+ <% end %>
10
+ <%= render(Primer::Beta::Button.new(scheme: scheme, disabled: true)) do |button| %>
11
+ <% button.with_trailing_visual_keybinding_hint(keys: "Mod+s", data: { platform: "other" }) %>
12
+ <%= "#{scheme} disabled" %>
13
+ <% end %>
14
+ <%= render(Primer::Beta::Button.new(scheme: scheme, inactive: true)) do |button| %>
15
+ <% button.with_trailing_visual_keybinding_hint(keys: "Mod+s", data: { platform: "other" }) %>
16
+ <%= "#{scheme} inactive" %>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
20
+ <%= render(Primer::Beta::Button.new(aria: { label: "Save document" })) do |button| %>
21
+ <% button.with_trailing_visual_keybinding_hint(keys: "Mod+s", data: { platform: "other" }) %>
22
+ Save
23
+ <% end %>
24
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <%= render(Primer::Box.new(display: :flex, style: "gap: var(--base-size-16); align-items: center")) do %>
2
+ <% %w[apple windows other].each do |platform| %>
3
+ <%= render(Primer::Box.new(display: :flex, style: "gap: var(--base-size-8); align-items: center")) do %>
4
+ <%= render(Primer::Beta::Text.new(tag: :span, color: :muted)) { platform } %>
5
+ <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Alt+Shift+ArrowUp", data: { platform: platform })) %>
6
+ <% end %>
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <% platform_data = platform.to_s == "detect" ? {} : { platform: platform } %>
2
+ <% I18n.with_locale(locale) do %>
3
+ <%= render(Primer::OpenProject::KeybindingHint.new(keys: keys, format: format, scheme: scheme, size: size, data: platform_data)) %>
4
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= render(Primer::Beta::Text.new(tag: :p)) do %>
2
+ Press <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Enter", data: { platform: "other" })) %> to save, or <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Escape", data: { platform: "other" })) %> to cancel.
3
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= render(Primer::Box.new(display: :flex, style: "gap: var(--base-size-16); align-items: center")) do %>
2
+ <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Shift+p", scheme: :default, data: { platform: "other" })) %>
3
+ <%= render(Primer::Box.new(p: 2, style: "background: var(--bgColor-emphasis); color: var(--fgColor-onEmphasis); border-radius: var(--borderRadius-medium)")) do %>
4
+ <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Shift+p", scheme: :emphasis, data: { platform: "other" })) %>
5
+ <% end %>
6
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render(Primer::OpenProject::KeybindingHint.new(keys: "g i", data: { platform: "other" })) %>
@@ -0,0 +1,4 @@
1
+ <%= render(Primer::Box.new(display: :flex, style: "gap: var(--base-size-16); align-items: center")) do %>
2
+ <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Shift+p", size: :medium, data: { platform: "other" })) %>
3
+ <%= render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Shift+p", size: :small, data: { platform: "other" })) %>
4
+ <% end %>
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # @label KeybindingHint
6
+ class KeybindingHintPreview < ViewComponent::Preview
7
+ # `platform` is forced on snapshotted previews so CI (Linux) and
8
+ # developer machines (macOS) render the same glyphs.
9
+ #
10
+ # @label Default
11
+ # @snapshot
12
+ def default
13
+ render(Primer::OpenProject::KeybindingHint.new(keys: "Mod+Shift+p", data: { platform: "other" }))
14
+ end
15
+
16
+ # @label Playground
17
+ # @param keys text
18
+ # @param format [Symbol] select [condensed, full]
19
+ # @param scheme [Symbol] select [default, emphasis]
20
+ # @param size [Symbol] select [medium, small]
21
+ # @param platform [Symbol] select [detect, apple, windows, other]
22
+ # @param locale [Symbol] select [en, de]
23
+ def playground(keys: "Mod+Shift+p", format: :condensed, scheme: :default, size: :medium, platform: :detect, locale: :en)
24
+ render_with_template(locals: { keys: keys, format: format.to_sym, scheme: scheme.to_sym, size: size.to_sym, platform: platform.to_sym, locale: locale.to_sym })
25
+ end
26
+
27
+ # @label Full format
28
+ def full_format
29
+ render_with_template
30
+ end
31
+
32
+ # @label Sequence
33
+ def sequence
34
+ render_with_template
35
+ end
36
+
37
+ # @label Sizes
38
+ def sizes
39
+ render_with_template
40
+ end
41
+
42
+ # @label Schemes
43
+ def schemes
44
+ render_with_template
45
+ end
46
+
47
+ # @label Platforms
48
+ # @snapshot
49
+ def platforms
50
+ render_with_template
51
+ end
52
+
53
+ # @label In prose
54
+ def prose
55
+ render_with_template
56
+ end
57
+
58
+ # @label In Button
59
+ # @snapshot
60
+ def in_button
61
+ render_with_template
62
+ end
63
+
64
+ # @label In ActionList
65
+ # @snapshot
66
+ def in_action_list
67
+ render_with_template
68
+ end
69
+ end
70
+ end
71
+ end
@@ -518,6 +518,12 @@
518
518
  "default": "`{}`",
519
519
  "description": "Arguments to pass to the underlying [ActionMenu::List](/components/alpha/actionmenulist)"
520
520
  },
521
+ {
522
+ "name": "body_arguments",
523
+ "type": "Hash",
524
+ "default": "`{}`",
525
+ "description": "Arguments to pass to the underlying overlay's `body` slot."
526
+ },
521
527
  {
522
528
  "name": "system_arguments",
523
529
  "type": "Hash",
@@ -5153,7 +5159,7 @@
5153
5159
  "name": "minute",
5154
5160
  "type": "Symbol",
5155
5161
  "default": "`MINUTE_DEFAULT`",
5156
- "description": "What format minues should take. One of `nil`, `:numeric`, or `:two_digit`."
5162
+ "description": "What format minutes should take. One of `nil`, `:numeric`, or `:two_digit`."
5157
5163
  },
5158
5164
  {
5159
5165
  "name": "hour",
@@ -5161,6 +5167,12 @@
5161
5167
  "default": "`HOUR_DEFAULT`",
5162
5168
  "description": "What format hours should take. One of `nil`, `:numeric`, or `:two_digit`."
5163
5169
  },
5170
+ {
5171
+ "name": "hour_cycle",
5172
+ "type": "Symbol",
5173
+ "default": "`HOUR_CYCLE_DEFAULT`",
5174
+ "description": "What hour cycle should be used. One of `nil`, `:h11`, `:h12`, `:h23`, or `:h24`."
5175
+ },
5164
5176
  {
5165
5177
  "name": "weekday",
5166
5178
  "type": "Symbol",
@@ -6599,6 +6611,46 @@
6599
6611
  }
6600
6612
  ]
6601
6613
  },
6614
+ {
6615
+ "component": "OpenProject::KeybindingHint",
6616
+ "status": "open_project",
6617
+ "a11y_reviewed": false,
6618
+ "short_name": "OpenProjectKeybindingHint",
6619
+ "source": "https://github.com/primer/view_components/tree/main/app/components/primer/open_project/keybinding_hint.rb",
6620
+ "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/open_project/keybinding_hint/default/",
6621
+ "parameters": [
6622
+ {
6623
+ "name": "keys",
6624
+ "type": "String",
6625
+ "default": "N/A",
6626
+ "description": "The keys of the shortcut, e.g. `\"Mod+Shift+p\"` or `\"g i\"`. See the class documentation for the syntax."
6627
+ },
6628
+ {
6629
+ "name": "format",
6630
+ "type": "Symbol",
6631
+ "default": "`:condensed`",
6632
+ "description": "One of `:condensed` or `:full`. `:condensed` shows symbols (⌘⇧P) and suits menus and buttons; `:full` spells keys out (Command + Shift + P) and suits prose."
6633
+ },
6634
+ {
6635
+ "name": "scheme",
6636
+ "type": "Symbol",
6637
+ "default": "`:default`",
6638
+ "description": "One of `:default` or `:emphasis`. Use `:emphasis` on emphasis-coloured backgrounds."
6639
+ },
6640
+ {
6641
+ "name": "size",
6642
+ "type": "Symbol",
6643
+ "default": "`:medium`",
6644
+ "description": "One of `:medium` or `:small`."
6645
+ },
6646
+ {
6647
+ "name": "system_arguments",
6648
+ "type": "Hash",
6649
+ "default": "N/A",
6650
+ "description": "[System arguments](/system-arguments)"
6651
+ }
6652
+ ]
6653
+ },
6602
6654
  {
6603
6655
  "component": "OpenProject::PageHeader",
6604
6656
  "status": "open_project",
@@ -165,6 +165,7 @@
165
165
  "Primer::OpenProject::InlineMessage": "",
166
166
  "Primer::OpenProject::InputGroup": "",
167
167
  "Primer::OpenProject::InsetBox": "",
168
+ "Primer::OpenProject::KeybindingHint": "",
168
169
  "Primer::OpenProject::PageHeader": "",
169
170
  "Primer::OpenProject::PageHeader::Dialog": "",
170
171
  "Primer::OpenProject::PageHeader::Menu": "",
data/static/classes.json CHANGED
@@ -403,6 +403,18 @@
403
403
  "InsetBox--title-container": [
404
404
  "Primer::OpenProject::InsetBox"
405
405
  ],
406
+ "KeybindingHint-chord": [
407
+ "Primer::OpenProject::KeybindingHint"
408
+ ],
409
+ "KeybindingHint-chord--emphasis": [
410
+ "Primer::OpenProject::KeybindingHint"
411
+ ],
412
+ "KeybindingHint-chord--small": [
413
+ "Primer::OpenProject::KeybindingHint"
414
+ ],
415
+ "KeybindingHint-kbd": [
416
+ "Primer::OpenProject::KeybindingHint"
417
+ ],
406
418
  "Label": [
407
419
  "Primer::Beta::Label"
408
420
  ],
@@ -201,6 +201,10 @@ module.exports = new Set([
201
201
  'InsetBox--body',
202
202
  'InsetBox--body--clip_board_copy',
203
203
  'InsetBox--title-container',
204
+ 'KeybindingHint-chord',
205
+ 'KeybindingHint-chord--emphasis',
206
+ 'KeybindingHint-chord--small',
207
+ 'KeybindingHint-kbd',
204
208
  'Label',
205
209
  'Label--accent',
206
210
  'Label--attention',
data/static/classnames.js CHANGED
@@ -201,6 +201,10 @@ const classNames = new Set([
201
201
  'InsetBox--body',
202
202
  'InsetBox--body--clip_board_copy',
203
203
  'InsetBox--title-container',
204
+ 'KeybindingHint-chord',
205
+ 'KeybindingHint-chord--emphasis',
206
+ 'KeybindingHint-chord--small',
207
+ 'KeybindingHint-kbd',
204
208
  'Label',
205
209
  'Label--accent',
206
210
  'Label--attention',
@@ -1433,6 +1433,14 @@
1433
1433
  "narrow"
1434
1434
  ],
1435
1435
  "GeneratedSlotMethods": "Primer::Beta::RelativeTime::GeneratedSlotMethods",
1436
+ "HOUR_CYCLE_DEFAULT": null,
1437
+ "HOUR_CYCLE_OPTIONS": [
1438
+ null,
1439
+ "h11",
1440
+ "h12",
1441
+ "h23",
1442
+ "h24"
1443
+ ],
1436
1444
  "HOUR_DEFAULT": null,
1437
1445
  "HOUR_MAPPINGS": {
1438
1446
  "": null,
@@ -1928,6 +1936,33 @@
1928
1936
  }
1929
1937
  }
1930
1938
  },
1939
+ "Primer::OpenProject::KeybindingHint": {
1940
+ "DEFAULT_FORMAT": "condensed",
1941
+ "DEFAULT_SCHEME": "default",
1942
+ "DEFAULT_SIZE": "medium",
1943
+ "FORMAT_OPTIONS": [
1944
+ "condensed",
1945
+ "full"
1946
+ ],
1947
+ "GeneratedSlotMethods": "Primer::OpenProject::KeybindingHint::GeneratedSlotMethods",
1948
+ "Names": "Primer::OpenProject::KeybindingHint::Names",
1949
+ "SCHEME_MAPPINGS": {
1950
+ "default": "",
1951
+ "emphasis": "KeybindingHint-chord--emphasis"
1952
+ },
1953
+ "SCHEME_OPTIONS": [
1954
+ "default",
1955
+ "emphasis"
1956
+ ],
1957
+ "SIZE_MAPPINGS": {
1958
+ "medium": "",
1959
+ "small": "KeybindingHint-chord--small"
1960
+ },
1961
+ "SIZE_OPTIONS": [
1962
+ "medium",
1963
+ "small"
1964
+ ]
1965
+ },
1931
1966
  "Primer::OpenProject::PageHeader": {
1932
1967
  "BACK_BUTTON_ICON_OPTIONS": [
1933
1968
  "arrow-left",