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
<action-list>
<div data-view-component="true">
<ul aria-label="List heading" id="action-list-70ca220d-1473-447e-b79b-232d556555e4" role="list" data-view-component="true" class="ActionListWrap">
<li data-targets="action-list.items" data-view-component="true" class="ActionListItem">
<tool-tip id="tooltip-dfa05ba2-11d1-4b52-ae02-3459a67a0ed6" for="item-2f11dfdc-13fc-4d85-bc53-5907c4a473c2" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">this is a tooltip</tool-tip>
<button id="item-2f11dfdc-13fc-4d85-bc53-5907c4a473c2" type="button" data-view-component="true" class="ActionListContent">
<span data-view-component="true" class="ActionListItem-label">
Really really long label that may wrap, truncate, or appear as a tooltip
</span></button>
</li>
<li data-targets="action-list.items" data-view-component="true" class="ActionListItem">
<tool-tip id="tooltip-82ba427b-6167-4dd8-8ec3-3e3845cedd52" for="item-5f21bd5d-359b-4cf0-9b04-42ef506a54ff" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">this is a tooltip</tool-tip>
<button id="item-5f21bd5d-359b-4cf0-9b04-42ef506a54ff" type="button" data-view-component="true" class="ActionListContent">
<span data-view-component="true" class="ActionListItem-label">
Really really long label that may wrap, truncate, or appear as a tooltip
</span></button>
</li>
</ul>
</div>
</action-list>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
render(Primer::Alpha::ActionList.new(aria: { label: "List heading" })) do |component|
component.with_item(
label: "Really really long label that may wrap, truncate, or appear as a tooltip",
truncate_label: truncate_label
) do |item|
item.with_tooltip(text: "this is a tooltip")
end
component.with_item(
label: "Really really long label that may wrap, truncate, or appear as a tooltip",
truncate_label: truncate_label
) do |item|
item.with_tooltip(text: "this is a tooltip")
end
end

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);
}
/* ActionList */
action-list {
display: block;
}
nav-list {
display: block;
}
.ActionListHeader {
margin-left: var(--base-size-8);
margin-bottom: var(--base-size-16);
}
/* <ul> */
.ActionListWrap {
list-style: none;
}
.ActionListWrap--inset,
.ActionListWrap--inset[popover] {
padding: var(--base-size-8);
}
/* 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);
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);
border-radius: var(--borderRadius-medium);
/* 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);
}
}
.ActionListItem.ActionListItem--hasSubItem > .ActionListContent:active {
background-color: var(--control-transparent-bgColor-active);
}
/* 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);
}
.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) transparent;
outline-offset: calc(-1 * var(--borderWidth-thin));
box-shadow: var(--boxShadow-thin) var(--control-transparent-borderColor-active);
}
}
.ActionListItem:not(.ActionListItem--hasSubItem):active, .ActionListItem.ActionListItem--hasSubItem > .ActionListContent:active {
background: var(--control-transparent-bgColor-active);
}
.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) transparent;
outline-offset: calc(-1 * var(--borderWidth-thin));
box-shadow: var(--boxShadow-thin) var(--control-transparent-borderColor-active);
}
.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);
background: var(--control-transparent-bgColor-selected);
}
@media (hover: hover) {
.ActionListItem[aria-selected='true']:hover {
background-color: var(--control-transparent-bgColor-hover);
}
}
.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));
width: var(--base-size-4);
height: var(--base-size-24);
content: '';
background: var(--borderColor-accent-emphasis);
border-radius: var(--borderRadius-medium);
}
/* 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);
}
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--danger) {
background: var(--control-transparent-bgColor-selected);
}
@media (hover: hover) {
.ActionListItem.ActionListItem--navActive:not(.ActionListItem--danger):hover {
background-color: var(--control-transparent-bgColor-hover);
}
}
.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));
width: var(--base-size-4);
height: var(--base-size-24);
content: '';
background: var(--borderColor-accent-emphasis);
border-radius: var(--borderRadius-medium);
}
/* 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);
}
.ActionListItem.ActionListItem--disabled .ActionListContent .ActionListItem-visual, .ActionListItem[aria-disabled='true'] .ActionListContent .ActionListItem-visual {
fill: var(--control-fgColor-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);
}
.ActionListItem.ActionListItem--danger .ActionListItem-visual {
color: var(--control-danger-fgColor-rest);
}
@media (hover: hover) {
.ActionListItem.ActionListItem--danger:hover {
background: var(--control-danger-bgColor-hover);
}
.ActionListItem.ActionListItem--danger:hover .ActionListItem-label,
.ActionListItem.ActionListItem--danger:hover .ActionListItem-visual,
.ActionListItem.ActionListItem--danger:hover .ActionListItem-description {
color: var(--control-danger-fgColor-hover);
}
}
.ActionListItem.ActionListItem--danger .ActionListContent:active {
background: var(--control-danger-bgColor-active);
}
.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);
}
/* button or a href */
.ActionListContent {
position: relative;
display: grid;
width: 100%;
padding-block: var(--actionListContent-paddingBlock);
padding-inline: var(--control-medium-paddingInline-condensed);
color: var(--control-fgColor-rest);
text-align: left;
-webkit-user-select: none;
user-select: none;
background-color: transparent;
border: none;
border-radius: var(--borderRadius-medium);
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);
}
/* 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);
}
.ActionListContent[aria-disabled='true'] .ActionListItem-visual {
fill: var(--control-fgColor-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);
}
/* has 16px leading visual */
.ActionListContent.ActionListContent--visual16[aria-expanded] + .ActionList--subGroup .ActionListContent {
padding-left: var(--base-size-32);
}
/* has 20px leading visual */
.ActionListContent.ActionListContent--visual20[aria-expanded] + .ActionList--subGroup .ActionListContent {
padding-left: var(--base-size-36);
}
/* has 24px leading visual */
.ActionListContent.ActionListContent--visual24[aria-expanded] + .ActionList--subGroup .ActionListContent {
padding-left: var(--base-size-40);
}
.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);
}
.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)));
}
/* show active indicator on parent collapse if child is active */
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='false'] {
background: var(--control-transparent-bgColor-selected);
}
.ActionListContent.ActionListContent--hasActiveSubItem[aria-expanded='false'] .ActionListItem-label {
font-weight: var(--base-text-weight-semibold);
}
.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));
width: var(--base-size-4);
height: var(--base-size-24);
content: '';
background: var(--borderColor-accent-emphasis);
border-radius: var(--borderRadius-medium);
}
/*
* 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);
stroke: var(--control-checked-bgColor-rest);
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);
}
/* 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);
stroke: var(--control-borderColor-rest);
stroke-width: var(--borderWidth-thin, 1px);
}
.ActionListContent[aria-checked='false'] .ActionListItem-multiSelectIconRect, .ActionListContent[aria-selected='false'] .ActionListItem-multiSelectIconRect {
fill: var(--bgColor-default);
border: var(--borderWidth-thin, 1px) solid var(--control-borderColor-rest);
}
/* sizes */
.ActionListContent.ActionListContent--sizeLarge {
--actionListContent-paddingBlock: var(--control-large-paddingBlock);
}
.ActionListContent.ActionListContent--sizeXLarge {
--actionListContent-paddingBlock: var(--control-xlarge-paddingBlock);
}
/* On pointer:coarse (mobile), all list items are large */
@media (pointer: coarse) {
.ActionListContent {
--actionListContent-paddingBlock: var(--control-large-paddingBlock);
}
}
/* 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);
}
.ActionListItem-descriptionWrap .ActionListItem-label {
font-weight: var(--base-text-weight-semibold);
}
/* inline */
.ActionListItem-descriptionWrap--inline {
position: relative;
flex-direction: row;
align-items: baseline;
gap: var(--base-size-8);
}
/* description */
.ActionListItem-description {
font-size: var(--text-body-size-small);
font-weight: var(--base-text-weight-normal);
line-height: var(--text-body-lineHeight-small);
color: var(--fgColor-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);
color: var(--fgColor-muted);
pointer-events: none;
fill: var(--fgColor-muted);
align-items: center;
}
/* text */
.ActionListItem-label {
position: relative;
font-size: var(--text-body-size-medium);
font-weight: var(--base-text-weight-normal);
line-height: var(--text-body-lineHeight-medium);
color: var(--fgColor-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);
line-height: var(--text-body-lineHeight-small);
}
/* 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);
font-size: var(--text-body-size-small);
line-height: var(--text-body-lineHeight-small);
font-weight: var(--base-text-weight-semibold);
color: var(--fgColor-muted);
flex-direction: column;
}
/* no children */
.ActionList-sectionDivider:empty {
display: block;
height: var(--borderWidth-thin);
padding: 0;
margin-block-start: calc(var(--base-size-8) - var(--borderWidth-thin));
margin-block-end: var(--base-size-8);
margin-inline: calc(-1 * var(--base-size-8));
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);
font-weight: var(--base-text-weight-semibold);
color: var(--fgColor-muted);
}
.ActionList-sectionDivider--filled {
margin-block-start: calc(var(--base-size-8) - var(--borderWidth-thin));
margin-block-end: var(--base-size-8);
margin-inline: calc(-1 * var(--base-size-8));
background: var(--bgColor-muted);
border-top: solid var(--borderWidth-thin) var(--borderColor-muted, var(--color-action-list-item-inline-divider));
border-bottom: solid var(--borderWidth-thin) 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);
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
59
60
61
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 items = el.querySelectorAll('li')
for (const item of items) {
const label = item.querySelector('.ActionListItem-label') as HTMLElement
if (!label) continue
const tooltip = item.querySelector('.ActionListItem-truncationTooltip') as HTMLElement
if (!tooltip) continue
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
}
}