primer_view_components 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/assets/styles/primer_view_components.css +2 -2
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_list/heading.html.erb +1 -1
  8. data/app/components/primer/alpha/action_list/heading.rb +5 -3
  9. data/app/components/primer/alpha/action_list/item.html.erb +9 -0
  10. data/app/components/primer/alpha/action_list/item.rb +31 -10
  11. data/app/components/primer/alpha/action_list.css +1 -1
  12. data/app/components/primer/alpha/action_list.css.json +4 -41
  13. data/app/components/primer/alpha/action_list.css.map +1 -1
  14. data/app/components/primer/alpha/action_list.pcss +19 -20
  15. data/app/components/primer/alpha/action_list.rb +54 -6
  16. data/app/components/primer/alpha/action_menu/action_menu_element.d.ts +22 -0
  17. data/app/components/primer/alpha/action_menu/action_menu_element.js +139 -0
  18. data/app/components/primer/alpha/action_menu/action_menu_element.ts +137 -0
  19. data/app/components/primer/alpha/action_menu/list.rb +81 -0
  20. data/app/components/primer/alpha/action_menu.html.erb +26 -0
  21. data/app/components/primer/alpha/action_menu.rb +322 -0
  22. data/app/components/primer/alpha/auto_complete.css.json +0 -11
  23. data/app/components/primer/alpha/banner.css.json +0 -14
  24. data/app/components/primer/alpha/button_marketing.css.json +0 -10
  25. data/app/components/primer/alpha/dialog.css.json +0 -63
  26. data/app/components/primer/alpha/dialog.rb +6 -2
  27. data/app/components/primer/alpha/dropdown.css.json +0 -21
  28. data/app/components/primer/alpha/layout.css.json +0 -27
  29. data/app/components/primer/alpha/menu.css.json +0 -11
  30. data/app/components/primer/alpha/nav_list/item.rb +5 -0
  31. data/app/components/primer/alpha/overlay.css +1 -1
  32. data/app/components/primer/alpha/overlay.css.json +0 -3
  33. data/app/components/primer/alpha/overlay.css.map +1 -1
  34. data/app/components/primer/alpha/overlay.pcss +1 -0
  35. data/app/components/primer/alpha/overlay.rb +14 -18
  36. data/app/components/primer/alpha/segmented_control.css.json +0 -15
  37. data/app/components/primer/alpha/tab_nav.css.json +0 -10
  38. data/app/components/primer/alpha/text_field.css.json +0 -38
  39. data/app/components/primer/alpha/toggle_switch.css.json +0 -16
  40. data/app/components/primer/alpha/underline_nav.css.json +0 -13
  41. data/app/components/primer/beta/avatar.css.json +0 -14
  42. data/app/components/primer/beta/avatar_stack.css.json +0 -9
  43. data/app/components/primer/beta/blankslate.css.json +0 -12
  44. data/app/components/primer/beta/border_box.css.json +0 -32
  45. data/app/components/primer/beta/border_box.rb +3 -3
  46. data/app/components/primer/beta/breadcrumbs.css.json +0 -4
  47. data/app/components/primer/beta/button.css +1 -1
  48. data/app/components/primer/beta/button.css.json +0 -22
  49. data/app/components/primer/beta/button.css.map +1 -1
  50. data/app/components/primer/beta/button.pcss +3 -3
  51. data/app/components/primer/beta/counter.css.json +0 -6
  52. data/app/components/primer/beta/flash.css.json +0 -15
  53. data/app/components/primer/beta/label.css.json +0 -20
  54. data/app/components/primer/beta/link.css.json +0 -8
  55. data/app/components/primer/beta/popover.css.json +0 -18
  56. data/app/components/primer/beta/progress_bar.css.json +0 -6
  57. data/app/components/primer/beta/state.css.json +0 -10
  58. data/app/components/primer/beta/subhead.css.json +0 -8
  59. data/app/components/primer/beta/timeline_item.css.json +0 -9
  60. data/app/components/primer/beta/truncate.css.json +0 -6
  61. data/app/components/primer/focus_group.d.ts +19 -0
  62. data/app/components/primer/focus_group.js +144 -0
  63. data/app/components/primer/focus_group.ts +137 -0
  64. data/app/components/primer/icon_button.rb +1 -1
  65. data/app/components/primer/primer.d.ts +2 -0
  66. data/app/components/primer/primer.js +2 -0
  67. data/app/components/primer/primer.ts +2 -0
  68. data/app/components/primer/truncate.css.json +0 -7
  69. data/app/lib/primer/css/layout.css.json +0 -263
  70. data/app/lib/primer/css/utilities.css.json +0 -1636
  71. data/lib/primer/static/generate_arguments.rb +55 -0
  72. data/lib/primer/static/generate_audited_at.rb +17 -0
  73. data/lib/primer/static/generate_constants.rb +19 -0
  74. data/lib/primer/static/generate_info_arch.rb +156 -0
  75. data/lib/primer/static/generate_previews.rb +45 -0
  76. data/lib/primer/static/generate_statuses.rb +17 -0
  77. data/lib/primer/static.rb +72 -0
  78. data/lib/primer/view_components/linters/disallow_component_css_counter.rb +43 -4
  79. data/lib/primer/view_components/version.rb +1 -1
  80. data/lib/primer/view_components.rb +0 -48
  81. data/lib/primer/yard/component_manifest.rb +1 -0
  82. data/lib/primer/yard/component_ref.rb +14 -0
  83. data/lib/primer/yard/docs_helper.rb +3 -0
  84. data/lib/primer/yard/info_arch_docs_helper.rb +31 -0
  85. data/lib/primer/yard/legacy_gatsby_backend.rb +3 -35
  86. data/lib/primer/yard/registry.rb +2 -1
  87. data/lib/primer/yard.rb +1 -0
  88. data/lib/tasks/docs.rake +10 -12
  89. data/lib/tasks/static.rake +20 -28
  90. data/previews/primer/alpha/action_list_preview.rb +4 -1
  91. data/previews/primer/alpha/action_menu_preview/align_end.html.erb +6 -0
  92. data/previews/primer/alpha/action_menu_preview/opens_dialog.html.erb +21 -0
  93. data/previews/primer/alpha/action_menu_preview.rb +238 -0
  94. data/previews/primer/alpha/dialog_preview/body_has_scrollbar_overflow.html.erb +2 -2
  95. data/previews/primer/alpha/dialog_preview/custom_header.html.erb +3 -3
  96. data/previews/primer/alpha/dialog_preview/nested_dialog.html.erb +4 -4
  97. data/previews/primer/alpha/dialog_preview/test.html.erb +3 -3
  98. data/previews/primer/alpha/dialog_preview/with_footer.html.erb +3 -3
  99. data/previews/primer/alpha/dialog_preview/with_form.html.erb +1 -1
  100. data/previews/primer/alpha/dialog_preview/with_text_input.html.erb +2 -2
  101. data/previews/primer/alpha/dialog_preview.rb +7 -2
  102. data/previews/primer/beta/auto_complete_item_preview.rb +1 -0
  103. data/static/arguments.json +3078 -1404
  104. data/static/audited_at.json +2 -0
  105. data/static/classes.json +576 -311
  106. data/static/constants.json +42 -2
  107. data/static/info_arch.json +8859 -0
  108. data/static/previews.json +221 -101
  109. data/static/statuses.json +2 -0
  110. metadata +23 -2
@@ -0,0 +1,322 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ module Primer
5
+ module Alpha
6
+ # The ActionMenu should be used when a user can select a single option triggering an action from a list of items. Primer will automatically nest an `Item` within a presentational `<li>` tag.
7
+ #
8
+ # The only allowed elements for the `Item` components are: `:a`, `:button`, and `:clipboard-copy`. If one isn't selected, a fallback `:span` will be used. To add functionality, use a `.js` class to create the functionality, or an `onclick` handler.
9
+ #
10
+ # @accessibility
11
+ # The action for the menu item needs to be on the element with `role="menuitem"`. Semantics are removed for everything nested inside of it. When a menu item is selected, the menu will close immediately.
12
+ #
13
+ # Additional information around the keyboard functionality and implementation can be found on the [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.2/#menu).
14
+ class ActionMenu < Primer::Component
15
+ status :alpha
16
+
17
+ DEFAULT_PRELOAD = false
18
+
19
+ DEFAULT_SELECT_VARIANT = :none
20
+ SELECT_VARIANT_OPTIONS = [
21
+ :single,
22
+ :multiple,
23
+ DEFAULT_SELECT_VARIANT
24
+ ].freeze
25
+
26
+ attr_reader :list, :preload
27
+
28
+ alias preload? preload
29
+
30
+ # @example Default
31
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-0") do |c| %>
32
+ # <% c.with_show_button { "Menu" } %>
33
+ # <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
34
+ # Primer Design
35
+ # <% end %>
36
+ # <% c.with_item(tag: :button, type: "button", onclick: "() => {}") do %>
37
+ # Quote Reply
38
+ # <% end %>
39
+ # <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
40
+ # Copy Text
41
+ # <% end %>
42
+ # <% end %>
43
+ #
44
+ # @example With caret
45
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-1") do |c| %>
46
+ # <% c.with_show_button(with_caret: true) { "Menu" } %>
47
+ # <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
48
+ # Primer Design
49
+ # <% end %>
50
+ # <% c.with_item(tag: :button, type: "button") do %>
51
+ # Quote Reply
52
+ # <% end %>
53
+ # <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
54
+ # Copy Text
55
+ # <% end %>
56
+ # <% end %>
57
+ #
58
+ # @example With `IconButton` trigger
59
+ # @description
60
+ # Set `icon:` to the octicon you want to use. Always provide an accessible name for the menu by setting `aria-label`.
61
+ # @code
62
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-2") do |c| %>
63
+ # <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
64
+ # <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
65
+ # Primer Design Link
66
+ # <% end %>
67
+ # <% c.with_item(tag: :button, type: "button") do %>
68
+ # Quote Reply
69
+ # <% end %>
70
+ # <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
71
+ # Copy Text
72
+ # <% end %>
73
+ # <% end %>
74
+ #
75
+ # @example With divider
76
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-3") do |c| %>
77
+ # <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
78
+ # <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
79
+ # Primer Design Link
80
+ # <% end %>
81
+ # <% c.with_item(tag: :button, type: "button") do %>
82
+ # Quote Reply
83
+ # <% end %>
84
+ # <% c.with_item(is_divider: true) %>
85
+ # <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
86
+ # Copy Text
87
+ # <% end %>
88
+ # <% end %>
89
+ #
90
+ # @example With danger item
91
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-4") do |c| %>
92
+ # <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
93
+ # <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
94
+ # Primer Design Link
95
+ # <% end %>
96
+ # <% c.with_item(tag: :button, type: "button") do %>
97
+ # Quote Reply
98
+ # <% end %>
99
+ # <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
100
+ # Copy Text
101
+ # <% end %>
102
+ # <% c.with_item(tag: :button, type: "button", is_dangerous: true) do %>
103
+ # Delete
104
+ # <% end %>
105
+ # <% end %>
106
+ #
107
+ # @example With center align
108
+ # @description
109
+ # Align the menu to the center of the trigger button
110
+ # @code
111
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-5", anchor_align: :center, anchor_side: :outside_top) do |c| %>
112
+ # <% c.with_show_button(with_caret: true) { "Outside top" } %>
113
+ # <% c.with_item do %>
114
+ # Item 1 that does something
115
+ # <% end %>
116
+ # <% c.with_item do %>
117
+ # Item 2 that does another thing
118
+ # <% end %>
119
+ # <% end %>
120
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-6", anchor_align: :center, anchor_side: :outside_left) do |c| %>
121
+ # <% c.with_show_button(with_caret: true) { "Outside left" } %>
122
+ # <% c.with_item do %>
123
+ # Item 1 that does something
124
+ # <% end %>
125
+ # <% c.with_item do %>
126
+ # Item 2 that does another thing
127
+ # <% end %>
128
+ # <% end %>
129
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-7", anchor_align: :center, anchor_side: :outside_right) do |c| %>
130
+ # <% c.with_show_button(with_caret: true) { "Outside right" } %>
131
+ # <% c.with_item do %>
132
+ # Item 1 that does something
133
+ # <% end %>
134
+ # <% c.with_item do %>
135
+ # Item 2 that does another thing
136
+ # <% end %>
137
+ # <% end %>
138
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-8", anchor_align: :center, anchor_side: :outside_bottom) do |c| %>
139
+ # <% c.with_show_button(with_caret: true) { "Outside bottom" } %>
140
+ # <% c.with_item do %>
141
+ # Item 1 that does something
142
+ # <% end %>
143
+ # <% c.with_item do %>
144
+ # Item 2 that does another thing
145
+ # <% end %>
146
+ # <% end %>
147
+ #
148
+ # @example With start align
149
+ # @description
150
+ # Align the menu to the start of the trigger button
151
+ # @code
152
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-9", anchor_align: :start, anchor_side: :outside_top) do |c| %>
153
+ # <% c.with_show_button(with_caret: true) { "Outside top" } %>
154
+ # <% c.with_item do %>
155
+ # Item 1 that does something
156
+ # <% end %>
157
+ # <% c.with_item do %>
158
+ # Item 2 that does another thing
159
+ # <% end %>
160
+ # <% end %>
161
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-10", anchor_align: :start, anchor_side: :outside_left) do |c| %>
162
+ # <% c.with_show_button(with_caret: true) { "Outside left" } %>
163
+ # <% c.with_item do %>
164
+ # Item 1 that does something
165
+ # <% end %>
166
+ # <% c.with_item do %>
167
+ # Item 2 that does another thing
168
+ # <% end %>
169
+ # <% end %>
170
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-11", anchor_align: :start, anchor_side: :outside_right) do |c| %>
171
+ # <% c.with_show_button(with_caret: true) { "Outside right" } %>
172
+ # <% c.with_item do %>
173
+ # Item 1 that does something
174
+ # <% end %>
175
+ # <% c.with_item do %>
176
+ # Item 2 that does another thing
177
+ # <% end %>
178
+ # <% end %>
179
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-12", anchor_align: :start, anchor_side: :outside_bottom) do |c| %>
180
+ # <% c.with_show_button(with_caret: true) { "Outside bottom" } %>
181
+ # <% c.with_item do %>
182
+ # Item 1 that does something
183
+ # <% end %>
184
+ # <% c.with_item do %>
185
+ # Item 2 that does another thing
186
+ # <% end %>
187
+ # <% end %>
188
+ #
189
+ # @example With end align
190
+ # @description
191
+ # Align the menu to the end of the trigger button
192
+ # @code
193
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-13", anchor_align: :end, anchor_side: :outside_top) do |c| %>
194
+ # <% c.with_show_button(with_caret: true) { "Outside top" } %>
195
+ # <% c.with_item do %>
196
+ # Item 1 that does something
197
+ # <% end %>
198
+ # <% c.with_item do %>
199
+ # Item 2 that does another thing
200
+ # <% end %>
201
+ # <% end %>
202
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-14", anchor_align: :end, anchor_side: :outside_left) do |c| %>
203
+ # <% c.with_show_button(with_caret: true) { "Outside left" } %>
204
+ # <% c.with_item do %>
205
+ # Item 1 that does something
206
+ # <% end %>
207
+ # <% c.with_item do %>
208
+ # Item 2 that does another thing
209
+ # <% end %>
210
+ # <% end %>
211
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-15", anchor_align: :end, anchor_side: :outside_right) do |c| %>
212
+ # <% c.with_show_button(with_caret: true) { "Outside right" } %>
213
+ # <% c.with_item do %>
214
+ # Item 1 that does something
215
+ # <% end %>
216
+ # <% c.with_item do %>
217
+ # Item 2 that does another thing
218
+ # <% end %>
219
+ # <% end %>
220
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-16", anchor_align: :end, anchor_side: :outside_bottom) do |c| %>
221
+ # <% c.with_show_button(with_caret: true) { "Outside bottom" } %>
222
+ # <% c.with_item do %>
223
+ # Item 1 that does something
224
+ # <% end %>
225
+ # <% c.with_item do %>
226
+ # Item 2 that does another thing
227
+ # <% end %>
228
+ # <% end %>
229
+ #
230
+ # @example With deferred menu content loaded with an `include-fragment`
231
+ # <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-3", src: "/") do |c| %>
232
+ # <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
233
+ # <% end %>
234
+ #
235
+ # @param menu_id [String] Id of the menu.
236
+ # @param anchor_align [Symbol] <%= one_of(Primer::Alpha::Overlay::ANCHOR_ALIGN_OPTIONS) %>.
237
+ # @param anchor_side [Symbol] <%= one_of(Primer::Alpha::Overlay::ANCHOR_SIDE_OPTIONS) %>.
238
+ # @param src [String] Used with an `include-fragment` element to load menu content from the given source URL.
239
+ # @param preload [Boolean] When true, and src is present, loads the `include-fragment` on trigger hover.
240
+ # @param dynamic_label [Boolean] Whether or not to display the text of the currently selected item in the show button.
241
+ # @param dynamic_label_prefix [String] If provided, the prefix is prepended to the dynamic label and displayed in the show button.
242
+ # @param select_variant [Symbol]. <%= one_of(Primer::Alpha::ActionMenu::SELECT_VARIANT_OPTIONS) %>.
243
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>.
244
+ def initialize(
245
+ menu_id: self.class.generate_id,
246
+ anchor_align: Primer::Alpha::Overlay::DEFAULT_ANCHOR_ALIGN,
247
+ anchor_side: Primer::Alpha::Overlay::DEFAULT_ANCHOR_SIDE,
248
+ src: nil,
249
+ preload: DEFAULT_PRELOAD,
250
+ dynamic_label: false,
251
+ dynamic_label_prefix: nil,
252
+ select_variant: DEFAULT_SELECT_VARIANT,
253
+ **system_arguments
254
+ )
255
+ @menu_id = menu_id
256
+ @src = src
257
+ @preload = fetch_or_fallback_boolean(preload, DEFAULT_PRELOAD)
258
+ @system_arguments = deny_tag_argument(**system_arguments)
259
+
260
+ @system_arguments[:preload] = true if @src.present? && preload?
261
+
262
+ select_variant = fetch_or_fallback(SELECT_VARIANT_OPTIONS, select_variant, DEFAULT_SELECT_VARIANT)
263
+
264
+ @system_arguments[:tag] = :"action-menu"
265
+ @system_arguments[:"data-select-variant"] = select_variant
266
+ @system_arguments[:"data-dynamic-label"] = "" if dynamic_label
267
+ @system_arguments[:"data-dynamic-label-prefix"] = dynamic_label_prefix if dynamic_label_prefix.present?
268
+
269
+ @overlay = Primer::Alpha::Overlay.new(
270
+ id: "#{@menu_id}-overlay",
271
+ title: "Menu",
272
+ visually_hide_title: true,
273
+ anchor_align: anchor_align,
274
+ anchor_side: anchor_side
275
+ )
276
+
277
+ @list = Primer::Alpha::ActionMenu::List.new(
278
+ menu_id: @menu_id,
279
+ select_variant: select_variant
280
+ )
281
+ end
282
+
283
+ # Button to activate the menu. This may be a <%= link_to_component(Primer::ButtonComponent) %> or <%= link_to_component(Primer::IconButton) %>.
284
+ #
285
+ # @param icon [Symbol] Set this to an [Octicon name](https://primer.style/octicons/) when you want to render an `IconButton`. Otherwise, this renders as a <%= link_to_component(Primer::ButtonComponent) %>.
286
+ def with_show_button(**system_arguments, &block)
287
+ @overlay.with_show_button(**system_arguments, id: "#{@menu_id}-button", controls: "#{@menu_id}-list", &block)
288
+ end
289
+
290
+ # Adds a new item to the list.
291
+ #
292
+ # @param system_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Alpha::ActionList::Item) %>.
293
+ def with_item(**system_arguments, &block)
294
+ @list.with_item(**system_arguments, &block)
295
+ end
296
+
297
+ # Retrieves the list of items.
298
+ def items
299
+ @list.items
300
+ end
301
+
302
+ # Adds a divider to the list.
303
+ #
304
+ # @param system_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Alpha::ActionList) %>'s `divider` slot.
305
+ def with_divider(**system_arguments, &block)
306
+ @list.with_divider(**system_arguments, &block)
307
+ end
308
+
309
+ private
310
+
311
+ def before_render
312
+ content
313
+
314
+ raise ArgumentError, "`items` cannot be set when `src` is specified" if @src.present? && items.any?
315
+ end
316
+
317
+ def render?
318
+ items.any? || @src.present?
319
+ end
320
+ end
321
+ end
322
+ end
@@ -19,16 +19,5 @@
19
19
  ".autocomplete-item.navigation-focus *",
20
20
  ".autocomplete-item.selected *",
21
21
  ".autocomplete-item[aria-selected=true] *"
22
- ],
23
- "classes": [
24
- "autocomplete-label-stacked",
25
- "autocomplete-label-inline",
26
- "autocomplete-body",
27
- "autocomplete-embedded-icon-wrap",
28
- "form-control",
29
- "autocomplete-results",
30
- "autocomplete-item",
31
- "navigation-focus",
32
- "selected"
33
22
  ]
34
23
  }
@@ -20,19 +20,5 @@
20
20
  ".Banner.Banner--success .Banner-visual .octicon",
21
21
  ".Banner.Banner--full",
22
22
  ".Banner.Banner--full-whenNarrow"
23
- ],
24
- "classes": [
25
- "Banner",
26
- "Banner-actions",
27
- "Banner-visual",
28
- "octicon",
29
- "Banner-message",
30
- "Banner-title",
31
- "Banner-close",
32
- "Banner--warning",
33
- "Banner--error",
34
- "Banner--success",
35
- "Banner--full",
36
- "Banner--full-whenNarrow"
37
23
  ]
38
24
  }
@@ -29,15 +29,5 @@
29
29
  ".btn-signup-mktg:focus-visible",
30
30
  ".btn-small-mktg",
31
31
  ".btn-large-mktg"
32
- ],
33
- "classes": [
34
- "btn-mktg",
35
- "focus",
36
- "disabled",
37
- "btn-muted-mktg",
38
- "btn-subtle-mktg",
39
- "btn-signup-mktg",
40
- "btn-small-mktg",
41
- "btn-large-mktg"
42
32
  ]
43
33
  }
@@ -78,68 +78,5 @@
78
78
  ".Overlay-backdrop--side-whenNarrow.Overlay-backdrop--placement-top-whenNarrow>.Overlay-whenNarrow",
79
79
  ".Overlay-backdrop--full-whenNarrow",
80
80
  ".Overlay-backdrop--full-whenNarrow .Overlay"
81
- ],
82
- "classes": [
83
- "Overlay--hidden",
84
- "Overlay--visibilityHidden",
85
- "Overlay",
86
- "Overlay--size-auto",
87
- "Overlay--size-full",
88
- "Overlay--size-xsmall",
89
- "Overlay--size-small",
90
- "Overlay--size-small-portrait",
91
- "Overlay--size-medium",
92
- "Overlay--size-medium-portrait",
93
- "Overlay--size-large",
94
- "Overlay--size-xlarge",
95
- "Overlay--height-auto",
96
- "Overlay--height-xsmall",
97
- "Overlay--height-small",
98
- "Overlay--height-medium",
99
- "Overlay--height-large",
100
- "Overlay--height-xlarge",
101
- "Overlay--width-auto",
102
- "Overlay--width-small",
103
- "Overlay--width-medium",
104
- "Overlay--width-large",
105
- "Overlay--width-xlarge",
106
- "Overlay--width-xxlarge",
107
- "Overlay--motion-scaleFade",
108
- "Overlay-form",
109
- "Overlay-header",
110
- "Overlay-header--divided",
111
- "Overlay-body",
112
- "Overlay-header--large",
113
- "Overlay-headerContentWrap",
114
- "Overlay-titleWrap",
115
- "Overlay-title",
116
- "Overlay-description",
117
- "Overlay-actionWrap",
118
- "Overlay-body--paddingCondensed",
119
- "Overlay-body--paddingNone",
120
- "Overlay-footer",
121
- "Overlay-footer--divided",
122
- "Overlay-footer--alignStart",
123
- "Overlay-footer--alignCenter",
124
- "Overlay-footer--alignEnd",
125
- "Overlay-closeButton",
126
- "close-button",
127
- "Overlay-backdrop--center",
128
- "Overlay-backdrop--anchor",
129
- "Overlay-backdrop--side",
130
- "Overlay-backdrop--placement-left",
131
- "Overlay-backdrop--placement-right",
132
- "Overlay-backdrop--placement-bottom",
133
- "Overlay-backdrop--placement-top",
134
- "Overlay-backdrop--full",
135
- "Overlay-backdrop--center-whenNarrow",
136
- "Overlay-backdrop--anchor-whenNarrow",
137
- "Overlay-backdrop--side-whenNarrow",
138
- "Overlay-backdrop--placement-left-whenNarrow",
139
- "Overlay-whenNarrow",
140
- "Overlay-backdrop--placement-right-whenNarrow",
141
- "Overlay-backdrop--placement-bottom-whenNarrow",
142
- "Overlay-backdrop--placement-top-whenNarrow",
143
- "Overlay-backdrop--full-whenNarrow"
144
81
  ]
145
82
  }
@@ -53,13 +53,17 @@ module Primer
53
53
  # Optional button to open the dialog.
54
54
  #
55
55
  # @param system_arguments [Hash] The same arguments as <%= link_to_component(Primer::Beta::Button) %>.
56
- renders_one :show_button, lambda { |**system_arguments|
56
+ renders_one :show_button, lambda { |icon: nil, **system_arguments|
57
57
  system_arguments[:classes] = class_names(
58
58
  system_arguments[:classes]
59
59
  )
60
60
  system_arguments[:id] = "dialog-show-#{@system_arguments[:id]}"
61
61
  system_arguments[:data] = (system_arguments[:data] || {}).merge({ "show-dialog-id": @system_arguments[:id] })
62
- Primer::Beta::Button.new(**system_arguments)
62
+ if icon.present?
63
+ Primer::Beta::IconButton.new(icon: icon, **system_arguments)
64
+ else
65
+ Primer::Beta::Button.new(**system_arguments)
66
+ end
63
67
  }
64
68
 
65
69
  # Header content.
@@ -36,26 +36,5 @@
36
36
  ".dropdown-menu-sw:after",
37
37
  ".dropdown-menu-se:before",
38
38
  ".dropdown-menu-se:after"
39
- ],
40
- "classes": [
41
- "dropdown",
42
- "dropdown-caret",
43
- "dropdown-menu",
44
- "dropdown-menu-no-overflow",
45
- "dropdown-item",
46
- "octicon",
47
- "color-fg-",
48
- "Label",
49
- "btn-link",
50
- "dropdown-signout",
51
- "dropdown-divider",
52
- "dropdown-header",
53
- "octicon-check",
54
- "dropdown-menu-w",
55
- "dropdown-menu-e",
56
- "dropdown-menu-ne",
57
- "dropdown-menu-s",
58
- "dropdown-menu-sw",
59
- "dropdown-menu-se"
60
39
  ]
61
40
  }
@@ -76,32 +76,5 @@
76
76
  ".Layout-main .Layout-main-centered-xl>.container-lg",
77
77
  ".Layout-main .Layout-main-centered-xl>.container-md",
78
78
  ".Layout-main .Layout-main-centered-xl>.container-xl"
79
- ],
80
- "classes": [
81
- "Layout",
82
- "Layout-divider",
83
- "Layout-main",
84
- "Layout-sidebar",
85
- "Layout--sidebarPosition-flowRow-start",
86
- "Layout--sidebarPosition-flowRow-end",
87
- "Layout--sidebarPosition-flowRow-none",
88
- "Layout--divided",
89
- "Layout-divider--flowRow-hidden",
90
- "Layout-divider--flowRow-shallow",
91
- "Layout--flowRow-until-md",
92
- "Layout--flowRow-until-lg",
93
- "Layout--gutter-none",
94
- "Layout--gutter-condensed",
95
- "Layout--gutter-spacious",
96
- "Layout--sidebar-narrow",
97
- "Layout--sidebar-wide",
98
- "Layout--sidebarPosition-start",
99
- "Layout--sidebarPosition-end",
100
- "Layout-main-centered-lg",
101
- "Layout-main-centered-md",
102
- "Layout-main-centered-xl",
103
- "container-lg",
104
- "container-md",
105
- "container-xl"
106
79
  ]
107
80
  }
@@ -24,16 +24,5 @@
24
24
  ".menu-heading:hover",
25
25
  ".menu-heading:first-child",
26
26
  ".menu-heading:last-child"
27
- ],
28
- "classes": [
29
- "menu",
30
- "menu-item",
31
- "selected",
32
- "octicon",
33
- "Counter",
34
- "menu-warning",
35
- "avatar",
36
- "alert",
37
- "menu-heading"
38
27
  ]
39
28
  }
@@ -73,6 +73,11 @@ module Primer
73
73
  @content_arguments[:classes],
74
74
  "ActionListContent--hasActiveSubItem"
75
75
  )
76
+ else
77
+ @system_arguments[:classes] = class_names(
78
+ @system_arguments[:classes],
79
+ "ActionListItem--navActive" => active?
80
+ )
76
81
  end
77
82
 
78
83
  super
@@ -1 +1 @@
1
- .Overlay[popover]{border-width:0;padding:0;position:absolute}.Overlay[popover]:not(:open){display:none}anchored-position{display:block}
1
+ .Overlay[popover]{border-width:0;padding:0;position:absolute;width:min(192px,100vw - 2rem)}.Overlay[popover]:not(:open){display:none}anchored-position{display:block}
@@ -4,8 +4,5 @@
4
4
  ".Overlay[popover]",
5
5
  ".Overlay[popover]:not(:open)",
6
6
  "anchored-position"
7
- ],
8
- "classes": [
9
- "Overlay"
10
7
  ]
11
8
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["overlay.pcss"],"names":[],"mappings":"AAAA,kBACE,cAAe,CACf,SAAU,CACV,iBACF,CAGA,6BACE,YACF,CAEA,kBACE,aACF","file":"overlay.css","sourcesContent":[".Overlay[popover] {\n border-width: 0;\n padding: 0;\n position: absolute;\n}\n\n/* stylelint-disable-next-line selector-pseudo-class-no-unknown */\n.Overlay[popover]:not(:open) {\n display: none;\n}\n\nanchored-position {\n display: block;\n}\n"]}
1
+ {"version":3,"sources":["overlay.pcss"],"names":[],"mappings":"AAAA,kBACE,cAAe,CACf,SAAU,CACV,iBAAkB,CAClB,6BACF,CAGA,6BACE,YACF,CAEA,kBACE,aACF","file":"overlay.css","sourcesContent":[".Overlay[popover] {\n border-width: 0;\n padding: 0;\n position: absolute;\n width: min(192px, 100vw - 2rem);\n}\n\n/* stylelint-disable-next-line selector-pseudo-class-no-unknown */\n.Overlay[popover]:not(:open) {\n display: none;\n}\n\nanchored-position {\n display: block;\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  border-width: 0;
3
3
  padding: 0;
4
4
  position: absolute;
5
+ width: min(192px, 100vw - 2rem);
5
6
  }
6
7
 
7
8
  /* stylelint-disable-next-line selector-pseudo-class-no-unknown */
@@ -63,22 +63,23 @@ module Primer
63
63
  DEFAULT_POPOVER = :auto
64
64
  POPOVER_OPTIONS = [DEFAULT_POPOVER, :manual].freeze
65
65
 
66
- ROLE_OPTIONS = [:dialog, :menu].freeze
66
+ ROLE_OPTIONS = [:dialog, :menu, nil].freeze
67
67
 
68
68
  # Optional button to open the Overlay.
69
69
  #
70
70
  # @param system_arguments [Hash] The same arguments as <%= link_to_component(Primer::ButtonComponent) %>.
71
- renders_one :show_button, lambda { |icon: nil, **system_arguments|
72
- system_arguments[:classes] = class_names(
73
- system_arguments[:classes]
71
+ renders_one :show_button, lambda { |icon: nil, controls: nil, **button_arguments|
72
+ button_arguments[:classes] = class_names(
73
+ button_arguments[:classes]
74
74
  )
75
- system_arguments[:id] = show_button_id
76
- system_arguments["popovertoggletarget"] = overlay_id
77
- system_arguments[:aria] = (system_arguments[:aria] || {}).merge({ controls: overlay_id, haspopup: "true" })
75
+ button_arguments[:id] ||= show_button_id
76
+ @system_arguments[:anchor] = button_arguments[:id]
77
+ button_arguments["popovertarget"] = @id
78
+ button_arguments[:aria] = (button_arguments[:aria] || {}).merge({ controls: controls, haspopup: "true" })
78
79
  if icon.present?
79
- Primer::Beta::IconButton.new(icon: icon, **system_arguments)
80
+ Primer::Beta::IconButton.new(icon: icon, **button_arguments)
80
81
  else
81
- Primer::Beta::Button.new(**system_arguments)
82
+ Primer::Beta::Button.new(**button_arguments)
82
83
  end
83
84
  }
84
85
 
@@ -134,7 +135,6 @@ module Primer
134
135
  # @param title [String] Describes the content of the Overlay.
135
136
  # @param subtitle [String] Provides dditional context for the Overlay, also setting the `aria-describedby` attribute.
136
137
  # @param popover [Symbol] The popover behaviour. <%= one_of(Primer::Alpha::Overlay::POPOVER_OPTIONS) %>
137
- # @param popover [Symbol] The popover behaviour. <%= one_of(Primer::Alpha::Overlay::POPOVER_OPTIONS) %>
138
138
  # @param size [Symbol] The size of the Overlay. <%= one_of(Primer::Alpha::Overlay::SIZE_OPTIONS) %>
139
139
  # @param padding [Symbol] The padding given to the Overlay body. <%= one_of(Primer::Alpha::Overlay::PADDING_OPTIONS) %>
140
140
  # @param anchor [String] An ID of the element to anchor onto. Defaults to the `show_button`.
@@ -147,7 +147,7 @@ module Primer
147
147
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
148
148
  def initialize(
149
149
  title:,
150
- role:,
150
+ role: nil,
151
151
  subtitle: nil,
152
152
  popover: DEFAULT_POPOVER,
153
153
  size: DEFAULT_SIZE,
@@ -163,7 +163,7 @@ module Primer
163
163
  )
164
164
  @system_arguments = deny_tag_argument(**system_arguments)
165
165
 
166
- @system_arguments[:role] = fetch_or_fallback(ROLE_OPTIONS, role)
166
+ @system_arguments[:role] = fetch_or_fallback(ROLE_OPTIONS, role) if role.present?
167
167
 
168
168
  @system_arguments[:id] = id.to_s
169
169
  @system_arguments[:classes] = class_names(
@@ -198,16 +198,12 @@ module Primer
198
198
 
199
199
  private
200
200
 
201
- def overlay_id
202
- @system_arguments[:id]
203
- end
204
-
205
201
  def title_id
206
- "overlay-title-#{overlay_id}"
202
+ "overlay-title-#{@id}"
207
203
  end
208
204
 
209
205
  def show_button_id
210
- "overlay-show-#{overlay_id}"
206
+ "overlay-show-#{@id}"
211
207
  end
212
208
  end
213
209
  end