primer_view_components 0.0.114 → 0.0.115

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -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/divider.rb +2 -0
  8. data/app/components/primer/alpha/action_list/heading.rb +2 -0
  9. data/app/components/primer/alpha/action_list/item.rb +8 -6
  10. data/app/components/primer/alpha/action_list.rb +1 -0
  11. data/app/components/primer/alpha/auto_complete/auto_complete.html.erb +1 -1
  12. data/app/components/primer/alpha/auto_complete/item.rb +1 -0
  13. data/app/components/primer/alpha/auto_complete.rb +3 -2
  14. data/app/components/primer/alpha/banner.html.erb +1 -1
  15. data/app/components/primer/alpha/banner.rb +1 -0
  16. data/app/components/primer/alpha/button_marketing.rb +2 -0
  17. data/app/components/primer/alpha/dialog.rb +3 -0
  18. data/app/components/primer/alpha/image.rb +1 -0
  19. data/app/components/primer/alpha/image_crop.html.erb +1 -1
  20. data/app/components/primer/alpha/layout.css +1 -0
  21. data/app/components/primer/alpha/layout.css.json +1 -0
  22. data/app/components/primer/alpha/layout.css.map +1 -0
  23. data/app/components/primer/alpha/layout.pcss +268 -0
  24. data/app/components/primer/{menu_component.css → alpha/menu.css} +0 -0
  25. data/app/components/primer/alpha/menu.css.json +1 -0
  26. data/app/components/primer/alpha/menu.css.map +1 -0
  27. data/app/components/primer/{menu_component.html.erb → alpha/menu.html.erb} +0 -0
  28. data/app/components/primer/{menu_component.pcss → alpha/menu.pcss} +0 -0
  29. data/app/components/primer/alpha/menu.rb +76 -0
  30. data/app/components/primer/{octicon_symbols_component.html.erb → alpha/octicon_symbols.html.erb} +0 -0
  31. data/app/components/primer/alpha/octicon_symbols.rb +61 -0
  32. data/app/components/primer/alpha/text_field.rb +1 -0
  33. data/app/components/primer/alpha/toggle_switch.html.erb +2 -2
  34. data/app/components/primer/alpha/toggle_switch.rb +2 -0
  35. data/app/components/primer/alpha/tool_tip.js +77 -69
  36. data/app/components/primer/alpha/tool_tip.ts +63 -51
  37. data/app/components/primer/alpha/tooltip.rb +2 -0
  38. data/app/components/primer/beta/auto_complete/item.rb +4 -4
  39. data/app/components/primer/beta/auto_complete.rb +3 -3
  40. data/app/components/primer/beta/avatar.rb +1 -0
  41. data/app/components/primer/beta/base_button.rb +1 -0
  42. data/app/components/primer/beta/blankslate.rb +5 -5
  43. data/app/components/primer/beta/button.rb +7 -7
  44. data/app/components/primer/beta/clipboard_copy.html.erb +2 -2
  45. data/app/components/primer/beta/clipboard_copy.rb +1 -0
  46. data/app/components/primer/beta/close_button.rb +2 -1
  47. data/app/components/primer/beta/counter.rb +1 -0
  48. data/app/components/primer/beta/heading.rb +1 -0
  49. data/app/components/primer/beta/icon_button.html.erb +1 -1
  50. data/app/components/primer/beta/icon_button.rb +1 -0
  51. data/app/components/primer/beta/label.rb +1 -0
  52. data/app/components/primer/beta/markdown.rb +1 -0
  53. data/app/components/primer/{octicon_component.html.erb → beta/octicon.html.erb} +0 -0
  54. data/app/components/primer/beta/octicon.rb +88 -0
  55. data/app/components/primer/beta/relative_time.rb +2 -1
  56. data/app/components/primer/{spinner_component.html.erb → beta/spinner.html.erb} +0 -0
  57. data/app/components/primer/beta/spinner.rb +46 -0
  58. data/app/components/primer/beta/text.rb +1 -0
  59. data/app/components/primer/blankslate_component.rb +3 -3
  60. data/app/components/primer/box.rb +1 -0
  61. data/app/components/primer/button_component.rb +3 -3
  62. data/app/components/primer/conditional_wrapper.rb +2 -0
  63. data/app/components/primer/hellip_button.rb +2 -0
  64. data/app/components/primer/icon_button.html.erb +2 -2
  65. data/app/components/primer/icon_button.rb +1 -0
  66. data/app/components/primer/layout_component.rb +2 -0
  67. data/app/components/primer/local_time.rb +3 -0
  68. data/app/components/primer/menu_component.rb +2 -69
  69. data/app/components/primer/navigation/tab_component.rb +2 -2
  70. data/app/components/primer/octicon_component.rb +3 -81
  71. data/app/components/primer/octicon_symbols_component.rb +2 -52
  72. data/app/components/primer/primer.d.ts +2 -0
  73. data/app/components/primer/primer.js +2 -0
  74. data/app/components/primer/primer.pcss +2 -1
  75. data/app/components/primer/primer.ts +2 -0
  76. data/app/components/primer/spinner_component.rb +2 -38
  77. data/app/components/primer/state_component.rb +1 -0
  78. data/app/components/primer/subhead_component.rb +2 -0
  79. data/app/components/primer/tab_container_component.rb +2 -0
  80. data/app/components/primer/time_ago_component.rb +2 -1
  81. data/app/components/primer/timeline_item_component.rb +3 -2
  82. data/app/components/primer/tooltip.rb +1 -0
  83. data/app/components/primer/truncate.rb +2 -0
  84. data/app/forms/immediate_validation_form.rb +29 -0
  85. data/app/forms/multi_input_form.rb +4 -2
  86. data/app/lib/primer/css/layout.css +1 -378
  87. data/app/lib/primer/css/layout.css.json +1 -1
  88. data/app/lib/primer/octicon/cache.rb +1 -1
  89. data/app/lib/primer/view_helper.rb +1 -1
  90. data/lib/primer/deprecations.yml +26 -0
  91. data/lib/primer/forms/builder.rb +48 -8
  92. data/lib/primer/forms/check_box.html.erb +3 -1
  93. data/lib/primer/forms/dsl/input.rb +23 -1
  94. data/lib/primer/forms/dsl/multi_input.rb +6 -9
  95. data/lib/primer/forms/dsl/select_list_input.rb +1 -1
  96. data/lib/primer/forms/dsl/text_field_input.rb +31 -1
  97. data/lib/primer/forms/form_control.html.erb +17 -13
  98. data/lib/primer/forms/form_control.rb +2 -0
  99. data/lib/primer/forms/multi.html.erb +6 -2
  100. data/lib/primer/forms/primer_multi_input.d.ts +10 -0
  101. data/lib/primer/forms/primer_multi_input.js +45 -0
  102. data/lib/primer/forms/primer_multi_input.ts +46 -0
  103. data/lib/primer/forms/primer_text_field.d.ts +1 -0
  104. data/lib/primer/forms/primer_text_field.js +62 -0
  105. data/lib/primer/forms/primer_text_field.ts +48 -0
  106. data/lib/primer/forms/radio_button.html.erb +3 -1
  107. data/lib/primer/forms/text_field.html.erb +8 -8
  108. data/lib/primer/forms/text_field.rb +11 -0
  109. data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +1 -1
  110. data/lib/primer/view_components/version.rb +1 -1
  111. data/lib/tasks/docs.rake +5 -5
  112. data/lib/tasks/helpers/ast_traverser.rb +1 -1
  113. data/previews/primer/alpha/action_list_preview.rb +1 -1
  114. data/previews/primer/alpha/auto_complete_preview.rb +62 -6
  115. data/previews/primer/alpha/layout_preview.rb +179 -6
  116. data/previews/primer/{menu_component_preview → alpha/menu_preview}/default.html.erb +3 -3
  117. data/previews/primer/{menu_component_preview → alpha/menu_preview}/playground.html.erb +3 -3
  118. data/previews/primer/alpha/menu_preview.rb +14 -0
  119. data/previews/primer/alpha/toggle_switch_preview.rb +11 -9
  120. data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +1 -1
  121. data/previews/primer/beta/auto_complete_preview.rb +19 -17
  122. data/previews/primer/beta/octicon_preview.rb +24 -0
  123. data/previews/primer/beta/spinner_preview.rb +22 -0
  124. data/previews/primer/forms/forms_preview/immediate_validation_form.html.erb +3 -0
  125. data/previews/primer/forms/forms_preview/multi_input_form.html.erb +12 -1
  126. data/previews/primer/forms/forms_preview.rb +2 -0
  127. data/previews/primer/url_helpers.rb +15 -0
  128. data/static/arguments.json +159 -159
  129. data/static/audited_at.json +4 -0
  130. data/static/constants.json +42 -34
  131. data/static/statuses.json +10 -6
  132. metadata +32 -15
  133. data/app/components/primer/menu_component.css.json +0 -1
  134. data/app/components/primer/menu_component.css.map +0 -1
  135. data/previews/primer/menu_component_preview.rb +0 -12
  136. data/previews/primer/octicon_component_preview.rb +0 -22
  137. data/previews/primer/spinner_component_preview.rb +0 -20
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "octicons"
4
+
5
+ module Primer
6
+ module Alpha
7
+ # OcticonSymbols renders a symbol dictionary using a list of <%= link_to_octicons %>.
8
+ class OcticonSymbols < Primer::Component
9
+ warn_on_deprecated_slot_setter
10
+
11
+ # @example Symbol dictionary
12
+ # <%= render(Primer::Beta::Octicon.new(icon: :check, use_symbol: true, color: :success)) %>
13
+ # <%= render(Primer::Beta::Octicon.new(icon: :check, use_symbol: true, color: :danger)) %>
14
+ # <%= render(Primer::Beta::Octicon.new(icon: :check, use_symbol: true, size: :medium)) %>
15
+ # <%= render(Primer::Alpha::OcticonSymbols.new(icons: [{ symbol: :check }, { symbol: :check, size: :medium }])) %>
16
+ #
17
+ # @param icons [Array<Hash>] List of icons to render, in the format { symbol: :icon_name, size: :small }
18
+ def initialize(icons: [])
19
+ @icons = {}
20
+ icons.each do |icon|
21
+ symbol = icon[:symbol]
22
+ size = Primer::Beta::Octicon::SIZE_MAPPINGS[
23
+ fetch_or_fallback(Primer::Beta::Octicon::SIZE_OPTIONS, icon[:size] || Primer::Beta::Octicon::SIZE_DEFAULT, Primer::Beta::Octicon::SIZE_DEFAULT)
24
+ ]
25
+
26
+ cache_key = Primer::Octicon::Cache.get_key(symbol: symbol, size: size)
27
+
28
+ if (cache_icon = Primer::Octicon::Cache.read(cache_key))
29
+ icon_instance = cache_icon
30
+ else
31
+ icon_instance = Octicons::Octicon.new(symbol, height: size)
32
+
33
+ Primer::Octicon::Cache.set(cache_key, icon_instance)
34
+ end
35
+
36
+ # Don't put the same icon twice
37
+ @icons[[symbol, icon_instance.height]] = icon_instance if @icons[[symbol, icon_instance.height]].nil?
38
+ end
39
+ end
40
+
41
+ def render?
42
+ @icons.any?
43
+ end
44
+
45
+ def symbol_tags
46
+ safe_join(
47
+ @icons.values.map do |icon|
48
+ content_tag(
49
+ :symbol,
50
+ icon.path.html_safe, # rubocop:disable Rails/OutputSafety
51
+ id: "octicon_#{icon.symbol}_#{icon.height}",
52
+ viewBox: icon.options[:viewBox],
53
+ width: icon.width,
54
+ height: icon.height
55
+ )
56
+ end
57
+ )
58
+ end
59
+ end
60
+ end
61
+ end
@@ -7,6 +7,7 @@ module Primer
7
7
  # A text field suitable for use outside a form. For a text field input suitable for use
8
8
  # within an HTML form, see the `Primer::Forms` namespace.
9
9
  class TextField < Primer::Component
10
+ warn_on_deprecated_slot_setter
10
11
  status :alpha
11
12
 
12
13
  # @!method initialize
@@ -1,6 +1,6 @@
1
1
  <%= render(Primer::BaseComponent.new(tag: "toggle-switch", **@system_arguments)) do %>
2
- <%= render(Primer::OcticonComponent.new(size: :small, color: :danger, icon: :alert, hidden: "true", data: { target: "toggle-switch.errorIcon" })) %>
3
- <%= render(Primer::SpinnerComponent.new(size: :small, hidden: "true", data: { target: "toggle-switch.loadingSpinner" })) %>
2
+ <%= render(Primer::Beta::Octicon.new(size: :small, color: :danger, icon: :alert, hidden: "true", data: { target: "toggle-switch.errorIcon" })) %>
3
+ <%= render(Primer::Beta::Spinner.new(size: :small, hidden: "true", data: { target: "toggle-switch.loadingSpinner" })) %>
4
4
  <%= render(Primer::Beta::Text.new(aria: { hidden: true }, classes: "ToggleSwitch-status")) do %>
5
5
  <%= render(Primer::Box.new(classes: "ToggleSwitch-statusOn").with_content("On")) %>
6
6
  <%= render(Primer::Box.new(classes: "ToggleSwitch-statusOff").with_content("Off")) %>
@@ -6,6 +6,8 @@ module Primer
6
6
  # settings that should cause an immediate update. If configured with a "src" attribute, the component will
7
7
  # make a POST request containing data of the form "value: 0 | 1".
8
8
  class ToggleSwitch < Primer::Component
9
+ warn_on_deprecated_slot_setter
10
+
9
11
  SIZE_DEFAULT = :medium
10
12
  SIZE_MAPPINGS = {
11
13
  SIZE_DEFAULT => nil,
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- var _ToolTipElement_instances, _ToolTipElement_abortController, _ToolTipElement_align, _ToolTipElement_side, _ToolTipElement_allowUpdatePosition, _ToolTipElement_update, _ToolTipElement_updatePosition;
12
+ var _ToolTipElement_instances, _ToolTipElement_abortController, _ToolTipElement_align, _ToolTipElement_side, _ToolTipElement_allowUpdatePosition, _ToolTipElement_update, _ToolTipElement_updateControlReference, _ToolTipElement_updateDirection, _ToolTipElement_updatePosition;
13
13
  import { getAnchoredPosition } from '@primer/behaviors';
14
14
  const TOOLTIP_OPEN_CLASS = 'tooltip-open';
15
15
  const TOOLTIP_ARROW_EDGE_OFFSET = 6;
@@ -187,6 +187,8 @@ class ToolTipElement extends HTMLElement {
187
187
  }
188
188
  connectedCallback() {
189
189
  var _a;
190
+ __classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updateControlReference).call(this);
191
+ __classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updateDirection).call(this);
190
192
  if (!this.shadowRoot) {
191
193
  const shadow = this.attachShadow({ mode: 'open' });
192
194
  // eslint-disable-next-line github/no-inner-html
@@ -241,77 +243,13 @@ class ToolTipElement extends HTMLElement {
241
243
  }
242
244
  }
243
245
  attributeChangedCallback(name) {
246
+ if (!this.isConnected)
247
+ return;
244
248
  if (name === 'id' || name === 'data-type') {
245
- if (!this.id || !this.control)
246
- return;
247
- if (this.type === 'label') {
248
- let labelledBy = this.control.getAttribute('aria-labelledby');
249
- if (labelledBy) {
250
- if (!labelledBy.split(' ').includes(this.id)) {
251
- labelledBy = `${labelledBy} ${this.id}`;
252
- }
253
- else {
254
- labelledBy = `${labelledBy}`;
255
- }
256
- }
257
- else {
258
- labelledBy = this.id;
259
- }
260
- this.control.setAttribute('aria-labelledby', labelledBy);
261
- // Prevent duplicate accessible name announcements.
262
- this.setAttribute('aria-hidden', 'true');
263
- }
264
- else {
265
- let describedBy = this.control.getAttribute('aria-describedby');
266
- if (describedBy) {
267
- if (!describedBy.split(' ').includes(this.id)) {
268
- describedBy = `${describedBy} ${this.id}`;
269
- }
270
- else {
271
- describedBy = `${describedBy}`;
272
- }
273
- }
274
- else {
275
- describedBy = this.id;
276
- }
277
- this.control.setAttribute('aria-describedby', describedBy);
278
- }
249
+ __classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updateControlReference).call(this);
279
250
  }
280
251
  else if (name === 'data-direction') {
281
- this.classList.remove(...DIRECTION_CLASSES);
282
- const direction = this.direction;
283
- if (direction === 'n') {
284
- __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
285
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
286
- }
287
- else if (direction === 'ne') {
288
- __classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
289
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
290
- }
291
- else if (direction === 'e') {
292
- __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
293
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-right', "f");
294
- }
295
- else if (direction === 'se') {
296
- __classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
297
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
298
- }
299
- else if (direction === 's') {
300
- __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
301
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
302
- }
303
- else if (direction === 'sw') {
304
- __classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
305
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
306
- }
307
- else if (direction === 'w') {
308
- __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
309
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-left', "f");
310
- }
311
- else if (direction === 'nw') {
312
- __classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
313
- __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
314
- }
252
+ __classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updateDirection).call(this);
315
253
  }
316
254
  }
317
255
  }
@@ -327,6 +265,76 @@ _ToolTipElement_abortController = new WeakMap(), _ToolTipElement_align = new Wea
327
265
  }
328
266
  __classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updatePosition).call(this);
329
267
  }
268
+ }, _ToolTipElement_updateControlReference = function _ToolTipElement_updateControlReference() {
269
+ if (!this.id || !this.control)
270
+ return;
271
+ if (this.type === 'label') {
272
+ let labelledBy = this.control.getAttribute('aria-labelledby');
273
+ if (labelledBy) {
274
+ if (!labelledBy.split(' ').includes(this.id)) {
275
+ labelledBy = `${labelledBy} ${this.id}`;
276
+ }
277
+ else {
278
+ labelledBy = `${labelledBy}`;
279
+ }
280
+ }
281
+ else {
282
+ labelledBy = this.id;
283
+ }
284
+ this.control.setAttribute('aria-labelledby', labelledBy);
285
+ // Prevent duplicate accessible name announcements.
286
+ this.setAttribute('aria-hidden', 'true');
287
+ }
288
+ else {
289
+ let describedBy = this.control.getAttribute('aria-describedby');
290
+ if (describedBy) {
291
+ if (!describedBy.split(' ').includes(this.id)) {
292
+ describedBy = `${describedBy} ${this.id}`;
293
+ }
294
+ else {
295
+ describedBy = `${describedBy}`;
296
+ }
297
+ }
298
+ else {
299
+ describedBy = this.id;
300
+ }
301
+ this.control.setAttribute('aria-describedby', describedBy);
302
+ }
303
+ }, _ToolTipElement_updateDirection = function _ToolTipElement_updateDirection() {
304
+ this.classList.remove(...DIRECTION_CLASSES);
305
+ const direction = this.direction;
306
+ if (direction === 'n') {
307
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
308
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
309
+ }
310
+ else if (direction === 'ne') {
311
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
312
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
313
+ }
314
+ else if (direction === 'e') {
315
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
316
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-right', "f");
317
+ }
318
+ else if (direction === 'se') {
319
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
320
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
321
+ }
322
+ else if (direction === 's') {
323
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
324
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
325
+ }
326
+ else if (direction === 'sw') {
327
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
328
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
329
+ }
330
+ else if (direction === 'w') {
331
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
332
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-left', "f");
333
+ }
334
+ else if (direction === 'nw') {
335
+ __classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
336
+ __classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
337
+ }
330
338
  }, _ToolTipElement_updatePosition = function _ToolTipElement_updatePosition() {
331
339
  if (!this.control)
332
340
  return;
@@ -186,6 +186,8 @@ class ToolTipElement extends HTMLElement {
186
186
  }
187
187
 
188
188
  connectedCallback() {
189
+ this.#updateControlReference()
190
+ this.#updateDirection()
189
191
  if (!this.shadowRoot) {
190
192
  const shadow = this.attachShadow({mode: 'open'})
191
193
  // eslint-disable-next-line github/no-inner-html
@@ -259,64 +261,74 @@ class ToolTipElement extends HTMLElement {
259
261
  }
260
262
 
261
263
  attributeChangedCallback(name: string) {
264
+ if (!this.isConnected) return
265
+
262
266
  if (name === 'id' || name === 'data-type') {
263
- if (!this.id || !this.control) return
264
- if (this.type === 'label') {
265
- let labelledBy = this.control.getAttribute('aria-labelledby')
266
- if (labelledBy) {
267
- if (!labelledBy.split(' ').includes(this.id)) {
268
- labelledBy = `${labelledBy} ${this.id}`
269
- } else {
270
- labelledBy = `${labelledBy}`
271
- }
267
+ this.#updateControlReference()
268
+ } else if (name === 'data-direction') {
269
+ this.#updateDirection()
270
+ }
271
+ }
272
+
273
+ #updateControlReference() {
274
+ if (!this.id || !this.control) return
275
+ if (this.type === 'label') {
276
+ let labelledBy = this.control.getAttribute('aria-labelledby')
277
+ if (labelledBy) {
278
+ if (!labelledBy.split(' ').includes(this.id)) {
279
+ labelledBy = `${labelledBy} ${this.id}`
272
280
  } else {
273
- labelledBy = this.id
281
+ labelledBy = `${labelledBy}`
274
282
  }
275
- this.control.setAttribute('aria-labelledby', labelledBy)
276
-
277
- // Prevent duplicate accessible name announcements.
278
- this.setAttribute('aria-hidden', 'true')
279
283
  } else {
280
- let describedBy = this.control.getAttribute('aria-describedby')
281
- if (describedBy) {
282
- if (!describedBy.split(' ').includes(this.id)) {
283
- describedBy = `${describedBy} ${this.id}`
284
- } else {
285
- describedBy = `${describedBy}`
286
- }
284
+ labelledBy = this.id
285
+ }
286
+ this.control.setAttribute('aria-labelledby', labelledBy)
287
+
288
+ // Prevent duplicate accessible name announcements.
289
+ this.setAttribute('aria-hidden', 'true')
290
+ } else {
291
+ let describedBy = this.control.getAttribute('aria-describedby')
292
+ if (describedBy) {
293
+ if (!describedBy.split(' ').includes(this.id)) {
294
+ describedBy = `${describedBy} ${this.id}`
287
295
  } else {
288
- describedBy = this.id
296
+ describedBy = `${describedBy}`
289
297
  }
290
- this.control.setAttribute('aria-describedby', describedBy)
291
- }
292
- } else if (name === 'data-direction') {
293
- this.classList.remove(...DIRECTION_CLASSES)
294
- const direction = this.direction
295
- if (direction === 'n') {
296
- this.#align = 'center'
297
- this.#side = 'outside-top'
298
- } else if (direction === 'ne') {
299
- this.#align = 'start'
300
- this.#side = 'outside-top'
301
- } else if (direction === 'e') {
302
- this.#align = 'center'
303
- this.#side = 'outside-right'
304
- } else if (direction === 'se') {
305
- this.#align = 'start'
306
- this.#side = 'outside-bottom'
307
- } else if (direction === 's') {
308
- this.#align = 'center'
309
- this.#side = 'outside-bottom'
310
- } else if (direction === 'sw') {
311
- this.#align = 'end'
312
- this.#side = 'outside-bottom'
313
- } else if (direction === 'w') {
314
- this.#align = 'center'
315
- this.#side = 'outside-left'
316
- } else if (direction === 'nw') {
317
- this.#align = 'end'
318
- this.#side = 'outside-top'
298
+ } else {
299
+ describedBy = this.id
319
300
  }
301
+ this.control.setAttribute('aria-describedby', describedBy)
302
+ }
303
+ }
304
+
305
+ #updateDirection() {
306
+ this.classList.remove(...DIRECTION_CLASSES)
307
+ const direction = this.direction
308
+ if (direction === 'n') {
309
+ this.#align = 'center'
310
+ this.#side = 'outside-top'
311
+ } else if (direction === 'ne') {
312
+ this.#align = 'start'
313
+ this.#side = 'outside-top'
314
+ } else if (direction === 'e') {
315
+ this.#align = 'center'
316
+ this.#side = 'outside-right'
317
+ } else if (direction === 'se') {
318
+ this.#align = 'start'
319
+ this.#side = 'outside-bottom'
320
+ } else if (direction === 's') {
321
+ this.#align = 'center'
322
+ this.#side = 'outside-bottom'
323
+ } else if (direction === 'sw') {
324
+ this.#align = 'end'
325
+ this.#side = 'outside-bottom'
326
+ } else if (direction === 'w') {
327
+ this.#align = 'center'
328
+ this.#side = 'outside-left'
329
+ } else if (direction === 'nw') {
330
+ this.#align = 'end'
331
+ this.#side = 'outside-top'
320
332
  }
321
333
  }
322
334
 
@@ -23,6 +23,8 @@ module Primer
23
23
  # - When there is no visible text on the trigger element and the tooltip content is appropriate as a label for the element, set `type: :label`.
24
24
  # `label` type is usually only appropriate for an icon-only control.
25
25
  class Tooltip < Primer::Component
26
+ warn_on_deprecated_slot_setter
27
+
26
28
  DIRECTION_DEFAULT = :s
27
29
  DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :n, :e, :w, :ne, :nw, :se, :sw].freeze
28
30
 
@@ -12,9 +12,9 @@ module Primer
12
12
 
13
13
  # The leading visual rendered before the link.
14
14
  #
15
- # @param kwargs [Hash] The arguments accepted by <%= link_to_component(Primer::Beta::Avatar) %> or <%= link_to_component(Primer::OcticonComponent) %>
15
+ # @param kwargs [Hash] The arguments accepted by <%= link_to_component(Primer::Beta::Avatar) %> or <%= link_to_component(Primer::Beta::Octicon) %>
16
16
  renders_one :leading_visual, types: {
17
- icon: Primer::OcticonComponent,
17
+ icon: Primer::Beta::Octicon,
18
18
  avatar: lambda { |**kwargs|
19
19
  Primer::Beta::Avatar.new(**{ **kwargs, size: 16 })
20
20
  }
@@ -22,9 +22,9 @@ module Primer
22
22
 
23
23
  # The trailing visual rendered after the link.
24
24
  #
25
- # @param kwargs [Hash] The arguments accepted by <%= link_to_component(Primer::OcticonComponent) %>, <%= link_to_component(Primer::Beta::Label) %>, or <%= link_to_component(Primer::Beta::Counter) %>
25
+ # @param kwargs [Hash] The arguments accepted by <%= link_to_component(Primer::Beta::Octicon) %>, <%= link_to_component(Primer::Beta::Label) %>, or <%= link_to_component(Primer::Beta::Counter) %>
26
26
  renders_one :trailing_visual, types: {
27
- icon: Primer::OcticonComponent,
27
+ icon: Primer::Beta::Octicon,
28
28
  label: Primer::Beta::Label,
29
29
  counter: Primer::Beta::Counter
30
30
  }
@@ -39,13 +39,13 @@ module Primer
39
39
 
40
40
  # Leading visual.
41
41
  #
42
- # - `leading_visual_icon` for a <%= link_to_component(Primer::OcticonComponent) %>.
42
+ # - `leading_visual_icon` for a <%= link_to_component(Primer::Beta::Octicon) %>.
43
43
  #
44
- # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
44
+ # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
45
45
  renders_one :leading_visual, types: {
46
46
  icon: lambda { |**system_arguments|
47
47
  system_arguments[:classes] = class_names("FormControl-input-leadingVisual")
48
- Primer::OcticonComponent.new(**system_arguments)
48
+ Primer::Beta::Octicon.new(**system_arguments)
49
49
  }
50
50
  }
51
51
 
@@ -17,6 +17,7 @@ module Primer
17
17
  # rather than `@kittenuser`.
18
18
  # [Learn more about best image practices (WAI Images)](https://www.w3.org/WAI/tutorials/images/)
19
19
  class Avatar < Primer::Component
20
+ warn_on_deprecated_slot_setter
20
21
  status :beta
21
22
 
22
23
  DEFAULT_SIZE = 20
@@ -4,6 +4,7 @@ module Primer
4
4
  module Beta
5
5
  # Use `BaseButton` to render an unstyled `<button>` tag that can be customized.
6
6
  class BaseButton < Primer::Component
7
+ warn_on_deprecated_slot_setter
7
8
  status :beta
8
9
 
9
10
  DEFAULT_TAG = :button
@@ -19,9 +19,9 @@ module Primer
19
19
  #
20
20
  # Use:
21
21
  #
22
- # - `visual_icon` for an <%= link_to_component(Primer::OcticonComponent) %>.
22
+ # - `visual_icon` for an <%= link_to_component(Primer::Beta::Octicon) %>.
23
23
  # - `visual_image` for an <%= link_to_component(Primer::Alpha::Image) %>.
24
- # - `visual_spinner` for a <%= link_to_component(Primer::SpinnerComponent) %>.
24
+ # - `visual_spinner` for a <%= link_to_component(Primer::Beta::Spinner) %>.
25
25
  #
26
26
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
27
27
  renders_one :visual, types: {
@@ -29,12 +29,12 @@ module Primer
29
29
  system_arguments[:size] ||= :medium
30
30
  system_arguments[:classes] = class_names("blankslate-icon", system_arguments[:classes])
31
31
 
32
- Primer::OcticonComponent.new(**system_arguments)
32
+ Primer::Beta::Octicon.new(**system_arguments)
33
33
  },
34
34
  spinner: lambda { |**system_arguments|
35
35
  system_arguments[:classes] = class_names("blankslate-image", system_arguments[:classes])
36
36
 
37
- Primer::SpinnerComponent.new(**system_arguments)
37
+ Primer::Beta::Spinner.new(**system_arguments)
38
38
  },
39
39
  image: lambda { |**system_arguments|
40
40
  system_arguments[:size] = "56x56"
@@ -83,7 +83,7 @@ module Primer
83
83
  system_arguments[:size] = :medium
84
84
  system_arguments[:scheme] ||= :primary
85
85
 
86
- Primer::ButtonComponent.new(**system_arguments)
86
+ Primer::Beta::Button.new(**system_arguments)
87
87
  }
88
88
 
89
89
  # Optional secondary action
@@ -39,12 +39,12 @@ module Primer
39
39
  #
40
40
  # Use:
41
41
  #
42
- # - `leading_visual_icon` for a <%= link_to_component(Primer::OcticonComponent) %>.
42
+ # - `leading_visual_icon` for a <%= link_to_component(Primer::Beta::Octicon) %>.
43
43
  #
44
- # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
44
+ # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
45
45
  renders_one :leading_visual, types: {
46
46
  icon: lambda { |**system_arguments|
47
- Primer::OcticonComponent.new(**system_arguments)
47
+ Primer::Beta::Octicon.new(**system_arguments)
48
48
  }
49
49
  }
50
50
 
@@ -56,7 +56,7 @@ module Primer
56
56
  #
57
57
  # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Counter) %>.
58
58
  renders_one :trailing_visual, types: {
59
- icon: Primer::OcticonComponent,
59
+ icon: Primer::Beta::Octicon,
60
60
  label: Primer::Beta::Label,
61
61
  counter: Primer::Beta::Counter
62
62
  }
@@ -65,11 +65,11 @@ module Primer
65
65
  #
66
66
  # Use:
67
67
  #
68
- # - `trailing_action_icon` for a <%= link_to_component(Primer::OcticonComponent) %>.
68
+ # - `trailing_action_icon` for a <%= link_to_component(Primer::Beta::Octicon) %>.
69
69
  #
70
- # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
70
+ # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
71
71
  renders_one :trailing_action, types: {
72
- icon: Primer::OcticonComponent
72
+ icon: Primer::Beta::Octicon
73
73
  }
74
74
 
75
75
  # `Tooltip` that appears on mouse hover or keyboard focus over the button. Use tooltips sparingly and as a last resort.
@@ -2,7 +2,7 @@
2
2
  <% if content.present? %>
3
3
  <%= content %>
4
4
  <% else %>
5
- <%= render Primer::OcticonComponent.new(:copy) %>
6
- <%= render Primer::OcticonComponent.new(:check, color: :success, style: "display: none;") %>
5
+ <%= render Primer::Beta::Octicon.new(:copy) %>
6
+ <%= render Primer::Beta::Octicon.new(:check, color: :success, style: "display: none;") %>
7
7
  <% end %>
8
8
  <% end %>
@@ -7,6 +7,7 @@ module Primer
7
7
  # @accessibility
8
8
  # Always set an accessible label to help the user interact with the component.
9
9
  class ClipboardCopy < Primer::Component
10
+ warn_on_deprecated_slot_setter
10
11
  status :beta
11
12
 
12
13
  # @example Default
@@ -9,6 +9,7 @@ module Primer
9
9
  # You may choose to override this label with something more descriptive via [system_arguments][0].
10
10
  # [0]: https://primer.style/view-components/system-arguments#html-attributes
11
11
  class CloseButton < Primer::Component
12
+ warn_on_deprecated_slot_setter
12
13
  status :beta
13
14
 
14
15
  DEFAULT_TYPE = :button
@@ -33,7 +34,7 @@ module Primer
33
34
 
34
35
  def call
35
36
  render(Primer::Beta::BaseButton.new(**@system_arguments)) do
36
- render(Primer::OcticonComponent.new("x"))
37
+ render(Primer::Beta::Octicon.new("x"))
37
38
  end
38
39
  end
39
40
  end
@@ -9,6 +9,7 @@ module Primer
9
9
  # should be accompanied with text such as `issues` or `pull requests`.
10
10
  #
11
11
  class Counter < Primer::Component
12
+ warn_on_deprecated_slot_setter
12
13
  status :beta
13
14
 
14
15
  DEFAULT_SCHEME = :default
@@ -18,6 +18,7 @@ module Primer
18
18
  # Headings allow assistive technology users to quickly navigate around a page. Navigation to text that is not meant to be a heading can be a confusing experience.
19
19
  # <%= link_to_heading_practices %>
20
20
  class Heading < Primer::Component
21
+ warn_on_deprecated_slot_setter
21
22
  status :beta
22
23
 
23
24
  TAG_FALLBACK = :h2
@@ -1,6 +1,6 @@
1
1
  <%= render Primer::ConditionalWrapper.new(condition: render_tooltip?, tag: :div, classes: "Button-withTooltip", **@wrapper_arguments) do %>
2
2
  <%= render Primer::Beta::BaseButton.new(**@system_arguments) do -%>
3
- <%= render Primer::OcticonComponent.new(icon: @icon, classes: "Button-visual") %>
3
+ <%= render Primer::Beta::Octicon.new(icon: @icon, classes: "Button-visual") %>
4
4
  <% end -%>
5
5
  <%= render Primer::Alpha::Tooltip.new(**@tooltip_arguments) if render_tooltip? %>
6
6
  <% end %>
@@ -15,6 +15,7 @@ module Primer
15
15
  # Either `aria-label` or `aria-description` will be used for the `Tooltip` text, depending on which one is present.
16
16
  # [Learn more about best functional image practices (WAI Images)](https://www.w3.org/WAI/tutorials/images/functional)
17
17
  class IconButton < Primer::Component
18
+ warn_on_deprecated_slot_setter
18
19
  status :beta
19
20
 
20
21
  DEFAULT_SCHEME = :default
@@ -7,6 +7,7 @@ module Primer
7
7
  # @accessibility
8
8
  # Use `aria-label` if the `Label` or the context around it don't explain the label.
9
9
  class Label < Primer::Component
10
+ warn_on_deprecated_slot_setter
10
11
  status :beta
11
12
 
12
13
  DEFAULT_TAG = :span
@@ -4,6 +4,7 @@ module Primer
4
4
  module Beta
5
5
  # Use `Markdown` to wrap markdown content.
6
6
  class Markdown < Primer::Component
7
+ warn_on_deprecated_slot_setter
7
8
  status :beta
8
9
 
9
10
  DEFAULT_TAG = :div