primer_view_components 0.0.89 → 0.0.90

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -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/components/primer/alpha/auto_complete.rb +2 -2
  6. data/app/components/primer/alpha/layout.rb +34 -32
  7. data/app/components/primer/alpha/tab_nav.rb +20 -20
  8. data/app/components/primer/alpha/tab_panels.rb +2 -2
  9. data/app/components/primer/alpha/tool-tip-element.d.ts +1 -3
  10. data/app/components/primer/alpha/tool-tip-element.js +13 -19
  11. data/app/components/primer/alpha/tool-tip-element.ts +14 -22
  12. data/app/components/primer/alpha/tooltip.rb +1 -1
  13. data/app/components/primer/alpha/underline_nav.rb +16 -16
  14. data/app/components/primer/alpha/underline_panels.rb +3 -3
  15. data/app/components/primer/beta/auto_complete/item.rb +2 -2
  16. data/app/components/primer/beta/auto_complete.rb +2 -2
  17. data/app/components/primer/beta/avatar_stack.rb +9 -9
  18. data/app/components/primer/beta/border_box/header.rb +4 -2
  19. data/app/components/primer/beta/border_box.rb +13 -13
  20. data/app/components/primer/beta/breadcrumbs.rb +3 -3
  21. data/app/components/primer/beta/button_group.rb +9 -9
  22. data/app/components/primer/beta/close_button.rb +41 -0
  23. data/app/components/primer/beta/counter.rb +113 -0
  24. data/app/components/primer/beta/flash.rb +1 -1
  25. data/app/components/primer/beta/truncate.rb +17 -17
  26. data/app/components/primer/blankslate_component.rb +1 -1
  27. data/app/components/primer/button_component.rb +8 -8
  28. data/app/components/primer/close_button.rb +2 -34
  29. data/app/components/primer/counter_component.rb +2 -106
  30. data/app/components/primer/details_component.rb +2 -2
  31. data/app/components/primer/dropdown.rb +14 -14
  32. data/app/components/primer/image_crop.rb +1 -1
  33. data/app/components/primer/layout_component.rb +4 -4
  34. data/app/components/primer/link_component.rb +1 -1
  35. data/app/components/primer/menu_component.rb +5 -5
  36. data/app/components/primer/navigation/tab_component.rb +12 -12
  37. data/app/components/primer/popover_component.rb +8 -8
  38. data/app/components/primer/subhead_component.rb +10 -10
  39. data/app/components/primer/timeline_item_component.rb +3 -3
  40. data/app/lib/primer/join_style_arguments_helper.rb +1 -1
  41. data/lib/primer/view_components/linters/argument_mappers/close_button.rb +2 -2
  42. data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +2 -2
  43. data/lib/primer/view_components/linters/helpers/deprecated_components_helpers.rb +2 -0
  44. data/lib/primer/view_components/version.rb +1 -1
  45. data/lib/rubocop/cop/primer/component_name_migration.rb +2 -0
  46. data/lib/tasks/docs.rake +2 -2
  47. data/static/arguments.yml +44 -44
  48. data/static/audited_at.json +2 -0
  49. data/static/constants.json +26 -22
  50. data/static/statuses.json +5 -3
  51. metadata +4 -2
@@ -94,12 +94,12 @@ module Primer
94
94
  #
95
95
  # @example With custom classes for the input
96
96
  # <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-input", list_id: "fruits-popup--custom-input")) do |c| %>
97
- # <% c.input(classes: "custom-class") %>
97
+ # <% c.with_input(classes: "custom-class") %>
98
98
  # <% end %>
99
99
  #
100
100
  # @example With custom classes for the results
101
101
  # <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-results", list_id: "fruits-popup--custom-results")) do |c| %>
102
- # <% c.results(classes: "custom-class") do %>
102
+ # <% c.with_results(classes: "custom-class") do %>
103
103
  # <%= render(Primer::Alpha::AutoComplete::Item.new(selected: true, value: "apple")) do |c| %>
104
104
  # Apple
105
105
  # <% end %>
@@ -14,6 +14,8 @@ module Primer
14
14
  # Keyboard navigation follows the markup order. Decide carefully how the focus order should be be by deciding whether
15
15
  # `main` or `sidebar` comes first in code. The code order won’t affect the visual position.
16
16
  class Layout < Primer::Component
17
+ status :alpha
18
+
17
19
  FIRST_IN_SOURCE_DEFAULT = :sidebar
18
20
  FIRST_IN_SOURCE_OPTIONS = [FIRST_IN_SOURCE_DEFAULT, :main].freeze
19
21
 
@@ -80,8 +82,8 @@ module Primer
80
82
  # @example Default
81
83
  #
82
84
  # <%= render(Primer::Alpha::Layout.new) do |c| %>
83
- # <% c.main(border: true) { "Main" } %>
84
- # <% c.sidebar(border: true) { "Sidebar" } %>
85
+ # <% c.with_main(border: true) { "Main" } %>
86
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
85
87
  # <% end %>
86
88
  #
87
89
  # @example Main widths
@@ -96,20 +98,20 @@ module Primer
96
98
  #
97
99
  # @code
98
100
  # <%= render(Primer::Alpha::Layout.new) do |c| %>
99
- # <% c.main(width: :full, border: true) { "Main" } %>
100
- # <% c.sidebar(border: true) { "Sidebar" } %>
101
+ # <% c.with_main(width: :full, border: true) { "Main" } %>
102
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
101
103
  # <% end %>
102
104
  # <%= render(Primer::Alpha::Layout.new(mt: 5)) do |c| %>
103
- # <% c.main(width: :md, border: true) { "Main" } %>
104
- # <% c.sidebar(border: true) { "Sidebar" } %>
105
+ # <% c.with_main(width: :md, border: true) { "Main" } %>
106
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
105
107
  # <% end %>
106
108
  # <%= render(Primer::Alpha::Layout.new(mt: 5)) do |c| %>
107
- # <% c.main(width: :lg, border: true) { "Main" } %>
108
- # <% c.sidebar(border: true) { "Sidebar" } %>
109
+ # <% c.with_main(width: :lg, border: true) { "Main" } %>
110
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
109
111
  # <% end %>
110
112
  # <%= render(Primer::Alpha::Layout.new(mt: 5)) do |c| %>
111
- # <% c.main(width: :xl, border: true) { "Main" } %>
112
- # <% c.sidebar(border: true) { "Sidebar" } %>
113
+ # <% c.with_main(width: :xl, border: true) { "Main" } %>
114
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
113
115
  # <% end %>
114
116
  #
115
117
  # @example Sidebar widths
@@ -125,16 +127,16 @@ module Primer
125
127
  #
126
128
  # @code
127
129
  # <%= render(Primer::Alpha::Layout.new) do |c| %>
128
- # <% c.main(border: true) { "Main" } %>
129
- # <% c.sidebar(width: :default, border: true) { "Sidebar" } %>
130
+ # <% c.with_main(border: true) { "Main" } %>
131
+ # <% c.with_sidebar(width: :default, border: true) { "Sidebar" } %>
130
132
  # <% end %>
131
133
  # <%= render(Primer::Alpha::Layout.new(mt: 5)) do |c| %>
132
- # <% c.main(border: true) { "Main" } %>
133
- # <% c.sidebar(width: :narrow, border: true) { "Sidebar" } %>
134
+ # <% c.with_main(border: true) { "Main" } %>
135
+ # <% c.with_sidebar(width: :narrow, border: true) { "Sidebar" } %>
134
136
  # <% end %>
135
137
  # <%= render(Primer::Alpha::Layout.new(mt: 5)) do |c| %>
136
- # <% c.main(border: true) { "Main" } %>
137
- # <% c.sidebar(width: :wide, border: true) { "Sidebar" } %>
138
+ # <% c.with_main(border: true) { "Main" } %>
139
+ # <% c.with_sidebar(width: :wide, border: true) { "Sidebar" } %>
138
140
  # <% end %>
139
141
  #
140
142
  # @example Sidebar placement
@@ -144,12 +146,12 @@ module Primer
144
146
  #
145
147
  # @code
146
148
  # <%= render(Primer::Alpha::Layout.new) do |c| %>
147
- # <% c.main(border: true) { "Main" } %>
148
- # <% c.sidebar(col_placement: :start, border: true) { "Sidebar" } %>
149
+ # <% c.with_main(border: true) { "Main" } %>
150
+ # <% c.with_sidebar(col_placement: :start, border: true) { "Sidebar" } %>
149
151
  # <% end %>
150
152
  # <%= render(Primer::Alpha::Layout.new( mt: 5)) do |c| %>
151
- # <% c.main(border: true) { "Main" } %>
152
- # <% c.sidebar(col_placement: :end, border: true) { "Sidebar" } %>
153
+ # <% c.with_main(border: true) { "Main" } %>
154
+ # <% c.with_sidebar(col_placement: :end, border: true) { "Sidebar" } %>
153
155
  # <% end %>
154
156
  #
155
157
  # @example Sidebar placement as row
@@ -163,16 +165,16 @@ module Primer
163
165
  #
164
166
  # @code
165
167
  # <%= render(Primer::Alpha::Layout.new) do |c| %>
166
- # <% c.main(border: true) { "Main" } %>
167
- # <% c.sidebar(row_placement: :start, border: true) { "Sidebar" } %>
168
+ # <% c.with_main(border: true) { "Main" } %>
169
+ # <% c.with_sidebar(row_placement: :start, border: true) { "Sidebar" } %>
168
170
  # <% end %>
169
171
  # <%= render(Primer::Alpha::Layout.new(mt: 5)) do |c| %>
170
- # <% c.main(border: true) { "Main" } %>
171
- # <% c.sidebar(row_placement: :end, border: true) { "Sidebar" } %>
172
+ # <% c.with_main(border: true) { "Main" } %>
173
+ # <% c.with_sidebar(row_placement: :end, border: true) { "Sidebar" } %>
172
174
  # <% end %>
173
175
  # <%= render(Primer::Alpha::Layout.new(mt: 5)) do |c| %>
174
- # <% c.main(border: true) { "Main" } %>
175
- # <% c.sidebar(row_placement: :none, border: true) { "Sidebar" } %>
176
+ # <% c.with_main(border: true) { "Main" } %>
177
+ # <% c.with_sidebar(row_placement: :none, border: true) { "Sidebar" } %>
176
178
  # <% end %>
177
179
  #
178
180
  # @example Changing when to render `Layout` as columns
@@ -183,16 +185,16 @@ module Primer
183
185
  #
184
186
  # @code
185
187
  # <%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :sm)) do |c| %>
186
- # <% c.main(border: true) { "Main" } %>
187
- # <% c.sidebar(border: true) { "Sidebar" } %>
188
+ # <% c.with_main(border: true) { "Main" } %>
189
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
188
190
  # <% end %>
189
191
  # <%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :md, mt: 5)) do |c| %>
190
- # <% c.main(border: true) { "Main" } %>
191
- # <% c.sidebar(border: true) { "Sidebar" } %>
192
+ # <% c.with_main(border: true) { "Main" } %>
193
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
192
194
  # <% end %>
193
195
  # <%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg, mt: 5)) do |c| %>
194
- # <% c.main(border: true) { "Main" } %>
195
- # <% c.sidebar(border: true) { "Sidebar" } %>
196
+ # <% c.with_main(border: true) { "Main" } %>
197
+ # <% c.with_sidebar(border: true) { "Sidebar" } %>
196
198
  # <% end %>
197
199
  #
198
200
  # @param stacking_breakpoint [Symbol] When the `Layout` should change from rows into columns. <%= one_of(Primer::Alpha::Layout::STACKING_BREAKPOINT_OPTIONS) %>
@@ -49,30 +49,30 @@ module Primer
49
49
  # `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
50
50
  # @code
51
51
  # <%= render(Primer::Alpha::TabNav.new(label: "Default")) do |c| %>
52
- # <% c.tab(selected: true, href: "#") { "Tab 1" } %>
53
- # <% c.tab(href: "#") { "Tab 2" } %>
54
- # <% c.tab(href: "#") { "Tab 3" } %>
52
+ # <% c.with_tab(selected: true, href: "#") { "Tab 1" } %>
53
+ # <% c.with_tab(href: "#") { "Tab 2" } %>
54
+ # <% c.with_tab(href: "#") { "Tab 3" } %>
55
55
  # <% end %>
56
56
  #
57
57
  # @example Default with `<div>`
58
58
  # <%= render(Primer::Alpha::TabNav.new(label: "Default")) do |c| %>
59
- # <% c.tab(selected: true, href: "#") { "Tab 1" } %>
60
- # <% c.tab(href: "#") { "Tab 2" } %>
61
- # <% c.tab(href: "#") { "Tab 3" } %>
59
+ # <% c.with_tab(selected: true, href: "#") { "Tab 1" } %>
60
+ # <% c.with_tab(href: "#") { "Tab 2" } %>
61
+ # <% c.with_tab(href: "#") { "Tab 3" } %>
62
62
  # <% end %>
63
63
  #
64
64
  # @example With icons and counters
65
65
  # <%= render(Primer::Alpha::TabNav.new(label: "With icons and counters")) do |component| %>
66
- # <% component.tab(href: "#", selected: true) do |t| %>
66
+ # <% component.with_tab(href: "#", selected: true) do |t| %>
67
67
  # <% t.icon(icon: :star) %>
68
68
  # <% t.text { "Item 1" } %>
69
69
  # <% end %>
70
- # <% component.tab(href: "#") do |t| %>
70
+ # <% component.with_tab(href: "#") do |t| %>
71
71
  # <% t.icon(icon: :star) %>
72
72
  # <% t.text { "Item 2" } %>
73
73
  # <% t.counter(count: 10) %>
74
74
  # <% end %>
75
- # <% component.tab(href: "#") do |t| %>
75
+ # <% component.with_tab(href: "#") do |t| %>
76
76
  # <% t.text { "Item 3" } %>
77
77
  # <% t.counter(count: 10) %>
78
78
  # <% end %>
@@ -80,20 +80,20 @@ module Primer
80
80
  #
81
81
  # @example With extra content
82
82
  # <%= render(Primer::Alpha::TabNav.new(label: "With extra content")) do |c| %>
83
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
84
- # <% c.tab(href: "#") { "Tab 2" } %>
85
- # <% c.tab(href: "#") { "Tab 3" } %>
86
- # <% c.extra do %>
83
+ # <% c.with_tab(selected: true, href: "#") { "Tab 1" }%>
84
+ # <% c.with_tab(href: "#") { "Tab 2" } %>
85
+ # <% c.with_tab(href: "#") { "Tab 3" } %>
86
+ # <% c.with_extra do %>
87
87
  # <%= render(Primer::ButtonComponent.new(float: :right)) { "Button" } %>
88
88
  # <% end %>
89
89
  # <% end %>
90
90
  #
91
91
  # @example Adding extra content after the tabs
92
92
  # <%= render(Primer::Alpha::TabNav.new(label: "Adding extra content after the tabs", display: :flex, body_arguments: { flex: 1 })) do |c| %>
93
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
94
- # <% c.tab(href: "#") { "Tab 2" } %>
95
- # <% c.tab(href: "#") { "Tab 3" } %>
96
- # <% c.extra(align: :right) do %>
93
+ # <% c.with_tab(selected: true, href: "#") { "Tab 1" }%>
94
+ # <% c.with_tab(href: "#") { "Tab 2" } %>
95
+ # <% c.with_tab(href: "#") { "Tab 3" } %>
96
+ # <% c.with_extra(align: :right) do %>
97
97
  # <div>
98
98
  # <%= render(Primer::ButtonComponent.new) { "Button" } %>
99
99
  # </div>
@@ -102,9 +102,9 @@ module Primer
102
102
  #
103
103
  # @example Customizing the body
104
104
  # <%= render(Primer::Alpha::TabNav.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :accent_emphasis })) do |c| %>
105
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
106
- # <% c.tab(href: "#") { "Tab 2" } %>
107
- # <% c.tab(href: "#") { "Tab 3" } %>
105
+ # <% c.with_tab(selected: true, href: "#") { "Tab 1" }%>
106
+ # <% c.with_tab(href: "#") { "Tab 2" } %>
107
+ # <% c.with_tab(href: "#") { "Tab 3" } %>
108
108
  # <% end %>
109
109
  #
110
110
  # @param tag [Symbol] <%= one_of(Primer::Alpha::TabNav::TAG_OPTIONS) %>
@@ -43,13 +43,13 @@ module Primer
43
43
 
44
44
  # @example Default
45
45
  # <%= render(Primer::Alpha::TabPanels.new(label: "With panels")) do |component| %>
46
- # <% component.tab(id: "tab-1", selected: true) do |t| %>
46
+ # <% component.with_tab(id: "tab-1", selected: true) do |t| %>
47
47
  # <% t.text { "Tab 1" } %>
48
48
  # <% t.panel do %>
49
49
  # Panel 1
50
50
  # <% end %>
51
51
  # <% end %>
52
- # <% component.tab(id: "tab-2") do |t| %>
52
+ # <% component.with_tab(id: "tab-2") do |t| %>
53
53
  # <% t.text { "Tab 2" } %>
54
54
  # <% t.panel do %>
55
55
  # Panel 2
@@ -9,13 +9,11 @@ declare class ToolTipElement extends HTMLElement {
9
9
  get direction(): Direction;
10
10
  set direction(value: Direction);
11
11
  get control(): HTMLElement | null;
12
- set visibilityHidden(value: true | false);
13
- get visibilityHidden(): true | false;
14
12
  connectedCallback(): void;
15
13
  disconnectedCallback(): void;
16
14
  handleEvent(event: Event): void;
17
15
  static observedAttributes: string[];
18
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
16
+ attributeChangedCallback(name: string): void;
19
17
  }
20
18
  declare global {
21
19
  interface Window {
@@ -176,12 +176,6 @@ class ToolTipElement extends HTMLElement {
176
176
  get control() {
177
177
  return this.ownerDocument.getElementById(this.htmlFor);
178
178
  }
179
- set visibilityHidden(value) {
180
- this.style.visibility = value ? 'hidden' : '';
181
- }
182
- get visibilityHidden() {
183
- return this.style.visibility === 'hidden';
184
- }
185
179
  connectedCallback() {
186
180
  var _a;
187
181
  if (!this.shadowRoot) {
@@ -194,7 +188,7 @@ class ToolTipElement extends HTMLElement {
194
188
  <slot></slot>
195
189
  `;
196
190
  }
197
- this.visibilityHidden = true;
191
+ this.hidden = true;
198
192
  __classPrivateFieldSet(this, _ToolTipElement_allowUpdatePosition, true, "f");
199
193
  if (!this.id) {
200
194
  this.id = `tooltip-${Date.now()}-${(Math.random() * 10000).toFixed(0)}`;
@@ -222,22 +216,22 @@ class ToolTipElement extends HTMLElement {
222
216
  return;
223
217
  // Ensures that tooltip stays open when hovering between tooltip and element
224
218
  // WCAG Success Criterion 1.4.13 Hoverable
225
- if ((event.type === 'mouseenter' || event.type === 'focus') && this.visibilityHidden) {
226
- this.visibilityHidden = false;
219
+ if ((event.type === 'mouseenter' || event.type === 'focus') && this.hidden) {
220
+ this.hidden = false;
227
221
  }
228
222
  else if (event.type === 'blur') {
229
- this.visibilityHidden = true;
223
+ this.hidden = true;
230
224
  }
231
225
  else if (event.type === 'mouseleave' &&
232
226
  event.relatedTarget !== this.control &&
233
227
  event.relatedTarget !== this) {
234
- this.visibilityHidden = true;
228
+ this.hidden = true;
235
229
  }
236
- else if (event.type === 'keydown' && event.key === 'Escape' && !this.visibilityHidden) {
237
- this.visibilityHidden = true;
230
+ else if (event.type === 'keydown' && event.key === 'Escape' && !this.hidden) {
231
+ this.hidden = true;
238
232
  }
239
233
  }
240
- attributeChangedCallback(name, oldValue, newValue) {
234
+ attributeChangedCallback(name) {
241
235
  if (name === 'id' || name === 'data-type') {
242
236
  if (!this.id || !this.control)
243
237
  return;
@@ -251,7 +245,7 @@ class ToolTipElement extends HTMLElement {
251
245
  this.control.setAttribute('aria-describedby', describedBy);
252
246
  }
253
247
  }
254
- else if (this.isConnected && name === 'style' && (oldValue && oldValue.includes('visibility')) || (newValue && newValue.includes('visibility'))) {
248
+ else if (this.isConnected && name === 'hidden') {
255
249
  __classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_update).call(this);
256
250
  }
257
251
  else if (name === 'data-direction') {
@@ -293,21 +287,21 @@ class ToolTipElement extends HTMLElement {
293
287
  }
294
288
  }
295
289
  _ToolTipElement_abortController = new WeakMap(), _ToolTipElement_align = new WeakMap(), _ToolTipElement_side = new WeakMap(), _ToolTipElement_allowUpdatePosition = new WeakMap(), _ToolTipElement_instances = new WeakSet(), _ToolTipElement_update = function _ToolTipElement_update() {
296
- if (this.visibilityHidden) {
290
+ if (this.hidden) {
297
291
  this.classList.remove(TOOLTIP_OPEN_CLASS, ...DIRECTION_CLASSES);
298
292
  }
299
293
  else {
300
294
  this.classList.add(TOOLTIP_OPEN_CLASS);
301
295
  for (const tooltip of this.ownerDocument.querySelectorAll(this.tagName)) {
302
296
  if (tooltip !== this)
303
- tooltip.visibilityHidden = true;
297
+ tooltip.hidden = true;
304
298
  }
305
299
  __classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updatePosition).call(this);
306
300
  }
307
301
  }, _ToolTipElement_updatePosition = function _ToolTipElement_updatePosition() {
308
302
  if (!this.control)
309
303
  return;
310
- if (!__classPrivateFieldGet(this, _ToolTipElement_allowUpdatePosition, "f") || this.visibilityHidden)
304
+ if (!__classPrivateFieldGet(this, _ToolTipElement_allowUpdatePosition, "f") || this.hidden)
311
305
  return;
312
306
  const TOOLTIP_OFFSET = 10;
313
307
  this.style.left = `0px`; // Ensures we have reliable tooltip width in `getAnchoredPosition`
@@ -351,7 +345,7 @@ _ToolTipElement_abortController = new WeakMap(), _ToolTipElement_align = new Wea
351
345
  }
352
346
  this.classList.add(`tooltip-${direction}`);
353
347
  };
354
- ToolTipElement.observedAttributes = ['data-type', 'data-direction', 'id', 'style'];
348
+ ToolTipElement.observedAttributes = ['data-type', 'data-direction', 'id', 'hidden'];
355
349
  if (!window.customElements.get('tool-tip')) {
356
350
  window.ToolTipElement = ToolTipElement;
357
351
  window.customElements.define('tool-tip', ToolTipElement);
@@ -176,14 +176,6 @@ class ToolTipElement extends HTMLElement {
176
176
  return this.ownerDocument.getElementById(this.htmlFor)
177
177
  }
178
178
 
179
- set visibilityHidden(value: true | false) {
180
- this.style.visibility = value ? 'hidden' : ''
181
- }
182
-
183
- get visibilityHidden() {
184
- return this.style.visibility === 'hidden'
185
- }
186
-
187
179
  connectedCallback() {
188
180
  if (!this.shadowRoot) {
189
181
  const shadow = this.attachShadow({mode: 'open'})
@@ -195,7 +187,7 @@ class ToolTipElement extends HTMLElement {
195
187
  <slot></slot>
196
188
  `
197
189
  }
198
- this.visibilityHidden = true
190
+ this.hidden = true
199
191
  this.#allowUpdatePosition = true
200
192
 
201
193
  if (!this.id) {
@@ -228,36 +220,36 @@ class ToolTipElement extends HTMLElement {
228
220
 
229
221
  // Ensures that tooltip stays open when hovering between tooltip and element
230
222
  // WCAG Success Criterion 1.4.13 Hoverable
231
- if ((event.type === 'mouseenter' || event.type === 'focus') && this.visibilityHidden) {
232
- this.visibilityHidden = false
223
+ if ((event.type === 'mouseenter' || event.type === 'focus') && this.hidden) {
224
+ this.hidden = false
233
225
  } else if (event.type === 'blur') {
234
- this.visibilityHidden = true
226
+ this.hidden = true
235
227
  } else if (
236
228
  event.type === 'mouseleave' &&
237
229
  (event as MouseEvent).relatedTarget !== this.control &&
238
230
  (event as MouseEvent).relatedTarget !== this
239
231
  ) {
240
- this.visibilityHidden = true
241
- } else if (event.type === 'keydown' && (event as KeyboardEvent).key === 'Escape' && !this.visibilityHidden) {
242
- this.visibilityHidden = true
232
+ this.hidden = true
233
+ } else if (event.type === 'keydown' && (event as KeyboardEvent).key === 'Escape' && !this.hidden) {
234
+ this.hidden = true
243
235
  }
244
236
  }
245
237
 
246
- static observedAttributes = ['data-type', 'data-direction', 'id', 'style']
238
+ static observedAttributes = ['data-type', 'data-direction', 'id', 'hidden']
247
239
 
248
240
  #update() {
249
- if (this.visibilityHidden) {
241
+ if (this.hidden) {
250
242
  this.classList.remove(TOOLTIP_OPEN_CLASS, ...DIRECTION_CLASSES)
251
243
  } else {
252
244
  this.classList.add(TOOLTIP_OPEN_CLASS)
253
- for (const tooltip of this.ownerDocument.querySelectorAll<ToolTipElement>(this.tagName)) {
254
- if (tooltip !== this) tooltip.visibilityHidden = true
245
+ for (const tooltip of this.ownerDocument.querySelectorAll<HTMLElement>(this.tagName)) {
246
+ if (tooltip !== this) tooltip.hidden = true
255
247
  }
256
248
  this.#updatePosition()
257
249
  }
258
250
  }
259
251
 
260
- attributeChangedCallback(name: string, oldValue: string, newValue: string) {
252
+ attributeChangedCallback(name: string) {
261
253
  if (name === 'id' || name === 'data-type') {
262
254
  if (!this.id || !this.control) return
263
255
  if (this.type === 'label') {
@@ -268,7 +260,7 @@ class ToolTipElement extends HTMLElement {
268
260
  describedBy ? (describedBy = `${describedBy} ${this.id}`) : (describedBy = this.id)
269
261
  this.control.setAttribute('aria-describedby', describedBy)
270
262
  }
271
- } else if (this.isConnected && name === 'style' && (oldValue && oldValue.includes('visibility')) || (newValue && newValue.includes('visibility'))) {
263
+ } else if (this.isConnected && name === 'hidden') {
272
264
  this.#update()
273
265
  } else if (name === 'data-direction') {
274
266
  this.classList.remove(...DIRECTION_CLASSES)
@@ -303,7 +295,7 @@ class ToolTipElement extends HTMLElement {
303
295
 
304
296
  #updatePosition() {
305
297
  if (!this.control) return
306
- if (!this.#allowUpdatePosition || this.visibilityHidden) return
298
+ if (!this.#allowUpdatePosition || this.hidden) return
307
299
 
308
300
  const TOOLTIP_OFFSET = 10
309
301
 
@@ -88,8 +88,8 @@ module Primer
88
88
 
89
89
  @text = text
90
90
  @system_arguments = system_arguments
91
+ @system_arguments[:hidden] = true
91
92
  @system_arguments[:tag] = :"tool-tip"
92
- @system_arguments[:style] = join_style_arguments(@system_arguments[:style], "visibility: hidden")
93
93
  @system_arguments[:for] = for_id
94
94
  @system_arguments[:position] = :absolute
95
95
  @system_arguments[:"data-direction"] = fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT).to_s
@@ -53,60 +53,60 @@ module Primer
53
53
  # `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
54
54
  # @code
55
55
  # <%= render(Primer::Alpha::UnderlineNav.new(label: "Default with nav element")) do |component| %>
56
- # <% component.tab(href: "#", selected: true) { "Item 1" } %>
57
- # <% component.tab(href: "#") { "Item 2" } %>
58
- # <% component.actions do %>
56
+ # <% component.with_tab(href: "#", selected: true) { "Item 1" } %>
57
+ # <% component.with_tab(href: "#") { "Item 2" } %>
58
+ # <% component.with_actions do %>
59
59
  # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
60
60
  # <% end %>
61
61
  # <% end %>
62
62
  #
63
63
  # @example With `<div>`
64
64
  # <%= render(Primer::Alpha::UnderlineNav.new(tag: :div, label: "With div element")) do |component| %>
65
- # <% component.tab(href: "#", selected: true) { "Item 1" } %>
66
- # <% component.tab(href: "#") { "Item 2" } %>
67
- # <% component.actions do %>
65
+ # <% component.with_tab(href: "#", selected: true) { "Item 1" } %>
66
+ # <% component.with_tab(href: "#") { "Item 2" } %>
67
+ # <% component.with_actions do %>
68
68
  # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
69
69
  # <% end %>
70
70
  # <% end %>
71
71
  #
72
72
  # @example With icons and counters
73
73
  # <%= render(Primer::Alpha::UnderlineNav.new(label: "With icons and counters")) do |component| %>
74
- # <% component.tab(href: "#", selected: true) do |t| %>
74
+ # <% component.with_tab(href: "#", selected: true) do |t| %>
75
75
  # <% t.icon(icon: :star) %>
76
76
  # <% t.text { "Item 1" } %>
77
77
  # <% end %>
78
- # <% component.tab(href: "#") do |t| %>
78
+ # <% component.with_tab(href: "#") do |t| %>
79
79
  # <% t.icon(icon: :star) %>
80
80
  # <% t.text { "Item 2" } %>
81
81
  # <% t.counter(count: 10) %>
82
82
  # <% end %>
83
- # <% component.tab(href: "#") do |t| %>
83
+ # <% component.with_tab(href: "#") do |t| %>
84
84
  # <% t.text { "Item 3" } %>
85
85
  # <% t.counter(count: 10) %>
86
86
  # <% end %>
87
- # <% component.actions do %>
87
+ # <% component.with_actions do %>
88
88
  # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
89
89
  # <% end %>
90
90
  # <% end %>
91
91
  #
92
92
  # @example Align right
93
93
  # <%= render(Primer::Alpha::UnderlineNav.new(label: "Align right", align: :right)) do |component| %>
94
- # <% component.tab(href: "#", selected: true) do |t| %>
94
+ # <% component.with_tab(href: "#", selected: true) do |t| %>
95
95
  # <% t.text { "Item 1" } %>
96
96
  # <% end %>
97
- # <% component.tab(href: "#") do |t| %>
97
+ # <% component.with_tab(href: "#") do |t| %>
98
98
  # <% t.text { "Item 2" } %>
99
99
  # <% end %>
100
- # <% component.actions do %>
100
+ # <% component.with_actions do %>
101
101
  # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
102
102
  # <% end %>
103
103
  # <% end %>
104
104
  #
105
105
  # @example Customizing the body
106
106
  # <%= render(Primer::Alpha::UnderlineNav.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :accent_emphasis })) do |c| %>
107
- # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
108
- # <% c.tab(href: "#") { "Tab 2" } %>
109
- # <% c.tab(href: "#") { "Tab 3" } %>
107
+ # <% c.with_tab(selected: true, href: "#") { "Tab 1" }%>
108
+ # <% c.with_tab(href: "#") { "Tab 2" } %>
109
+ # <% c.with_tab(href: "#") { "Tab 3" } %>
110
110
  # <% end %>
111
111
  #
112
112
  # @param tag [Symbol] <%= one_of(Primer::Alpha::UnderlineNav::TAG_OPTIONS) %>
@@ -38,19 +38,19 @@ module Primer
38
38
 
39
39
  # @example Default
40
40
  # <%= render(Primer::Alpha::UnderlinePanels.new(label: "With panels")) do |component| %>
41
- # <% component.tab(id: "tab-1", selected: true) do |t| %>
41
+ # <% component.with_tab(id: "tab-1", selected: true) do |t| %>
42
42
  # <% t.text { "Tab 1" } %>
43
43
  # <% t.panel do %>
44
44
  # Panel 1
45
45
  # <% end %>
46
46
  # <% end %>
47
- # <% component.tab(id: "tab-2") do |t| %>
47
+ # <% component.with_tab(id: "tab-2") do |t| %>
48
48
  # <% t.text { "Tab 2" } %>
49
49
  # <% t.panel do %>
50
50
  # Panel 2
51
51
  # <% end %>
52
52
  # <% end %>
53
- # <% component.actions do %>
53
+ # <% component.with_actions do %>
54
54
  # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
55
55
  # <% end %>
56
56
  # <% end %>
@@ -22,11 +22,11 @@ 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::LabelComponent) %>, or <%= link_to_component(Primer::CounterComponent) %>
25
+ # @param kwargs [Hash] The arguments accepted by <%= link_to_component(Primer::OcticonComponent) %>, <%= link_to_component(Primer::LabelComponent) %>, or <%= link_to_component(Primer::Beta::Counter) %>
26
26
  renders_one :trailing_visual, types: {
27
27
  icon: Primer::OcticonComponent,
28
28
  label: Primer::LabelComponent,
29
- counter: Primer::CounterComponent
29
+ counter: Primer::Beta::Counter
30
30
  }
31
31
 
32
32
  # Optional description
@@ -138,12 +138,12 @@ module Primer
138
138
  #
139
139
  # @example With custom classes for the input
140
140
  # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-input", list_id: "fruits-popup--custom-input")) do |c| %>
141
- # <% c.input(classes: "custom-class") %>
141
+ # <% c.with_input(classes: "custom-class") %>
142
142
  # <% end %>
143
143
  #
144
144
  # @example With custom classes for the results
145
145
  # <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-results", list_id: "fruits-popup--custom-results")) do |c| %>
146
- # <% c.results(classes: "custom-class") %>
146
+ # <% c.with_results(classes: "custom-class") %>
147
147
  # <% end %>
148
148
  #
149
149
  # @param label_text [String] The label of the input.
@@ -21,23 +21,23 @@ module Primer
21
21
 
22
22
  # @example Default
23
23
  # <%= render(Primer::Beta::AvatarStack.new) do |c| %>
24
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
25
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
26
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
24
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
25
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
26
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
27
27
  # <% end %>
28
28
  #
29
29
  # @example Align right
30
30
  # <%= render(Primer::Beta::AvatarStack.new(align: :right)) do |c| %>
31
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
32
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
33
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
31
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
32
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
33
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
34
34
  # <% end %>
35
35
  #
36
36
  # @example With tooltip
37
37
  # <%= render(Primer::Beta::AvatarStack.new(tooltipped: true, body_arguments: { label: 'This is a tooltip!' })) do |c| %>
38
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
39
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
40
- # <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
38
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
39
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
40
+ # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
41
41
  # <% end %>
42
42
  #
43
43
  # @param tag [Symbol] <%= one_of(Primer::Beta::AvatarStack::TAG_OPTIONS) %>