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
45
46
47
<action-list> <div data-view-component="true"> <div data-view-component="true" class="ActionList-sectionDivider"> <h3 id="heading-title-1584cdb6-df46-45cd-a621-053cecf0177e" data-view-component="true" class="ActionList-sectionDivider-title"> Action List </h3> </div> <ul id="action-list-3104a874-ef13-464d-8d83-7d96d304c968" role="list" aria-labelledby="heading-title-1584cdb6-df46-45cd-a621-053cecf0177e" data-view-component="true" class="ActionListWrap"> <li data-targets="action-list.items" data-view-component="true" class="ActionListItem"> <a id="item-1a3d44e5-2029-4314-a614-06b727b6af53" 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-9554d7d4-276d-4855-b2fe-ef7af51ef959" 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-71ed3f7f-5331-4c23-abcd-ed28b05a87b8" 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) endend
No notes provided.
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
/* stylelint-disable selector-max-compound-selectors *//* stylelint-disable selector-max-specificity *//* stylelint-disable max-nesting-depth */:root { --actionListContent-paddingBlock: var(--control-medium-paddingBlock);}/* ActionList *//* stylelint-disable-next-line selector-max-type */action-list { display: block;}/* stylelint-disable-next-line selector-max-type */nav-list { display: block;}.ActionListHeader { margin-bottom: var(--base-size-16); margin-left: var(--base-size-8);}/* <ul> */.ActionListWrap { list-style: none;}.ActionListWrap--inset,.ActionListWrap--inset[popover] { padding: var(--base-size-8);}/* list dividers */.ActionListWrap--divided .ActionListItem-label::before { position: absolute; /* stylelint-disable-next-line primer/spacing */ top: calc(-1 * var(--actionListContent-paddingBlock)); display: block; width: 100%; height: 1px; content: ''; /* stylelint-disable-next-line primer/colors */ background: var(--borderColor-muted); }/* if descriptionWrap--inline exists, move pseudo divider to wrapper */:is(.ActionListWrap--divided .ActionListItem-descriptionWrap--inline)::before { position: absolute; /* stylelint-disable-next-line primer/spacing */ top: calc(-1 * var(--actionListContent-paddingBlock)); display: block; width: 100%; height: var(--borderWidth-thin); content: ''; /* stylelint-disable-next-line primer/colors */ background: var(--borderColor-muted); }/* unset the default label pseudo */:is(.ActionListWrap--divided .ActionListItem-descriptionWrap--inline) .ActionListItem-label::before { content: unset; }/* hide divider if item is active */:is(.ActionListWrap--divided .ActionListItem--navActive) .ActionListItem-label::before,:is(.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) { :is(.ActionListItem.ActionListItem--hasSubItem > .ActionListContent):hover { background-color: var(--control-transparent-bgColor-hover); } }:is(.ActionListItem.ActionListItem--hasSubItem > .ActionListContent):active { background-color: var(--control-transparent-bgColor-active); }/* only hover li without list as children */@media (hover: hover) { :is(.ActionListItem:not(.ActionListItem--hasSubItem),.ActionListItem.ActionListItem--hasSubItem > .ActionListContent):hover { cursor: pointer; background-color: var(--control-transparent-bgColor-hover); } :is(.ActionListItem:not(.ActionListItem--hasSubItem),.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); } }:is(.ActionListItem:not(.ActionListItem--hasSubItem),.ActionListItem.ActionListItem--hasSubItem > .ActionListContent):active { background: var(--control-transparent-bgColor-active); }:is(.ActionListItem:not(.ActionListItem--hasSubItem),.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); }:is(.ActionListItem:not(.ActionListItem--hasSubItem),.ActionListItem.ActionListItem--hasSubItem > .ActionListContent):active .ActionListItem-label::before,:is(.ActionListItem:not(.ActionListItem--hasSubItem),.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 */:is(:is(.ActionListItem.ActionListItem--disabled,.ActionListItem[aria-disabled='true']) .ActionListContent) .ActionListItem-label,:is(:is(.ActionListItem.ActionListItem--disabled,.ActionListItem[aria-disabled='true']) .ActionListContent) .ActionListItem-description { color: var(--control-fgColor-disabled); }:is(:is(.ActionListItem.ActionListItem--disabled,.ActionListItem[aria-disabled='true']) .ActionListContent) .ActionListItem-visual { fill: var(--control-fgColor-disabled); }@media (hover: hover) { :is(.ActionListItem.ActionListItem--disabled,.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); } }:is(.ActionListItem.ActionListItem--danger .ActionListContent):active { background: var(--control-danger-bgColor-active); }:is(.ActionListItem.ActionListItem--danger .ActionListContent):active .ActionListItem-label,:is(.ActionListItem.ActionListItem--danger .ActionListContent):active .ActionListItem-visual,:is(.ActionListItem.ActionListItem--danger .ActionListContent):active .ActionListItem-description { color: var(--control-danger-fgColor-hover); }/* button or a href */.ActionListContent { position: relative; display: grid; width: 100%; /* stylelint-disable-next-line primer/spacing */ padding-block: var(--actionListContent-paddingBlock); /* stylelint-disable-next-line primer/spacing */ 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) { /* stylelint-disable-next-line primer/spacing */ 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); } }:is(.ActionListContent[aria-expanded] + .ActionList--subGroup) .ActionListContent { padding-left: var(--base-size-24); }/* has 16px leading visual */:is(.ActionListContent.ActionListContent--visual16[aria-expanded] + .ActionList--subGroup) .ActionListContent { padding-left: var(--base-size-32); }/* has 20px leading visual */:is(.ActionListContent.ActionListContent--visual20[aria-expanded] + .ActionList--subGroup) .ActionListContent { padding-left: var(--base-size-36); }/* has 24px leading visual */:is(.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 */:is(.ActionListContent[aria-checked='true'],.ActionListContent[aria-selected='true']) .ActionListItem-multiSelectCheckmark { visibility: visible; opacity: 1; transition: visibility 0 linear 0, opacity 50ms; }/* singleselect checkmark */:is(.ActionListContent[aria-checked='true'],.ActionListContent[aria-selected='true']) .ActionListItem-singleSelectCheckmark { visibility: visible; }/* checkbox */:is(:is(.ActionListContent[aria-checked='true'],.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); }:is(:is(.ActionListContent[aria-checked='true'],.ActionListContent[aria-selected='true']) .ActionListItem-multiSelectIcon) .ActionListItem-multiSelectCheckmark { fill: var(--fgColor-onEmphasis); }/* multiselect checkmark */:is(.ActionListContent[aria-checked='false'],.ActionListContent[aria-selected='false']) .ActionListItem-multiSelectCheckmark { visibility: hidden; opacity: 0; transition: visibility 0 linear 50ms, opacity 50ms; }/* singleselect checkmark */:is(.ActionListContent[aria-checked='false'],.ActionListContent[aria-selected='false']) .ActionListItem-singleSelectCheckmark { visibility: hidden; transition: visibility 0s linear 200ms; }/* checkbox */:is(:is(.ActionListContent[aria-checked='false'],.ActionListContent[aria-selected='false']) .ActionListItem-multiSelectIcon) .ActionListItem-multiSelectIconRect { fill: var(--bgColor-default); stroke: var(--control-borderColor-rest); stroke-width: var(--borderWidth-thin, 1px); }:is(.ActionListContent[aria-checked='false'],.ActionListContent[aria-selected='false']) .ActionListItem-multiSelectIconRect { fill: var(--bgColor-default); border: var(--borderWidth-thin) 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 *//* stylelint-disable-next-line selector-max-type */.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; }:is(.ActionListItem--trailingActionHover:hover,.ActionListItem--trailingActionHover:focus-within) .ActionListItem-trailingAction { visibility: visible; }/* ActionList::Divider *//* with children */.ActionList-sectionDivider:not(:empty) { display: flex; font-size: var(--text-body-size-small); font-weight: var(--base-text-weight-semibold); line-height: var(--text-body-lineHeight-small); color: var(--fgColor-muted); flex-direction: column; /* stylelint-disable-next-line primer/spacing */ padding-inline: var(--actionListContent-paddingBlock); padding-block: var(--base-size-8); }/* no children */.ActionList-sectionDivider:empty { display: block; height: var(--borderWidth-thin); padding: 0; /* stylelint-disable-next-line primer/spacing */ 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; /* stylelint-disable-next-line primer/colors */ background: var(--borderColor-muted); 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); align-self: flex-start; }.ActionList-sectionDivider--filled { /* stylelint-disable-next-line primer/spacing */ 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-elementexport 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-globalexport class ActionListElement extends HTMLElement { #truncationObserver: ActionListTruncationObserver connectedCallback() { this.#truncationObserver = new ActionListTruncationObserver(this) } disconnectedCallback() { this.#truncationObserver.unobserve(this) }}declare global { interface Window { ActionListElement: typeof ActionListElement }}