primer_view_components 0.0.101 → 0.0.102
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 +12 -0
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/components/primer/alpha/action_list.rb +0 -2
- data/app/components/primer/alpha/nav_list/item.rb +1 -1
- data/app/components/primer/alpha/toggle_switch.d.ts +2 -1
- data/app/components/primer/alpha/toggle_switch.js +0 -1
- data/app/components/primer/alpha/toggle_switch.ts +1 -1
- data/app/components/primer/alpha/tool-tip-element.d.ts +23 -0
- data/app/components/primer/alpha/tool-tip-element.js +352 -0
- data/app/components/primer/clipboard_copy_component.d.ts +1 -0
- data/app/components/primer/clipboard_copy_component.js +43 -0
- data/app/components/primer/layout_component.html.erb +1 -2
- data/app/components/primer/layout_component.rb +2 -0
- data/lib/primer/deprecations.rb +0 -2
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/docs.rake +0 -2
- data/lib/tasks/test.rake +21 -1
- data/previews/primer/alpha/underline_nav_preview.rb +1 -1
- data/static/arguments.json +0 -60
- data/static/audited_at.json +0 -2
- data/static/constants.json +0 -60
- data/static/statuses.json +0 -2
- metadata +11 -9
- data/app/components/primer/flex_component.rb +0 -146
- data/app/components/primer/flex_item_component.rb +0 -55
@@ -73,7 +73,7 @@ module Primer
|
|
73
73
|
|
74
74
|
super
|
75
75
|
|
76
|
-
raise "Cannot render a trailing
|
76
|
+
raise "Cannot render a trailing action for an item with subitems" if items.present? && trailing_action.present?
|
77
77
|
|
78
78
|
return if items.blank?
|
79
79
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
declare class ToggleSwitchElement extends HTMLElement {
|
2
2
|
switch: HTMLElement;
|
3
3
|
loadingSpinner: HTMLElement;
|
4
4
|
errorIcon: HTMLElement;
|
@@ -26,3 +26,4 @@ declare global {
|
|
26
26
|
ToggleSwitchElement: typeof ToggleSwitchElement;
|
27
27
|
}
|
28
28
|
}
|
29
|
+
export {};
|
@@ -135,7 +135,6 @@ __decorate([
|
|
135
135
|
ToggleSwitchElement = __decorate([
|
136
136
|
controller
|
137
137
|
], ToggleSwitchElement);
|
138
|
-
export { ToggleSwitchElement };
|
139
138
|
if (!window.customElements.get('toggle-switch')) {
|
140
139
|
window.ToggleSwitchElement = ToggleSwitchElement;
|
141
140
|
window.customElements.define('toggle-switch', ToggleSwitchElement);
|
@@ -2,7 +2,7 @@ import {controller, target} from '@github/catalyst'
|
|
2
2
|
import {debounce} from '@github/mini-throttle/decorators'
|
3
3
|
|
4
4
|
@controller
|
5
|
-
|
5
|
+
class ToggleSwitchElement extends HTMLElement {
|
6
6
|
@target switch: HTMLElement
|
7
7
|
@target loadingSpinner: HTMLElement
|
8
8
|
@target errorIcon: HTMLElement
|
@@ -0,0 +1,23 @@
|
|
1
|
+
declare type Direction = 'n' | 's' | 'e' | 'w' | 'ne' | 'se' | 'nw' | 'sw';
|
2
|
+
declare class ToolTipElement extends HTMLElement {
|
3
|
+
#private;
|
4
|
+
styles(): string;
|
5
|
+
get htmlFor(): string;
|
6
|
+
set htmlFor(value: string);
|
7
|
+
get type(): 'description' | 'label';
|
8
|
+
set type(value: 'description' | 'label');
|
9
|
+
get direction(): Direction;
|
10
|
+
set direction(value: Direction);
|
11
|
+
get control(): HTMLElement | null;
|
12
|
+
connectedCallback(): void;
|
13
|
+
disconnectedCallback(): void;
|
14
|
+
handleEvent(event: Event): void;
|
15
|
+
static observedAttributes: string[];
|
16
|
+
attributeChangedCallback(name: string): void;
|
17
|
+
}
|
18
|
+
declare global {
|
19
|
+
interface Window {
|
20
|
+
ToolTipElement: typeof ToolTipElement;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
export {};
|
@@ -0,0 +1,352 @@
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
4
|
+
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");
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
6
|
+
};
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
|
+
};
|
12
|
+
var _ToolTipElement_instances, _ToolTipElement_abortController, _ToolTipElement_align, _ToolTipElement_side, _ToolTipElement_allowUpdatePosition, _ToolTipElement_update, _ToolTipElement_updatePosition;
|
13
|
+
import { getAnchoredPosition } from '@primer/behaviors';
|
14
|
+
const TOOLTIP_OPEN_CLASS = 'tooltip-open';
|
15
|
+
const TOOLTIP_ARROW_EDGE_OFFSET = 6;
|
16
|
+
const DIRECTION_CLASSES = [
|
17
|
+
'tooltip-n',
|
18
|
+
'tooltip-s',
|
19
|
+
'tooltip-e',
|
20
|
+
'tooltip-w',
|
21
|
+
'tooltip-ne',
|
22
|
+
'tooltip-se',
|
23
|
+
'tooltip-nw',
|
24
|
+
'tooltip-sw'
|
25
|
+
];
|
26
|
+
class ToolTipElement extends HTMLElement {
|
27
|
+
constructor() {
|
28
|
+
super(...arguments);
|
29
|
+
_ToolTipElement_instances.add(this);
|
30
|
+
_ToolTipElement_abortController.set(this, void 0);
|
31
|
+
_ToolTipElement_align.set(this, 'center');
|
32
|
+
_ToolTipElement_side.set(this, 'outside-bottom');
|
33
|
+
_ToolTipElement_allowUpdatePosition.set(this, false);
|
34
|
+
}
|
35
|
+
styles() {
|
36
|
+
return `
|
37
|
+
:host {
|
38
|
+
position: absolute;
|
39
|
+
z-index: 1000000;
|
40
|
+
padding: .5em .75em;
|
41
|
+
font: normal normal 11px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
42
|
+
-webkit-font-smoothing: subpixel-antialiased;
|
43
|
+
color: var(--color-fg-on-emphasis);
|
44
|
+
text-align: center;
|
45
|
+
text-decoration: none;
|
46
|
+
text-shadow: none;
|
47
|
+
text-transform: none;
|
48
|
+
letter-spacing: normal;
|
49
|
+
word-wrap: break-word;
|
50
|
+
white-space: pre;
|
51
|
+
background: var(--color-neutral-emphasis-plus);
|
52
|
+
border-radius: 6px;
|
53
|
+
opacity: 0;
|
54
|
+
max-width: 250px;
|
55
|
+
word-wrap: break-word;
|
56
|
+
white-space: normal;
|
57
|
+
width: max-content;
|
58
|
+
}
|
59
|
+
|
60
|
+
:host:before{
|
61
|
+
position: absolute;
|
62
|
+
z-index: 1000001;
|
63
|
+
color: var(--color-neutral-emphasis-plus);
|
64
|
+
content: "";
|
65
|
+
border: 6px solid transparent;
|
66
|
+
opacity: 0
|
67
|
+
}
|
68
|
+
|
69
|
+
@keyframes tooltip-appear {
|
70
|
+
from {
|
71
|
+
opacity: 0
|
72
|
+
}
|
73
|
+
to {
|
74
|
+
opacity: 1
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
:host:after{
|
79
|
+
position: absolute;
|
80
|
+
display: block;
|
81
|
+
right: 0;
|
82
|
+
left: 0;
|
83
|
+
height: 12px;
|
84
|
+
content: ""
|
85
|
+
}
|
86
|
+
|
87
|
+
:host(.${TOOLTIP_OPEN_CLASS}),
|
88
|
+
:host(.${TOOLTIP_OPEN_CLASS}):before {
|
89
|
+
animation-name: tooltip-appear;
|
90
|
+
animation-duration: .1s;
|
91
|
+
animation-fill-mode: forwards;
|
92
|
+
animation-timing-function: ease-in;
|
93
|
+
animation-delay: .4s
|
94
|
+
}
|
95
|
+
|
96
|
+
:host(.tooltip-s):before,
|
97
|
+
:host(.tooltip-n):before {
|
98
|
+
right: 50%;
|
99
|
+
margin-right: -${TOOLTIP_ARROW_EDGE_OFFSET}px;
|
100
|
+
}
|
101
|
+
|
102
|
+
:host(.tooltip-s):before,
|
103
|
+
:host(.tooltip-se):before,
|
104
|
+
:host(.tooltip-sw):before {
|
105
|
+
bottom: 100%;
|
106
|
+
border-bottom-color: var(--color-neutral-emphasis-plus)
|
107
|
+
}
|
108
|
+
|
109
|
+
:host(.tooltip-s):after,
|
110
|
+
:host(.tooltip-se):after,
|
111
|
+
:host(.tooltip-sw):after {
|
112
|
+
bottom: 100%
|
113
|
+
}
|
114
|
+
|
115
|
+
:host(.tooltip-n):before,
|
116
|
+
:host(.tooltip-ne):before,
|
117
|
+
:host(.tooltip-nw):before {
|
118
|
+
top: 100%;
|
119
|
+
border-top-color: var(--color-neutral-emphasis-plus)
|
120
|
+
}
|
121
|
+
|
122
|
+
:host(.tooltip-n):after,
|
123
|
+
:host(.tooltip-ne):after,
|
124
|
+
:host(.tooltip-nw):after {
|
125
|
+
top: 100%
|
126
|
+
}
|
127
|
+
|
128
|
+
:host(.tooltip-se):before,
|
129
|
+
:host(.tooltip-ne):before {
|
130
|
+
left: 0;
|
131
|
+
margin-left: ${TOOLTIP_ARROW_EDGE_OFFSET}px;
|
132
|
+
}
|
133
|
+
|
134
|
+
:host(.tooltip-sw):before,
|
135
|
+
:host(.tooltip-nw):before {
|
136
|
+
right: 0;
|
137
|
+
margin-right: ${TOOLTIP_ARROW_EDGE_OFFSET}px;
|
138
|
+
}
|
139
|
+
|
140
|
+
:host(.tooltip-w):before {
|
141
|
+
top: 50%;
|
142
|
+
bottom: 50%;
|
143
|
+
left: 100%;
|
144
|
+
margin-top: -6px;
|
145
|
+
border-left-color: var(--color-neutral-emphasis-plus)
|
146
|
+
}
|
147
|
+
|
148
|
+
:host(.tooltip-e):before {
|
149
|
+
top: 50%;
|
150
|
+
right: 100%;
|
151
|
+
bottom: 50%;
|
152
|
+
margin-top: -6px;
|
153
|
+
border-right-color: var(--color-neutral-emphasis-plus)
|
154
|
+
}
|
155
|
+
`;
|
156
|
+
}
|
157
|
+
get htmlFor() {
|
158
|
+
return this.getAttribute('for') || '';
|
159
|
+
}
|
160
|
+
set htmlFor(value) {
|
161
|
+
this.setAttribute('for', value);
|
162
|
+
}
|
163
|
+
get type() {
|
164
|
+
const type = this.getAttribute('data-type');
|
165
|
+
return type === 'label' ? 'label' : 'description';
|
166
|
+
}
|
167
|
+
set type(value) {
|
168
|
+
this.setAttribute('data-type', value);
|
169
|
+
}
|
170
|
+
get direction() {
|
171
|
+
return (this.getAttribute('data-direction') || 's');
|
172
|
+
}
|
173
|
+
set direction(value) {
|
174
|
+
this.setAttribute('data-direction', value);
|
175
|
+
}
|
176
|
+
get control() {
|
177
|
+
return this.ownerDocument.getElementById(this.htmlFor);
|
178
|
+
}
|
179
|
+
connectedCallback() {
|
180
|
+
var _a;
|
181
|
+
if (!this.shadowRoot) {
|
182
|
+
const shadow = this.attachShadow({ mode: 'open' });
|
183
|
+
// eslint-disable-next-line github/no-inner-html
|
184
|
+
shadow.innerHTML = `
|
185
|
+
<style>
|
186
|
+
${this.styles()}
|
187
|
+
</style>
|
188
|
+
<slot></slot>
|
189
|
+
`;
|
190
|
+
}
|
191
|
+
this.hidden = true;
|
192
|
+
__classPrivateFieldSet(this, _ToolTipElement_allowUpdatePosition, true, "f");
|
193
|
+
if (!this.id) {
|
194
|
+
this.id = `tooltip-${Date.now()}-${(Math.random() * 10000).toFixed(0)}`;
|
195
|
+
}
|
196
|
+
if (!this.control)
|
197
|
+
return;
|
198
|
+
this.setAttribute('role', 'tooltip');
|
199
|
+
(_a = __classPrivateFieldGet(this, _ToolTipElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
200
|
+
__classPrivateFieldSet(this, _ToolTipElement_abortController, new AbortController(), "f");
|
201
|
+
const { signal } = __classPrivateFieldGet(this, _ToolTipElement_abortController, "f");
|
202
|
+
this.addEventListener('mouseleave', this, { signal });
|
203
|
+
this.control.addEventListener('mouseenter', this, { signal });
|
204
|
+
this.control.addEventListener('mouseleave', this, { signal });
|
205
|
+
this.control.addEventListener('focus', this, { signal });
|
206
|
+
this.control.addEventListener('blur', this, { signal });
|
207
|
+
this.ownerDocument.addEventListener('keydown', this, { signal });
|
208
|
+
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_update).call(this);
|
209
|
+
}
|
210
|
+
disconnectedCallback() {
|
211
|
+
var _a;
|
212
|
+
(_a = __classPrivateFieldGet(this, _ToolTipElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
213
|
+
}
|
214
|
+
handleEvent(event) {
|
215
|
+
if (!this.control)
|
216
|
+
return;
|
217
|
+
// Ensures that tooltip stays open when hovering between tooltip and element
|
218
|
+
// WCAG Success Criterion 1.4.13 Hoverable
|
219
|
+
if ((event.type === 'mouseenter' || event.type === 'focus') && this.hidden) {
|
220
|
+
this.hidden = false;
|
221
|
+
}
|
222
|
+
else if (event.type === 'blur') {
|
223
|
+
this.hidden = true;
|
224
|
+
}
|
225
|
+
else if (event.type === 'mouseleave' &&
|
226
|
+
event.relatedTarget !== this.control &&
|
227
|
+
event.relatedTarget !== this) {
|
228
|
+
this.hidden = true;
|
229
|
+
}
|
230
|
+
else if (event.type === 'keydown' && event.key === 'Escape' && !this.hidden) {
|
231
|
+
this.hidden = true;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
attributeChangedCallback(name) {
|
235
|
+
if (name === 'id' || name === 'data-type') {
|
236
|
+
if (!this.id || !this.control)
|
237
|
+
return;
|
238
|
+
if (this.type === 'label') {
|
239
|
+
this.control.setAttribute('aria-labelledby', this.id);
|
240
|
+
this.setAttribute('aria-hidden', 'true');
|
241
|
+
}
|
242
|
+
else {
|
243
|
+
let describedBy = this.control.getAttribute('aria-describedby');
|
244
|
+
describedBy ? (describedBy = `${describedBy} ${this.id}`) : (describedBy = this.id);
|
245
|
+
this.control.setAttribute('aria-describedby', describedBy);
|
246
|
+
}
|
247
|
+
}
|
248
|
+
else if (this.isConnected && name === 'hidden') {
|
249
|
+
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_update).call(this);
|
250
|
+
}
|
251
|
+
else if (name === 'data-direction') {
|
252
|
+
this.classList.remove(...DIRECTION_CLASSES);
|
253
|
+
const direction = this.direction;
|
254
|
+
if (direction === 'n') {
|
255
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
256
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
|
257
|
+
}
|
258
|
+
else if (direction === 'ne') {
|
259
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
|
260
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
|
261
|
+
}
|
262
|
+
else if (direction === 'e') {
|
263
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
264
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-right', "f");
|
265
|
+
}
|
266
|
+
else if (direction === 'se') {
|
267
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
|
268
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
|
269
|
+
}
|
270
|
+
else if (direction === 's') {
|
271
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
272
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
|
273
|
+
}
|
274
|
+
else if (direction === 'sw') {
|
275
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
|
276
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
|
277
|
+
}
|
278
|
+
else if (direction === 'w') {
|
279
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
280
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-left', "f");
|
281
|
+
}
|
282
|
+
else if (direction === 'nw') {
|
283
|
+
__classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
|
284
|
+
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
|
285
|
+
}
|
286
|
+
}
|
287
|
+
}
|
288
|
+
}
|
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() {
|
290
|
+
if (this.hidden) {
|
291
|
+
this.classList.remove(TOOLTIP_OPEN_CLASS, ...DIRECTION_CLASSES);
|
292
|
+
}
|
293
|
+
else {
|
294
|
+
this.classList.add(TOOLTIP_OPEN_CLASS);
|
295
|
+
for (const tooltip of this.ownerDocument.querySelectorAll(this.tagName)) {
|
296
|
+
if (tooltip !== this)
|
297
|
+
tooltip.hidden = true;
|
298
|
+
}
|
299
|
+
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updatePosition).call(this);
|
300
|
+
}
|
301
|
+
}, _ToolTipElement_updatePosition = function _ToolTipElement_updatePosition() {
|
302
|
+
if (!this.control)
|
303
|
+
return;
|
304
|
+
if (!__classPrivateFieldGet(this, _ToolTipElement_allowUpdatePosition, "f") || this.hidden)
|
305
|
+
return;
|
306
|
+
const TOOLTIP_OFFSET = 10;
|
307
|
+
this.style.left = `0px`; // Ensures we have reliable tooltip width in `getAnchoredPosition`
|
308
|
+
const position = getAnchoredPosition(this, this.control, {
|
309
|
+
side: __classPrivateFieldGet(this, _ToolTipElement_side, "f"),
|
310
|
+
align: __classPrivateFieldGet(this, _ToolTipElement_align, "f"),
|
311
|
+
anchorOffset: TOOLTIP_OFFSET
|
312
|
+
});
|
313
|
+
const anchorSide = position.anchorSide;
|
314
|
+
const align = position.anchorAlign;
|
315
|
+
this.style.top = `${position.top}px`;
|
316
|
+
this.style.left = `${position.left}px`;
|
317
|
+
let direction = 's';
|
318
|
+
if (anchorSide === 'outside-left') {
|
319
|
+
direction = 'w';
|
320
|
+
}
|
321
|
+
else if (anchorSide === 'outside-right') {
|
322
|
+
direction = 'e';
|
323
|
+
}
|
324
|
+
else if (anchorSide === 'outside-top') {
|
325
|
+
if (align === 'center') {
|
326
|
+
direction = 'n';
|
327
|
+
}
|
328
|
+
else if (align === 'start') {
|
329
|
+
direction = 'ne';
|
330
|
+
}
|
331
|
+
else {
|
332
|
+
direction = 'nw';
|
333
|
+
}
|
334
|
+
}
|
335
|
+
else {
|
336
|
+
if (align === 'center') {
|
337
|
+
direction = 's';
|
338
|
+
}
|
339
|
+
else if (align === 'start') {
|
340
|
+
direction = 'se';
|
341
|
+
}
|
342
|
+
else {
|
343
|
+
direction = 'sw';
|
344
|
+
}
|
345
|
+
}
|
346
|
+
this.classList.add(`tooltip-${direction}`);
|
347
|
+
};
|
348
|
+
ToolTipElement.observedAttributes = ['data-type', 'data-direction', 'id', 'hidden'];
|
349
|
+
if (!window.customElements.get('tool-tip')) {
|
350
|
+
window.ToolTipElement = ToolTipElement;
|
351
|
+
window.customElements.define('tool-tip', ToolTipElement);
|
352
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/clipboard-copy-element';
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import '@github/clipboard-copy-element';
|
2
|
+
const CLIPBOARD_COPY_TIMER_DURATION = 2000;
|
3
|
+
function showSVG(svg) {
|
4
|
+
svg.style.display = 'inline-block';
|
5
|
+
}
|
6
|
+
function hideSVG(svg) {
|
7
|
+
svg.style.display = 'none';
|
8
|
+
}
|
9
|
+
// Toggle a copy button.
|
10
|
+
function showCopy(button) {
|
11
|
+
const [copyIcon, checkIcon] = button.querySelectorAll('.octicon');
|
12
|
+
if (!copyIcon || !checkIcon)
|
13
|
+
return;
|
14
|
+
showSVG(copyIcon);
|
15
|
+
hideSVG(checkIcon);
|
16
|
+
}
|
17
|
+
// Toggle a copy button.
|
18
|
+
function showCheck(button) {
|
19
|
+
const [copyIcon, checkIcon] = button.querySelectorAll('.octicon');
|
20
|
+
if (!copyIcon || !checkIcon)
|
21
|
+
return;
|
22
|
+
hideSVG(copyIcon);
|
23
|
+
showSVG(checkIcon);
|
24
|
+
}
|
25
|
+
const clipboardCopyElementTimers = new WeakMap();
|
26
|
+
document.addEventListener('clipboard-copy', function ({ target }) {
|
27
|
+
if (!(target instanceof HTMLElement))
|
28
|
+
return;
|
29
|
+
if (!target.hasAttribute('data-view-component'))
|
30
|
+
return;
|
31
|
+
const currentTimeout = clipboardCopyElementTimers.get(target);
|
32
|
+
if (currentTimeout) {
|
33
|
+
clearTimeout(currentTimeout);
|
34
|
+
clipboardCopyElementTimers.delete(target);
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
showCheck(target);
|
38
|
+
}
|
39
|
+
clipboardCopyElementTimers.set(target, setTimeout(() => {
|
40
|
+
showCopy(target);
|
41
|
+
clipboardCopyElementTimers.delete(target);
|
42
|
+
}, CLIPBOARD_COPY_TIMER_DURATION));
|
43
|
+
});
|
@@ -61,6 +61,8 @@ module Primer
|
|
61
61
|
@system_arguments[:classes]
|
62
62
|
)
|
63
63
|
@system_arguments[:direction] = responsive ? [:column, nil, :row] : nil
|
64
|
+
@system_arguments[:display] = :flex
|
65
|
+
@system_arguments[:tag] = :div
|
64
66
|
|
65
67
|
@sidebar_col = fetch_or_fallback(ALLOWED_SIDEBAR_COLS, sidebar_col, DEFAULT_SIDEBAR_COL)
|
66
68
|
@main_col = MAX_COL - @sidebar_col
|
data/lib/primer/deprecations.rb
CHANGED
@@ -13,8 +13,6 @@ module Primer
|
|
13
13
|
"Primer::CounterComponent" => "Primer::Beta::Counter",
|
14
14
|
"Primer::DetailsComponent" => "Primer::Beta::Details",
|
15
15
|
"Primer::DropdownMenuComponent" => nil,
|
16
|
-
"Primer::FlexComponent" => nil,
|
17
|
-
"Primer::FlexItemComponent" => nil,
|
18
16
|
"Primer::HeadingComponent" => "Primer::Beta::Heading",
|
19
17
|
"Primer::HiddenTextExpander" => "Primer::Alpha::HiddenTextExpander",
|
20
18
|
"Primer::IconButton" => "Primer::Beta::IconButton",
|
data/lib/tasks/docs.rake
CHANGED
data/lib/tasks/test.rake
CHANGED
@@ -4,7 +4,7 @@ require "rake/testtask"
|
|
4
4
|
|
5
5
|
namespace :test do
|
6
6
|
desc "Run all tests"
|
7
|
-
task all: [:fast, :system]
|
7
|
+
task all: [:fast, :system, :accessibility, :bench]
|
8
8
|
|
9
9
|
Rake::TestTask.new(:single) do |t|
|
10
10
|
ENV["TZ"] = "Asia/Taipei"
|
@@ -22,6 +22,7 @@ namespace :test do
|
|
22
22
|
t.test_files = FileList[
|
23
23
|
"test/components/**/*_test.rb",
|
24
24
|
"test/lib/**/*_test.rb",
|
25
|
+
"test/forms/**/*_test.rb",
|
25
26
|
"test/primer/**/*_test.rb",
|
26
27
|
"test/linters/**/*_test.rb",
|
27
28
|
"test/rubocop/**/*_test.rb"
|
@@ -36,6 +37,25 @@ namespace :test do
|
|
36
37
|
t.test_files = FileList["test/system/**/*_test.rb"]
|
37
38
|
end
|
38
39
|
|
40
|
+
Rake::TestTask.new(:accessibility) do |t|
|
41
|
+
ENV["TZ"] = "Asia/Taipei"
|
42
|
+
|
43
|
+
t.libs << "test"
|
44
|
+
t.libs << "lib"
|
45
|
+
t.test_files = FileList["test/accessibility_test.rb"]
|
46
|
+
end
|
47
|
+
|
48
|
+
Rake::TestTask.new(:snapshots) do |t|
|
49
|
+
# Clear folder
|
50
|
+
FileUtils.rm_rf("test/snapshots")
|
51
|
+
|
52
|
+
ENV["TZ"] = "Asia/Taipei"
|
53
|
+
|
54
|
+
t.libs << "test"
|
55
|
+
t.libs << "lib"
|
56
|
+
t.test_files = FileList["test/snapshots_test.rb"]
|
57
|
+
end
|
58
|
+
|
39
59
|
Rake::TestTask.new(:bench) do |t|
|
40
60
|
t.libs << "test"
|
41
61
|
t.test_files = FileList["test/benchmarks/**/bench_*.rb"]
|
data/static/arguments.json
CHANGED
@@ -1559,66 +1559,6 @@
|
|
1559
1559
|
}
|
1560
1560
|
]
|
1561
1561
|
},
|
1562
|
-
{
|
1563
|
-
"component": "Flex",
|
1564
|
-
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/flex_component.rb",
|
1565
|
-
"parameters": [
|
1566
|
-
{
|
1567
|
-
"name": "justify_content",
|
1568
|
-
"type": "Symbol",
|
1569
|
-
"default": "`JUSTIFY_CONTENT_DEFAULT`",
|
1570
|
-
"description": "Use this param to distribute space between and around flex items along the main axis of the container. One of `nil`, `:center`, `:flex_end`, `:flex_start`, `:space_around`, or `:space_between`."
|
1571
|
-
},
|
1572
|
-
{
|
1573
|
-
"name": "inline",
|
1574
|
-
"type": "Boolean",
|
1575
|
-
"default": "`false`",
|
1576
|
-
"description": "Defaults to false."
|
1577
|
-
},
|
1578
|
-
{
|
1579
|
-
"name": "flex_wrap",
|
1580
|
-
"type": "Boolean",
|
1581
|
-
"default": "`FLEX_WRAP_DEFAULT`",
|
1582
|
-
"description": "Defaults to nil."
|
1583
|
-
},
|
1584
|
-
{
|
1585
|
-
"name": "align_items",
|
1586
|
-
"type": "Symbol",
|
1587
|
-
"default": "`ALIGN_ITEMS_DEFAULT`",
|
1588
|
-
"description": "Use this param to align items on the cross axis. One of `nil`, `:baseline`, `:center`, `:end`, `:start`, or `:stretch`."
|
1589
|
-
},
|
1590
|
-
{
|
1591
|
-
"name": "direction",
|
1592
|
-
"type": "Symbol",
|
1593
|
-
"default": "`nil`",
|
1594
|
-
"description": "Use this param to define the orientation of the main axis (row or column). By default, flex items will display in a row. One of `nil`, `:column`, `:column_reverse`, `:row`, or `:row_reverse`."
|
1595
|
-
},
|
1596
|
-
{
|
1597
|
-
"name": "system_arguments",
|
1598
|
-
"type": "Hash",
|
1599
|
-
"default": "N/A",
|
1600
|
-
"description": "[System arguments](/system-arguments)"
|
1601
|
-
}
|
1602
|
-
]
|
1603
|
-
},
|
1604
|
-
{
|
1605
|
-
"component": "FlexItem",
|
1606
|
-
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/flex_item_component.rb",
|
1607
|
-
"parameters": [
|
1608
|
-
{
|
1609
|
-
"name": "flex_auto",
|
1610
|
-
"type": "Boolean",
|
1611
|
-
"default": "`false`",
|
1612
|
-
"description": "Fills available space and auto-sizes based on the content. Defaults to false"
|
1613
|
-
},
|
1614
|
-
{
|
1615
|
-
"name": "system_arguments",
|
1616
|
-
"type": "Hash",
|
1617
|
-
"default": "N/A",
|
1618
|
-
"description": "[System arguments](/system-arguments)"
|
1619
|
-
}
|
1620
|
-
]
|
1621
|
-
},
|
1622
1562
|
{
|
1623
1563
|
"component": "HellipButton",
|
1624
1564
|
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/hellip_button.rb",
|
data/static/audited_at.json
CHANGED
@@ -60,8 +60,6 @@
|
|
60
60
|
"Primer::Dropdown::Menu": "",
|
61
61
|
"Primer::Dropdown::Menu::Item": "",
|
62
62
|
"Primer::DropdownMenuComponent": "",
|
63
|
-
"Primer::FlexComponent": "",
|
64
|
-
"Primer::FlexItemComponent": "",
|
65
63
|
"Primer::HeadingComponent": "",
|
66
64
|
"Primer::HellipButton": "",
|
67
65
|
"Primer::HiddenTextExpander": "",
|