primer_view_components 0.0.113 → 0.0.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +2 -2
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list/divider.rb +2 -0
- data/app/components/primer/alpha/action_list/heading.rb +2 -0
- data/app/components/primer/alpha/action_list/item.rb +8 -6
- data/app/components/primer/alpha/action_list.rb +1 -0
- data/app/components/primer/alpha/auto_complete/auto_complete.html.erb +1 -1
- data/app/components/primer/alpha/auto_complete/item.rb +1 -0
- data/app/components/primer/alpha/auto_complete.rb +3 -2
- data/app/components/primer/alpha/banner.html.erb +1 -1
- data/app/components/primer/alpha/banner.rb +1 -0
- data/app/components/primer/alpha/button_marketing.rb +2 -0
- data/app/components/primer/alpha/dialog.rb +3 -0
- data/app/components/primer/alpha/image.rb +1 -0
- data/app/components/primer/alpha/image_crop.html.erb +1 -1
- data/app/components/primer/alpha/layout.css +1 -0
- data/app/components/primer/alpha/layout.css.json +1 -0
- data/app/components/primer/alpha/layout.css.map +1 -0
- data/app/components/primer/alpha/layout.pcss +268 -0
- data/app/components/primer/{menu_component.css → alpha/menu.css} +0 -0
- data/app/components/primer/alpha/menu.css.json +1 -0
- data/app/components/primer/alpha/menu.css.map +1 -0
- data/app/components/primer/{menu_component.html.erb → alpha/menu.html.erb} +0 -0
- data/app/components/primer/{menu_component.pcss → alpha/menu.pcss} +0 -0
- data/app/components/primer/alpha/menu.rb +76 -0
- data/app/components/primer/{octicon_symbols_component.html.erb → alpha/octicon_symbols.html.erb} +0 -0
- data/app/components/primer/alpha/octicon_symbols.rb +61 -0
- data/app/components/primer/alpha/text_field.rb +1 -0
- data/app/components/primer/alpha/toggle_switch.html.erb +2 -2
- data/app/components/primer/alpha/toggle_switch.rb +2 -0
- data/app/components/primer/alpha/tool_tip.js +77 -69
- data/app/components/primer/alpha/tool_tip.ts +63 -51
- data/app/components/primer/alpha/tooltip.rb +2 -0
- data/app/components/primer/beta/auto_complete/item.rb +4 -4
- data/app/components/primer/beta/auto_complete.rb +3 -3
- data/app/components/primer/beta/avatar.rb +1 -0
- data/app/components/primer/beta/base_button.rb +1 -0
- data/app/components/primer/beta/blankslate.rb +5 -5
- data/app/components/primer/beta/button.rb +7 -7
- data/app/components/primer/beta/clipboard_copy.html.erb +2 -2
- data/app/components/primer/beta/clipboard_copy.rb +1 -0
- data/app/components/primer/beta/close_button.rb +2 -1
- data/app/components/primer/beta/counter.rb +1 -0
- data/app/components/primer/beta/heading.rb +1 -0
- data/app/components/primer/beta/icon_button.html.erb +1 -1
- data/app/components/primer/beta/icon_button.rb +1 -0
- data/app/components/primer/beta/label.rb +1 -0
- data/app/components/primer/beta/markdown.rb +291 -0
- data/app/components/primer/{octicon_component.html.erb → beta/octicon.html.erb} +0 -0
- data/app/components/primer/beta/octicon.rb +88 -0
- data/app/components/primer/beta/relative_time.rb +2 -1
- data/app/components/primer/{spinner_component.html.erb → beta/spinner.html.erb} +0 -0
- data/app/components/primer/beta/spinner.rb +46 -0
- data/app/components/primer/beta/text.rb +1 -0
- data/app/components/primer/blankslate_component.rb +3 -3
- data/app/components/primer/box.rb +1 -0
- data/app/components/primer/button_component.rb +3 -3
- data/app/components/primer/conditional_wrapper.rb +2 -0
- data/app/components/primer/hellip_button.rb +2 -0
- data/app/components/primer/icon_button.html.erb +2 -2
- data/app/components/primer/icon_button.rb +1 -0
- data/app/components/primer/layout_component.rb +2 -0
- data/app/components/primer/local_time.rb +3 -0
- data/app/components/primer/markdown.rb +2 -283
- data/app/components/primer/menu_component.rb +2 -69
- data/app/components/primer/navigation/tab_component.rb +2 -2
- data/app/components/primer/octicon_component.rb +3 -81
- data/app/components/primer/octicon_symbols_component.rb +2 -52
- data/app/components/primer/primer.d.ts +2 -0
- data/app/components/primer/primer.js +2 -0
- data/app/components/primer/primer.pcss +2 -3
- data/app/components/primer/primer.ts +2 -0
- data/app/components/primer/spinner_component.rb +2 -38
- data/app/components/primer/state_component.rb +1 -0
- data/app/components/primer/subhead_component.rb +2 -0
- data/app/components/primer/tab_container_component.rb +2 -0
- data/app/components/primer/time_ago_component.rb +2 -1
- data/app/components/primer/timeline_item_component.rb +3 -2
- data/app/components/primer/tooltip.rb +1 -0
- data/app/components/primer/truncate.rb +2 -0
- data/app/forms/immediate_validation_form.rb +29 -0
- data/app/forms/multi_input_form.rb +4 -2
- data/app/lib/primer/css/layout.css +1 -378
- data/app/lib/primer/css/layout.css.json +1 -1
- data/app/lib/primer/octicon/cache.rb +1 -1
- data/app/lib/primer/view_helper.rb +1 -1
- data/lib/primer/deprecations.yml +30 -0
- data/lib/primer/forms/builder.rb +48 -8
- data/lib/primer/forms/check_box.html.erb +3 -1
- data/lib/primer/forms/dsl/input.rb +23 -1
- data/lib/primer/forms/dsl/multi_input.rb +6 -9
- data/lib/primer/forms/dsl/select_list_input.rb +1 -1
- data/lib/primer/forms/dsl/text_field_input.rb +31 -1
- data/lib/primer/forms/form_control.html.erb +17 -13
- data/lib/primer/forms/form_control.rb +2 -0
- data/lib/primer/forms/multi.html.erb +6 -2
- data/lib/primer/forms/primer_multi_input.d.ts +10 -0
- data/lib/primer/forms/primer_multi_input.js +45 -0
- data/lib/primer/forms/primer_multi_input.ts +46 -0
- data/lib/primer/forms/primer_text_field.d.ts +1 -0
- data/lib/primer/forms/primer_text_field.js +62 -0
- data/lib/primer/forms/primer_text_field.ts +48 -0
- data/lib/primer/forms/radio_button.html.erb +3 -1
- data/lib/primer/forms/text_field.html.erb +8 -8
- data/lib/primer/forms/text_field.rb +11 -0
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/docs.rake +6 -6
- data/lib/tasks/helpers/ast_traverser.rb +1 -1
- data/previews/primer/alpha/action_list_preview.rb +1 -1
- data/previews/primer/alpha/auto_complete_preview.rb +62 -6
- data/previews/primer/alpha/layout_preview.rb +179 -6
- data/previews/primer/{menu_component_preview → alpha/menu_preview}/default.html.erb +3 -3
- data/previews/primer/{menu_component_preview → alpha/menu_preview}/playground.html.erb +3 -3
- data/previews/primer/alpha/menu_preview.rb +14 -0
- data/previews/primer/alpha/toggle_switch_preview.rb +11 -9
- data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +1 -1
- data/previews/primer/beta/auto_complete_preview.rb +19 -17
- data/previews/primer/{markdown_preview.rb → beta/markdown_preview.rb} +14 -12
- data/previews/primer/beta/octicon_preview.rb +24 -0
- data/previews/primer/beta/spinner_preview.rb +22 -0
- data/previews/primer/forms/forms_preview/immediate_validation_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/multi_input_form.html.erb +12 -1
- data/previews/primer/forms/forms_preview.rb +2 -0
- data/previews/primer/url_helpers.rb +15 -0
- data/static/arguments.json +178 -178
- data/static/audited_at.json +5 -0
- data/static/constants.json +50 -40
- data/static/statuses.json +12 -7
- metadata +34 -24
- data/app/components/primer/beta/button_group.css +0 -1
- data/app/components/primer/beta/button_group.css.json +0 -1
- data/app/components/primer/beta/button_group.css.map +0 -1
- data/app/components/primer/beta/button_group.pcss +0 -92
- data/app/components/primer/button_component.css +0 -1
- data/app/components/primer/button_component.css.json +0 -1
- data/app/components/primer/button_component.css.map +0 -1
- data/app/components/primer/button_component.pcss +0 -557
- data/app/components/primer/menu_component.css.json +0 -1
- data/app/components/primer/menu_component.css.map +0 -1
- data/previews/primer/menu_component_preview.rb +0 -12
- data/previews/primer/octicon_component_preview.rb +0 -22
- 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::
|
|
3
|
-
<%= render(Primer::
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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 =
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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 =
|
|
296
|
+
describedBy = `${describedBy}`
|
|
289
297
|
}
|
|
290
|
-
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
48
|
+
Primer::Beta::Octicon.new(**system_arguments)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -19,9 +19,9 @@ module Primer
|
|
|
19
19
|
#
|
|
20
20
|
# Use:
|
|
21
21
|
#
|
|
22
|
-
# - `visual_icon` for an <%= link_to_component(Primer::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
70
|
+
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
|
|
71
71
|
renders_one :trailing_action, types: {
|
|
72
|
-
icon: Primer::
|
|
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::
|
|
6
|
-
<%= render Primer::
|
|
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 %>
|
|
@@ -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::
|
|
37
|
+
render(Primer::Beta::Octicon.new("x"))
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
end
|
|
@@ -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::
|
|
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
|