Previews

No matching results.

x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<action-list>
<div data-view-component="true">
<div data-view-component="true" class="ActionList-sectionDivider">
<h3 id="heading-title-061071c1-228a-4827-ae2c-565fb9a5e5f6" data-view-component="true" class="ActionList-sectionDivider-title">
Action List
</h3>
</div>
<ul id="action-list-47f26d9c-f5a2-4ba1-8fc2-02eba3d6f26b" role="list" aria-labelledby="heading-title-061071c1-228a-4827-ae2c-565fb9a5e5f6" data-view-component="true" class="ActionListWrap">
<li data-targets="action-list.items" data-view-component="true" class="ActionListItem">
<a id="item-666e17ea-6e8f-4b59-a512-ebb4c11901cb" href="/" data-view-component="true" class="ActionListContent ActionListContent--visual16">
<span class="ActionListItem-visual ActionListItem-visual--leading">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-gear">
<path d="M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.102-.302c-.067-.019-.177-.011-.3.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.102.302c.067.019.177.011.3-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.146a6.6 6.6 0 0 0-1.142 0ZM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM9.5 8a1.5 1.5 0 1 0-3.001.001A1.5 1.5 0 0 0 9.5 8Z"></path>
</svg>
</span>
<span data-view-component="true" class="ActionListItem-label">
Item one
</span></a>
</li>
<li data-targets="action-list.items" data-view-component="true" class="ActionListItem">
<a id="item-d8b286bf-ef83-48cd-99cd-3a94e4567a26" href="/" data-view-component="true" class="ActionListContent ActionListContent--visual16">
<span class="ActionListItem-visual ActionListItem-visual--leading">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star">
<path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path>
</svg>
</span>
<span data-view-component="true" class="ActionListItem-label">
Item two
</span></a>
</li>
<li data-targets="action-list.items" data-view-component="true" class="ActionListItem">
<a id="item-f0063576-31ab-4e38-8fff-cdf55b5d5852" href="/" data-view-component="true" class="ActionListContent ActionListContent--visual16">
<span class="ActionListItem-visual ActionListItem-visual--leading">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-heart">
<path d="m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002ZM4.25 2.5c-1.336 0-2.75 1.164-2.75 3 0 2.15 1.58 4.144 3.365 5.682A20.58 20.58 0 0 0 8 13.393a20.58 20.58 0 0 0 3.135-2.211C12.92 9.644 14.5 7.65 14.5 5.5c0-1.836-1.414-3-2.75-3-1.373 0-2.609.986-3.029 2.456a.749.749 0 0 1-1.442 0C6.859 3.486 5.623 2.5 4.25 2.5Z"></path>
</svg>
</span>
<span data-view-component="true" class="ActionListItem-label">
Item three
</span></a>
</li>
</ul>
</div>
</action-list>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
render(Primer::Alpha::ActionList.new(
role: role,
scheme: scheme,
show_dividers: show_dividers
)) do |component|
component.with_heading(title: "Action List")
component.with_item(label: "Item one", href: "/") do |item|
item.with_leading_visual_icon(icon: :gear)
end
component.with_item(label: "Item two", href: "/") do |item|
item.with_leading_visual_icon(icon: :star)
end
component.with_item(label: "Item three", href: "/") do |item|
item.with_leading_visual_icon(icon: :heart)
end
end
Param Description Input

app/components/primer/alpha/action_list.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
:root {
--actionListContent-paddingBlock: var(--control-medium-paddingBlock,0.375rem);
}
/* ActionList */
action-list {
display: block;
}
nav-list {
display: block;
}
.ActionListHeader {
margin-left: var(--base-size-8,0.5rem);
margin-bottom: var(--base-size-16,1rem);
}
/* <ul> */
.ActionListWrap {
list-style: none;
}
.ActionListWrap--inset,
.ActionListWrap--inset[popover] {
padding: var(--base-size-8,0.5rem);
}
/* list dividers */
.ActionListWrap--divided .ActionListItem-label::before {
position: absolute;
top: calc(-1 * var(--actionListContent-paddingBlock));
display: block;
width: 100%;
height: 1px;
content: '';
background: var(--borderColor-muted, var(--color-action-list-item-inline-divider));
}
/* if descriptionWrap--inline exists, move pseudo divider to wrapper */
.ActionListWrap--divided .ActionListItem-descriptionWrap--inline::before {
position: absolute;
top: calc(-1 * var(--actionListContent-paddingBlock));
display: block;
width: 100%;
height: var(--borderWidth-thin,max(1px, 0.0625rem));
content: '';
background: var(--borderColor-muted, var(--color-action-list-item-inline-divider));
}
/* unset the default label pseudo */
.ActionListWrap--divided .ActionListItem-descriptionWrap--inline .ActionListItem-label::before {
content: unset;
}
/* hide divider if item is active */
.ActionListWrap--divided .ActionListItem--navActive .ActionListItem-label::before,
.ActionListWrap--divided .ActionListItem--navActive + .ActionListItem .ActionListItem-label::before {
visibility: hidden;
}
/* hide if item is first of type with label::before, or is the first item after a sectionDivider */
.ActionListItem:first-of-type .ActionListItem-label::before,
.ActionList-sectionDivider + .ActionListItem .ActionListItem-label::before {
visibility: hidden;
}
/* hide if item is first of type with label::before, or is the first item after a sectionDivider */
.ActionListItem:first-of-type .ActionListItem-descriptionWrap--inline::before,
.ActionList-sectionDivider + .ActionListItem .ActionListItem-descriptionWrap--inline::before {
visibility: hidden;
}
/* ActionList::Item */
.ActionListItem {
position: relative;
list-style: none;
background-color: var(--control-transparent-bgColor-rest,transparent);
border-radius: var(--borderRadius-medium,0.375rem);
/* state */
}
.ActionListItem:hover,
.ActionListItem:active {
cursor: pointer;
}
/* hide dividers */
@media (hover: hover) {
.ActionListItem:hover .ActionListItem-label::before,
.ActionListItem:hover + .ActionListItem .ActionListItem-label::before {
visibility: hidden;
}
.ActionListItem:hover .ActionListItem-descriptionWrap--inline::before,
.ActionListItem:hover + .ActionListItem .ActionListItem-descriptionWrap--inline::before {
visibility: hidden;
}
}
/* Make sure that the first visible item isn't a divider */
.ActionListItem[hidden] + .ActionList-sectionDivider {
display: none;
}
/* collapse styles here */
/* first child */
.ActionListItem.ActionListItem--hasSubItem > .ActionListContent {
z-index: 1;
}
@media (hover: hover) {
.ActionListItem.ActionListItem--hasSubItem > .ActionListContent:hover {
background-color: var(--control-transparent-bgColor-hover,var(--color-action-list-item-default-hover-bg));
}
}
.ActionListItem.ActionListItem--hasSubItem > .ActionListContent:active {
background-color: var(--control-transparent-bgColor-active,var(--color-action-list-item-default-active-bg));
}
/* only hover li without list as children */
@media (hover: hover) {
.ActionListItem:not(.ActionListItem--hasSubItem):hover, .ActionListItem.ActionListItem--hasSubItem > .ActionListContent:hover {
cursor: pointer;
background-color: var(--control-transparent-bgColor-hover,var(--color-action-list-item-default-hover-bg));
}
.ActionListItem:not(.ActionListItem--hasSubItem):hover:not(.ActionListItem--navActive, :focus-visible), .ActionListItem.ActionListItem--hasSubItem > .ActionListContent:hover:not(.ActionListItem--navActive, :focus-visible) {
/* Support for "Windows high contrast mode" */
outline: solid var(--borderWidth-thin,max(1px, 0.0625rem)) transparent;
outline-offset: calc(-1 * var(--borderWidth-thin,max(1px, 0.0625rem)));
box-shadow: var(--boxShadow-thin,inset 0 0 0 max(1px, 0.0625rem)) var(--control-transparent-borderColor-active,var(--color-action-list-item-default-active-border));
}
}
.ActionListItem:not(.ActionListItem--hasSubItem):active, .ActionListItem.ActionListItem--hasSubItem > .ActionListContent:active {
background: var(--control-transparent-bgColor-active,var(--color-action-list-item-default-active-bg));
}
.ActionListItem:not(.ActionListItem--hasSubItem):active:not(.ActionListItem--navActive), .ActionListItem.ActionListItem--hasSubItem > .ActionListContent:active:not(.ActionListItem--navActive) {
/* Support for "Windows high contrast mode" https:sarahmhigley.com/writing/whcm-quick-tips/ */
outline: solid var(--borderWidth-thin,max(1px, 0.0625rem)) transparent;
outline-offset: calc(-1 * var(--borderWidth-thin,max(1px, 0.0625rem)));
box-shadow: var(--boxShadow-thin,inset 0 0 0 max(1px, 0.0625rem)) var(--control-transparent-borderColor-active,var(--color-action-list-item-default-active-border));
}
.ActionListItem:not(.ActionListItem--hasSubItem):active .ActionListItem-label::before,
.ActionListItem.ActionListItem--hasSubItem > .ActionListContent:active .ActionListItem-label::before,
.ActionListItem:not(.ActionListItem--hasSubItem):active + .ActionListItem .ActionListItem-label::before,
.ActionListItem.ActionListItem--hasSubItem > .ActionListContent:active + .ActionListItem .ActionListItem-label::before {
visibility: hidden;
}
/* Autocomplete [aria-selected] items */
.ActionListItem[aria-selected='true'] {
font-weight: var(--base-text-weight-normal,400);
background: var(--control-transparent-bgColor-selected,var(--color-action-list-item-default-selected-bg));
}
@media (hover: hover) {
.ActionListItem[aria-selected='true']:hover {
background-color: var(--control-transparent-bgColor-hover,var(--color-action-list-item-default-hover-bg));
}
}
.ActionListItem[aria-selected='true']::before,
.ActionListItem[aria-selected='true'] + .ActionListItem::before {
visibility: hidden;
}
/* blue accent line */
.ActionListItem[aria-selected='true']::after {
position: absolute;
top: calc(50% - 12px);
left: calc(-1 * var(--base-size-4,0.25rem));
width: var(--base-size-4,0.25rem);
height: var(--base-size-24,1.5rem);
content: '';
background: var(--borderColor-accent-emphasis,var(--color-accent-emphasis));
border-radius: var(--borderRadius-medium,0.375rem);
}
/* active state [aria-current] */
.ActionListItem.ActionListItem--navActive {
/* provides a visual indication of the current item for Windows high-contrast mode */
outline: 2px solid transparent;
}
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--subItem) .ActionListItem-label {
font-weight: var(--base-text-weight-semibold,600);
}
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--danger) {
background: var(--control-transparent-bgColor-selected,var(--color-action-list-item-default-selected-bg));
}
@media (hover: hover) {
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--danger):hover {
background-color: var(--control-transparent-bgColor-hover,var(--color-action-list-item-default-hover-bg));
}
}
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--danger)::before,
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--danger) + .ActionListItem::before {
visibility: hidden;
}
/* blue accent line */
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--danger)::after {
position: absolute;
top: calc(50% - 12px);
left: calc(-1 * var(--base-size-8,0.5rem));
width: var(--base-size-4,0.25rem);
height: var(--base-size-24,1.5rem);
content: '';
background: var(--borderColor-accent-emphasis,var(--color-accent-emphasis));
border-radius: var(--borderRadius-medium,0.375rem);
}
/* disabled */
.ActionListItem.ActionListItem--disabled .ActionListContent .ActionListItem-label,
.ActionListItem[aria-disabled='true'] .ActionListContent .ActionListItem-label,
.ActionListItem.ActionListItem--disabled .ActionListContent .ActionListItem-description,
.ActionListItem[aria-disabled='true'] .ActionListContent .ActionListItem-description {
color: var(--control-fgColor-disabled,var(--color-primer-fg-disabled));
}
.ActionListItem.ActionListItem--disabled .ActionListContent .ActionListItem-visual, .ActionListItem[aria-disabled='true'] .ActionListContent .ActionListItem-visual {
fill: var(--control-fgColor-disabled,var(--color-primer-fg-disabled));
}
@media (hover: hover) {
.ActionListItem.ActionListItem--disabled:hover, .ActionListItem[aria-disabled='true']:hover {
cursor: not-allowed;
background-color: transparent;
}
}
/* variants */
/* danger */
.ActionListItem.ActionListItem--danger .ActionListItem-label {
color: var(--control-danger-fgColor-rest,var(--color-danger-fg));
}
.ActionListItem.ActionListItem--danger .ActionListItem-visual {
color: var(--control-danger-fgColor-rest,var(--color-danger-fg));
}
@media (hover: hover) {
.ActionListItem.ActionListItem--danger:hover {
background: var(--control-danger-bgColor-hover,var(--color-action-list-item-danger-hover-bg));
}
.ActionListItem.ActionListItem--danger:hover .ActionListItem-label,
.ActionListItem.ActionListItem--danger:hover .ActionListItem-visual,
.ActionListItem.ActionListItem--danger:hover .ActionListItem-description {
color: var(--control-danger-fgColor-hover,var(--color-action-list-item-danger-hover-text));
}
}
.ActionListItem.ActionListItem--danger .ActionListContent:active {
background: var(--control-danger-bgColor-active,var(--color-action-list-item-danger-active-bg));
}
.ActionListItem.ActionListItem--danger .ActionListContent:active .ActionListItem-label,
.ActionListItem.ActionListItem--danger .ActionListContent:active .ActionListItem-visual,
.ActionListItem.ActionListItem--danger .ActionListContent:active .ActionListItem-description {
color: var(--control-danger-fgColor-hover,var(--color-action-list-item-danger-hover-text));
}
/* button or a href */
.ActionListContent {
position: relative;
display: grid;
width: 100%;
padding-block: var(--actionListContent-paddingBlock);
padding-inline: var(--control-medium-paddingInline-condensed,0.5rem);
color: var(--control-fgColor-rest,var(--color-fg-default));
text-align: left;
-webkit-user-select: none;
user-select: none;
background-color: transparent;
border: none;
border-radius: var(--borderRadius-medium,0.375rem);
transition: background 33.333ms linear;
touch-action: manipulation;
-webkit-tap-highlight-color: transparent;
grid-template-rows: min-content;
grid-template-areas: 'leadingAction leadingVisual label trailingVisual trailingAction';
grid-template-columns: min-content min-content minmax(0, auto) min-content min-content;
align-items: start;
/* column-gap persists with empty grid-areas, margin applies only when children exist */
}
.ActionListContent > :not(:last-child) {
margin-right: var(--control-medium-gap,0.5rem);
}
/* state */
.ActionListContent:hover {
-webkit-text-decoration: none;
text-decoration: none;
}
/* disabled */
.ActionListContent[aria-disabled='true'] .ActionListItem-label,
.ActionListContent[aria-disabled='true'] .ActionListItem-description {
color: var(--control-fgColor-disabled,var(--color-primer-fg-disabled));
}
.ActionListContent[aria-disabled='true'] .ActionListItem-visual {
fill: var(--control-fgColor-disabled,var(--color-primer-fg-disabled));
}
@media (hover: hover) {
.ActionListContent[aria-disabled='true']:hover {
cursor: not-allowed;
background-color: transparent;
}
}
/* collapsible item [aria-expanded] */
/* nesting (single level)
target items inside expanded subgroups */
@media screen and (prefers-reduced-motion: no-preference) {
.ActionListContent[aria-expanded] + .ActionList--subGroup {
transition:
opacity 160ms cubic-bezier(0.25, 1, 0.5, 1),
transform 160ms cubic-bezier(0.25, 1, 0.5, 1);
}
}
.ActionListContent[aria-expanded] + .ActionList--subGroup .ActionListContent {
padding-left: var(--base-size-24,1.5rem);
}
/* has 16px leading visual */
.ActionListContent.ActionListContent--visual16[aria-expanded] + .ActionList--subGroup .ActionListContent {
padding-left: var(--base-size-32,2rem);
}
/* has 20px leading visual */
.ActionListContent.ActionListContent--visual20[aria-expanded] + .ActionList--subGroup .ActionListContent {
padding-left: var(--base-size-36,2.25rem);
}
/* has 24px leading visual */
.ActionListContent.ActionListContent--visual24[aria-expanded] + .ActionList--subGroup .ActionListContent {
padding-left: var(--base-size-40,2.5rem);
}
.ActionListContent[aria-expanded='true'] .ActionListItem-collapseIcon {
transition: transform 120ms linear;
transform: scaleY(-1);
}
.ActionListContent[aria-expanded='true'] + .ActionList--subGroup {
height: auto;
overflow: visible;
visibility: visible;
opacity: 1;
transform: translateY(0);
}
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='true'] > .ActionListItem-label {
font-weight: var(--base-text-weight-semibold,600);
}
.ActionListContent[aria-expanded='false'] .ActionListItem-collapseIcon {
transition: transform 120ms linear;
transform: scaleY(1);
}
.ActionListContent[aria-expanded='false'] + .ActionList--subGroup {
height: 0;
overflow: hidden;
visibility: hidden;
opacity: 0;
transform: translateY(calc(-1 * var(--base-size-16,1rem)));
}
/* show active indicator on parent collapse if child is active */
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='false'] {
background: var(--control-transparent-bgColor-selected,var(--color-action-list-item-default-selected-bg));
}
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='false'] .ActionListItem-label {
font-weight: var(--base-text-weight-semibold,600);
}
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='false']::before,
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='false'] + .ActionListItem::before {
visibility: hidden;
}
/* blue accent line */
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='false']::after {
position: absolute;
top: calc(50% - 12px);
left: calc(-1 * var(--base-size-8,0.5rem));
width: var(--base-size-4,0.25rem);
height: var(--base-size-24,1.5rem);
content: '';
background: var(--borderColor-accent-emphasis,var(--color-accent-emphasis));
border-radius: var(--borderRadius-medium,0.375rem);
}
/*
* checkbox item [aria-checked]
* listbox [aria-selected]
*/
/* multiselect checkmark */
.ActionListContent[aria-checked='true'] .ActionListItem-multiSelectCheckmark, .ActionListContent[aria-selected='true'] .ActionListItem-multiSelectCheckmark {
visibility: visible;
opacity: 1;
transition:
visibility 0 linear 0,
opacity 50ms;
}
/* singleselect checkmark */
.ActionListContent[aria-checked='true'] .ActionListItem-singleSelectCheckmark, .ActionListContent[aria-selected='true'] .ActionListItem-singleSelectCheckmark {
visibility: visible;
}
/* checkbox */
.ActionListContent[aria-checked='true'] .ActionListItem-multiSelectIcon .ActionListItem-multiSelectIconRect, .ActionListContent[aria-selected='true'] .ActionListItem-multiSelectIcon .ActionListItem-multiSelectIconRect {
fill: var(--control-checked-bgColor-rest,var(--color-switch-track-checked-bg));
stroke: var(--control-checked-bgColor-rest,var(--color-switch-track-checked-bg));
stroke-width: var(--borderWidth-thin, 1px);
}
.ActionListContent[aria-checked='true'] .ActionListItem-multiSelectIcon .ActionListItem-multiSelectCheckmark, .ActionListContent[aria-selected='true'] .ActionListItem-multiSelectIcon .ActionListItem-multiSelectCheckmark {
fill: var(--fgColor-onEmphasis,var(--color-fg-on-emphasis));
}
/* multiselect checkmark */
.ActionListContent[aria-checked='false'] .ActionListItem-multiSelectCheckmark, .ActionListContent[aria-selected='false'] .ActionListItem-multiSelectCheckmark {
visibility: hidden;
opacity: 0;
transition:
visibility 0 linear 50ms,
opacity 50ms;
}
/* singleselect checkmark */
.ActionListContent[aria-checked='false'] .ActionListItem-singleSelectCheckmark, .ActionListContent[aria-selected='false'] .ActionListItem-singleSelectCheckmark {
visibility: hidden;
transition: visibility 0s linear 200ms;
}
/* checkbox */
.ActionListContent[aria-checked='false'] .ActionListItem-multiSelectIcon .ActionListItem-multiSelectIconRect, .ActionListContent[aria-selected='false'] .ActionListItem-multiSelectIcon .ActionListItem-multiSelectIconRect {
fill: var(--bgColor-default,var(--color-canvas-default));
stroke: var(--control-borderColor-rest,var(--color-btn-border));
stroke-width: var(--borderWidth-thin, 1px);
}
.ActionListContent[aria-checked='false'] .ActionListItem-multiSelectIconRect, .ActionListContent[aria-selected='false'] .ActionListItem-multiSelectIconRect {
fill: var(--bgColor-default,var(--color-canvas-default));
border: var(--borderWidth-thin, 1px) solid var(--control-borderColor-rest,var(--color-btn-border));
}
/* sizes */
.ActionListContent.ActionListContent--sizeLarge {
--actionListContent-paddingBlock: var(--control-large-paddingBlock,0.625rem);
}
.ActionListContent.ActionListContent--sizeXLarge {
--actionListContent-paddingBlock: var(--control-xlarge-paddingBlock,0.875rem);
}
/* On pointer:coarse (mobile), all list items are large */
@media (pointer: coarse) {
.ActionListContent {
--actionListContent-paddingBlock: var(--control-large-paddingBlock,0.625rem);
}
}
/* if leading/trailing visual, align with first line of content */
.ActionListContent.ActionListContent--blockDescription .ActionListItem-visual {
place-self: start;
}
/* place children on grid */
.ActionListItem-action--leading {
grid-area: leadingAction;
}
.ActionListItem-visual--leading {
grid-area: leadingVisual;
}
.ActionListItem-visual--trailing {
grid-area: trailingVisual;
}
.ActionListItem-action--trailing {
grid-area: trailingAction;
}
/* have leading visual svg filled with chosen color */
.ActionListItem-visual--leading svg {
fill: currentcolor;
}
/* wrapper span
default block */
.ActionListItem-descriptionWrap {
grid-area: label;
display: flex;
flex-direction: column;
gap: var(--base-size-4,0.25rem);
}
.ActionListItem-descriptionWrap .ActionListItem-label {
font-weight: var(--base-text-weight-semibold,600);
}
/* inline */
.ActionListItem-descriptionWrap--inline {
position: relative;
flex-direction: row;
align-items: baseline;
gap: var(--base-size-8,0.5rem);
}
/* description */
.ActionListItem-description {
font-size: var(--text-body-size-small,0.75rem);
font-weight: var(--base-text-weight-normal,400);
line-height: var(--text-body-lineHeight-small,1.6666);
color: var(--fgColor-muted,var(--color-fg-muted));
}
/* helper for grid alignment with multi-line content
span wrapping svg or text */
.ActionListItem-visual,
.ActionListItem-action {
display: flex;
min-height: var(--control-medium-lineBoxHeight,1.25rem);
color: var(--fgColor-muted,var(--color-fg-muted));
pointer-events: none;
fill: var(--fgColor-muted,var(--color-fg-muted));
align-items: center;
}
/* text */
.ActionListItem-label {
position: relative;
font-size: var(--text-body-size-medium,0.875rem);
font-weight: var(--base-text-weight-normal,400);
line-height: var(--text-body-lineHeight-medium,1.4285);
color: var(--fgColor-default,var(--color-fg-default));
grid-area: label;
}
.ActionListItem-label--truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* nested lists (only supports 1 level currently)
target ActionListItem--subItem for padding-left to maintain :active :after state */
.ActionListItem--subItem > .ActionListContent > .ActionListItem-label {
font-size: var(--text-body-size-small,0.75rem);
line-height: var(--text-body-lineHeight-small,1.6666);
}
/* trailing action icon button */
.ActionListItem--withActions {
display: flex;
flex-wrap: nowrap;
align-items: center;
}
.ActionListItem-trailingAction {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
/* show trailing action button on hover */
.ActionListItem--trailingActionHover .ActionListItem-trailingAction {
visibility: hidden;
}
.ActionListItem--trailingActionHover:hover .ActionListItem-trailingAction, .ActionListItem--trailingActionHover:focus-within .ActionListItem-trailingAction {
visibility: visible;
}
/* ActionList::Divider */
/* with children */
.ActionList-sectionDivider:not(:empty) {
display: flex;
padding-inline: var(--actionListContent-paddingBlock);
padding-block: var(--base-size-8,0.5rem);
font-size: var(--text-body-size-small,0.75rem);
line-height: var(--text-body-lineHeight-small,1.6666);
font-weight: var(--base-text-weight-semibold,600);
color: var(--fgColor-muted,var(--color-fg-muted));
flex-direction: column;
}
/* no children */
.ActionList-sectionDivider:empty {
display: block;
height: var(--borderWidth-thin,max(1px, 0.0625rem));
padding: 0;
margin-block-start: calc(var(--base-size-8,0.5rem) - var(--borderWidth-thin,max(1px, 0.0625rem)));
margin-block-end: var(--base-size-8,0.5rem);
margin-inline: calc(-1 * var(--base-size-8,0.5rem));
list-style: none;
background: var(--borderColor-muted, var(--color-action-list-item-inline-divider));
border: 0;
}
.ActionList-sectionDivider .ActionList-sectionDivider-title {
font-size: var(--text-body-size-small,0.75rem);
font-weight: var(--base-text-weight-semibold,600);
color: var(--fgColor-muted,var(--color-fg-muted));
}
.ActionList-sectionDivider--filled {
margin-block-start: calc(var(--base-size-8,0.5rem) - var(--borderWidth-thin,max(1px, 0.0625rem)));
margin-block-end: var(--base-size-8,0.5rem);
margin-inline: calc(-1 * var(--base-size-8,0.5rem));
background: var(--bgColor-muted,var(--color-canvas-subtle));
border-top: solid var(--borderWidth-thin,max(1px, 0.0625rem)) var(--borderColor-muted, var(--color-action-list-item-inline-divider));
border-bottom: solid var(--borderWidth-thin,max(1px, 0.0625rem)) var(--borderColor-muted, var(--color-action-list-item-inline-divider));
/* if no children, treat as divider */
}
.ActionList-sectionDivider--filled:empty {
height: var(--base-size-8,0.5rem);
box-sizing: border-box;
}
.ActionList-sectionDivider--filled:first-child {
margin-block-start: 0;
}

app/components/primer/alpha/action_list.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {controller} from '@github/catalyst'
// eslint-disable-next-line custom-elements/no-exports-with-element
export class ActionListTruncationObserver {
resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
const action = entry.target
if (action instanceof HTMLElement) {
this.update(action)
}
}
})
constructor(el: HTMLElement) {
this.resizeObserver.observe(el)
}
unobserve(el: HTMLElement) {
this.resizeObserver.unobserve(el)
}
update(el: HTMLElement) {
const label = el.querySelector('.ActionListItem-label')
if (!label) return
const tooltip = el.querySelector('.ActionListItem-truncationTooltip') as HTMLElement | null
if (!tooltip) return
const isTruncated = label.scrollWidth > label.clientWidth
if (isTruncated) {
tooltip.style.display = ''
} else {
tooltip.style.display = 'none'
}
}
}
@controller
// eslint-disable-next-line custom-elements/expose-class-on-global
export class ActionListElement extends HTMLElement {
#truncationObserver: ActionListTruncationObserver
connectedCallback() {
this.#truncationObserver = new ActionListTruncationObserver(this)
}
disconnectedCallback() {
this.#truncationObserver.unobserve(this)
}
}
declare global {
interface Window {
ActionListElement: typeof ActionListElement
}
}