primer_view_components 0.0.96 → 0.0.97

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/assets/styles/primer_view_components.css +1 -1
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_list/action-list-selection.pcss +92 -0
  8. data/app/components/primer/alpha/action_list/action-list.pcss +620 -0
  9. data/app/components/primer/alpha/action_list/divider.rb +35 -0
  10. data/app/components/primer/alpha/action_list/heading.html.erb +8 -0
  11. data/app/components/primer/alpha/action_list/heading.rb +38 -0
  12. data/app/components/primer/alpha/action_list/item.html.erb +39 -0
  13. data/app/components/primer/alpha/action_list/item.rb +230 -0
  14. data/app/components/primer/alpha/action_list.html.erb +15 -0
  15. data/app/components/primer/alpha/action_list.rb +112 -0
  16. data/app/components/primer/alpha/dialog/header.rb +1 -1
  17. data/app/components/primer/alpha/nav_list/item.html.erb +13 -0
  18. data/app/components/primer/alpha/nav_list/item.rb +89 -0
  19. data/app/components/primer/alpha/nav_list/section.html.erb +3 -0
  20. data/app/components/primer/alpha/nav_list/section.rb +88 -0
  21. data/app/components/primer/alpha/nav_list.d.ts +25 -0
  22. data/app/components/primer/alpha/nav_list.html.erb +10 -0
  23. data/app/components/primer/alpha/nav_list.js +130 -0
  24. data/app/components/primer/alpha/nav_list.rb +112 -0
  25. data/app/components/primer/alpha/nav_list.ts +129 -0
  26. data/app/components/primer/primer.d.ts +1 -0
  27. data/app/components/primer/primer.js +1 -0
  28. data/app/components/primer/primer.pcss +1 -0
  29. data/app/components/primer/primer.ts +1 -0
  30. data/lib/postcss_mixins/activeIndicatorLine.pcss +11 -0
  31. data/lib/primer/view_components/version.rb +1 -1
  32. data/lib/tasks/docs.rake +51 -22
  33. data/lib/yard/docs_helper.rb +3 -3
  34. data/static/arguments.json +267 -3
  35. data/static/audited_at.json +7 -0
  36. data/static/constants.json +76 -0
  37. data/static/statuses.json +7 -0
  38. metadata +21 -4
  39. data/app/components/primer/experimental/action_bar.d.ts +0 -14
  40. data/app/components/primer/experimental/action_bar.js +0 -141
@@ -0,0 +1,620 @@
1
+ :root {
2
+ --primer-actionListContent-paddingBlock: var(--primer-control-medium-paddingBlock, 6px);
3
+ }
4
+
5
+ /* ActionList */
6
+
7
+ /* <ul> */
8
+ .ActionListWrap {
9
+ list-style: none;
10
+ }
11
+
12
+ .ActionListWrap--inset {
13
+ padding: var(--base-size-8, 8px);
14
+ }
15
+
16
+ /* list dividers */
17
+
18
+ .ActionListWrap--divided {
19
+ & .ActionListItem-label::before {
20
+ position: absolute;
21
+ top: calc(-1 * var(--primer-actionListContent-paddingBlock));
22
+ display: block;
23
+ width: 100%;
24
+ height: 1px;
25
+ content: '';
26
+ background: var(--color-action-list-item-inline-divider);
27
+ }
28
+
29
+ /* if descriptionWrap--inline exists, move pseudo divider to wrapper */
30
+ & .ActionListItem-descriptionWrap--inline {
31
+ &::before {
32
+ position: absolute;
33
+ top: calc(-1 * var(--primer-actionListContent-paddingBlock));
34
+ display: block;
35
+ width: 100%;
36
+ height: var(--primer-borderWidth-thin, 1px);
37
+ content: '';
38
+ background: var(--color-action-list-item-inline-divider);
39
+ }
40
+
41
+ /* unset the default label pseudo */
42
+ & .ActionListItem-label::before {
43
+ content: unset;
44
+ }
45
+ }
46
+
47
+ /* hide divider if item is active */
48
+ & .ActionListItem--navActive {
49
+ & .ActionListItem-label::before,
50
+ + .ActionListItem .ActionListItem-label::before {
51
+ visibility: hidden;
52
+ }
53
+ }
54
+ }
55
+
56
+ /* hide if item is first of type with label::before, or is the first item after a sectionDivider */
57
+ .ActionListItem:first-of-type .ActionListItem-label::before,
58
+ .ActionList-sectionDivider + .ActionListItem .ActionListItem-label::before {
59
+ visibility: hidden;
60
+ }
61
+
62
+ /* hide if item is first of type with label::before, or is the first item after a sectionDivider */
63
+ .ActionListItem:first-of-type .ActionListItem-descriptionWrap--inline::before,
64
+ .ActionList-sectionDivider + .ActionListItem .ActionListItem-descriptionWrap--inline::before {
65
+ visibility: hidden;
66
+ }
67
+
68
+ /* ActionList::Item */
69
+
70
+ /* divider behavior */
71
+
72
+ .ActionListItem {
73
+ /* hide dividers */
74
+ @media (hover: hover) {
75
+ &:hover {
76
+ & .ActionListItem-label::before,
77
+ & + .ActionListItem .ActionListItem-label::before {
78
+ visibility: hidden;
79
+ }
80
+
81
+ & .ActionListItem-descriptionWrap--inline::before,
82
+ & + .ActionListItem .ActionListItem-descriptionWrap--inline::before {
83
+ visibility: hidden;
84
+ }
85
+ }
86
+ }
87
+
88
+ /* Make sure that the first visible item isn't a divider */
89
+ &[hidden] + .ActionList-sectionDivider {
90
+ display: none;
91
+ }
92
+ }
93
+
94
+ /* sub items */
95
+
96
+ .ActionListItem {
97
+ /* target contents of li if sub-item (li wraps item label + nested ul) */
98
+ /* collapse styles here */
99
+ &.ActionListItem--hasSubItem {
100
+ /* first child */
101
+ & > .ActionListContent {
102
+ z-index: 1;
103
+
104
+ @media (hover: hover) {
105
+ &:hover {
106
+ background-color: var(--color-action-list-item-default-hover-bg);
107
+ }
108
+ }
109
+
110
+ &:active {
111
+ background-color: var(--color-action-list-item-default-active-bg);
112
+ }
113
+ }
114
+ }
115
+ }
116
+
117
+ /* <li> */
118
+ .ActionListItem {
119
+ position: relative;
120
+ list-style: none;
121
+ background-color: transparent;
122
+ border-radius: var(--primer-borderRadius-medium, 6px);
123
+
124
+ /* state */
125
+
126
+ &:hover,
127
+ &:active {
128
+ cursor: pointer;
129
+ }
130
+
131
+ /* only hover li without list as children */
132
+ &:not(.ActionListItem--hasSubItem),
133
+ /* target contents of first child li if sub-item (li wraps item label + nested ul) */
134
+ &.ActionListItem--hasSubItem > .ActionListContent {
135
+ @media (hover: hover) {
136
+ &:hover {
137
+ cursor: pointer;
138
+ background-color: var(--color-action-list-item-default-hover-bg);
139
+
140
+ &:not(.ActionListItem--navActive):not(:focus-visible) {
141
+ /* Support for "Windows high contrast mode" */
142
+ outline: solid var(--primer-borderWidth-thin, 1px) transparent;
143
+ outline-offset: calc(-1 * var(--primer-borderWidth-thin, 1px));
144
+ box-shadow: var(--primer-borderInset-thin, 1px) var(--color-action-list-item-default-active-border);
145
+ }
146
+ }
147
+ }
148
+
149
+ &:active {
150
+ background: var(--color-action-list-item-default-active-bg);
151
+
152
+ &:not(.ActionListItem--navActive) {
153
+ /* Support for "Windows high contrast mode" https:sarahmhigley.com/writing/whcm-quick-tips/ */
154
+ outline: solid var(--primer-borderWidth-thin, 1px) transparent;
155
+ outline-offset: calc(-1 * var(--primer-borderWidth-thin, 1px));
156
+ box-shadow: var(--primer-borderInset-thin, 1px) var(--color-action-list-item-default-active-border);
157
+ }
158
+
159
+ @media screen and (prefers-reduced-motion: no-preference) {
160
+ animation: ActionListItem-active-bg 4s forwards cubic-bezier(0.33, 1, 0.68, 1);
161
+ }
162
+
163
+ @keyframes ActionListItem-active-bg {
164
+ 50% {
165
+ box-shadow: inset 0 2px 12px 6px rgba(var(--color-canvas-default), 0.4);
166
+ transform: scale(1);
167
+ }
168
+
169
+ 100% {
170
+ transform: scale(0.97);
171
+ }
172
+ }
173
+ }
174
+
175
+ &:active {
176
+ & .ActionListItem-label::before,
177
+ & + .ActionListItem .ActionListItem-label::before {
178
+ visibility: hidden;
179
+ }
180
+ }
181
+ }
182
+
183
+ /* Autocomplete [aria-selected] items */
184
+
185
+ &[aria-selected='true'] {
186
+ font-weight: var(--base-text-weight-normal, 400);
187
+ background: var(--color-action-list-item-default-selected-bg);
188
+
189
+ @media (hover: hover) {
190
+ &:hover {
191
+ background-color: var(--color-action-list-item-default-hover-bg);
192
+ }
193
+ }
194
+
195
+ &::before,
196
+ & + .ActionListItem::before {
197
+ visibility: hidden;
198
+ }
199
+
200
+ /* blue accent line
201
+ &::after {
202
+ @include activeIndicatorLine(-$spacer-1);
203
+ @mixin activeIndicatorLine
204
+ } */
205
+ }
206
+
207
+ /* active state [aria-current] */
208
+
209
+ &.ActionListItem--navActive {
210
+ &:not(.ActionListItem--subItem) {
211
+ .ActionListItem-label {
212
+ font-weight: var(--base-text-weight-semibold, 600);
213
+ }
214
+ }
215
+
216
+ &:not(.ActionListItem--danger) {
217
+ background: var(--color-action-list-item-default-selected-bg);
218
+
219
+ @media (hover: hover) {
220
+ &:hover {
221
+ background-color: var(--color-action-list-item-default-hover-bg);
222
+ }
223
+ }
224
+
225
+ &::before,
226
+ & + .ActionListItem::before {
227
+ visibility: hidden;
228
+ }
229
+
230
+ /* blue accent line */
231
+ &::after {
232
+ @mixin activeIndicatorLine;
233
+ }
234
+ }
235
+ }
236
+
237
+ /* disabled */
238
+
239
+ &[aria-disabled='true'] {
240
+ & .ActionListContent {
241
+ & .ActionListItem-label,
242
+ & .ActionListItem-description {
243
+ color: var(--color-primer-fg-disabled);
244
+ }
245
+
246
+ & .ActionListItem-visual {
247
+ fill: var(--color-primer-fg-disabled);
248
+ }
249
+ }
250
+
251
+ @media (hover: hover) {
252
+ &:hover {
253
+ cursor: not-allowed;
254
+ background-color: transparent;
255
+ }
256
+ }
257
+ }
258
+
259
+ /* variants */
260
+
261
+ /* danger */
262
+ &.ActionListItem--danger {
263
+ & .ActionListItem-label {
264
+ color: var(--color-danger-fg);
265
+ }
266
+
267
+ & .ActionListItem-visual {
268
+ color: var(--color-danger-fg);
269
+ }
270
+
271
+ @media (hover: hover) {
272
+ &:hover {
273
+ background: var(--color-action-list-item-danger-hover-bg);
274
+
275
+ & .ActionListItem-label {
276
+ color: var(--color-action-list-item-danger-hover-text);
277
+ }
278
+ }
279
+ }
280
+
281
+ & .ActionListContent {
282
+ &:active {
283
+ background: var(--color-action-list-item-danger-active-bg);
284
+ }
285
+ }
286
+ }
287
+ }
288
+
289
+ /* button or a href */
290
+ .ActionListContent {
291
+ position: relative;
292
+ display: grid;
293
+ width: 100%;
294
+ padding-block: var(--primer-actionListContent-paddingBlock);
295
+ padding-inline: var(--primer-control-medium-paddingInline-condensed, 8px);
296
+ color: var(--color-fg-default);
297
+ text-align: left;
298
+ user-select: none;
299
+ background-color: transparent;
300
+ border: none;
301
+ border-radius: var(--primer-borderRadius-medium, 6px);
302
+ transition: background 33.333ms linear;
303
+ touch-action: manipulation;
304
+ -webkit-tap-highlight-color: transparent;
305
+ grid-template-rows: min-content;
306
+ grid-template-areas: 'leadingAction leadingVisual label trailingVisual trailingAction';
307
+ grid-template-columns: min-content min-content minmax(0, auto) min-content min-content;
308
+ align-items: start;
309
+
310
+ /* column-gap persists with empty grid-areas, margin applies only when children exist */
311
+ & > :not(:last-child) {
312
+ margin-right: var(--primer-control-medium-gap, 8px);
313
+ }
314
+
315
+ /* state */
316
+
317
+ &:hover {
318
+ text-decoration: none;
319
+ }
320
+
321
+ /* disabled */
322
+ &[aria-disabled='true'] {
323
+ & .ActionListItem-label,
324
+ & .ActionListItem-description {
325
+ color: var(--color-primer-fg-disabled);
326
+ }
327
+
328
+ & .ActionListItem-visual {
329
+ fill: var(--color-primer-fg-disabled);
330
+ }
331
+
332
+ @media (hover: hover) {
333
+ &:hover {
334
+ cursor: not-allowed;
335
+ background-color: transparent;
336
+ }
337
+ }
338
+ }
339
+
340
+ /* collapsible item [aria-expanded] */
341
+
342
+ /* nesting (single level)
343
+ target items inside expanded subgroups */
344
+ &[aria-expanded] {
345
+ & + .ActionList--subGroup {
346
+ @media screen and (prefers-reduced-motion: no-preference) {
347
+ transition: opacity 160ms cubic-bezier(0.25, 1, 0.5, 1), transform 160ms cubic-bezier(0.25, 1, 0.5, 1);
348
+ }
349
+
350
+ & .ActionListContent {
351
+ padding-left: var(--base-size-24, 24px);
352
+ }
353
+ }
354
+
355
+ /* has 16px leading visual */
356
+ &.ActionListContent--visual16 + .ActionList--subGroup {
357
+ & .ActionListContent {
358
+ padding-left: var(--base-size-32, 32px);
359
+ }
360
+ }
361
+
362
+ /* has 20px leading visual */
363
+ &.ActionListContent--visual20 + .ActionList--subGroup {
364
+ & .ActionListContent {
365
+ padding-left: var(--base-size-36, 36px);
366
+ }
367
+ }
368
+
369
+ /* has 24px leading visual */
370
+ &.ActionListContent--visual24 + .ActionList--subGroup {
371
+ & .ActionListContent {
372
+ padding-left: var(--base-size-40, 40px);
373
+ }
374
+ }
375
+ }
376
+
377
+ &[aria-expanded='true'] {
378
+ & .ActionListItem-collapseIcon {
379
+ transition: transform 120ms linear;
380
+ transform: scaleY(-1);
381
+ }
382
+
383
+ & + .ActionList--subGroup {
384
+ height: auto;
385
+ overflow: visible;
386
+ visibility: visible;
387
+ opacity: 1;
388
+ transform: translateY(0);
389
+ }
390
+
391
+ &.ActionListContent--hasActiveSubItem {
392
+ & > .ActionListItem-label {
393
+ font-weight: var(--base-text-weight-semibold, 600);
394
+ }
395
+ }
396
+ }
397
+
398
+ &[aria-expanded='false'] {
399
+ & .ActionListItem-collapseIcon {
400
+ transition: transform 120ms linear;
401
+ transform: scaleY(1);
402
+ }
403
+
404
+ & + .ActionList--subGroup {
405
+ height: 0;
406
+ overflow: hidden;
407
+ visibility: hidden;
408
+ opacity: 0;
409
+ transform: translateY(calc(-1 * var(--base-size-16, 16px)));
410
+ }
411
+
412
+ /* show active indicator on parent collapse if child is active */
413
+ &.ActionListContent--hasActiveSubItem {
414
+ background: var(--color-action-list-item-default-selected-bg);
415
+
416
+ & .ActionListItem-label {
417
+ font-weight: var(--base-text-weight-semibold, 600);
418
+ }
419
+
420
+ &::before,
421
+ + .ActionListItem::before {
422
+ visibility: hidden;
423
+ }
424
+
425
+ /* blue accent line */
426
+ &::after {
427
+ @mixin activeIndicatorLine;
428
+ }
429
+ }
430
+ }
431
+
432
+ /* sizes */
433
+
434
+ &.ActionListContent--sizeLarge {
435
+ --primer-actionListContent-paddingBlock: var(--primer-control-large-paddingBlock, calc((2.5rem - 1.25rem) / 2));
436
+ }
437
+
438
+ &.ActionListContent--sizeXLarge {
439
+ --primer-actionListContent-paddingBlock: var(--primer-control-xlarge-paddingBlock, calc((3rem - 1.25rem) / 2));
440
+ }
441
+
442
+ /* On pointer:coarse (mobile), all list items are large */
443
+ @media (pointer: coarse) {
444
+ --primer-actionListContent-paddingBlock: var(--primer-control-large-paddingBlock, calc((2.5rem - 1.25rem) / 2));
445
+ }
446
+
447
+ &.ActionListContent--blockDescription {
448
+ /* if leading/trailing visual, align with first line of content */
449
+ & .ActionListItem-visual {
450
+ place-self: start;
451
+ }
452
+ }
453
+ }
454
+
455
+ /* place children on grid */
456
+
457
+ .ActionListItem-action--leading {
458
+ grid-area: leadingAction;
459
+ }
460
+
461
+ .ActionListItem-visual--leading {
462
+ grid-area: leadingVisual;
463
+ }
464
+
465
+ .ActionListItem-label {
466
+ grid-area: label;
467
+ }
468
+
469
+ .ActionListItem-visual--trailing {
470
+ grid-area: trailingVisual;
471
+ }
472
+
473
+ .ActionListItem-action--trailing {
474
+ grid-area: trailingAction;
475
+ }
476
+
477
+ /* wrapper span
478
+ default block */
479
+ .ActionListItem-descriptionWrap {
480
+ grid-area: label;
481
+ display: flex;
482
+ flex-direction: column;
483
+ gap: var(--base-size-4, 4px);
484
+
485
+ & .ActionListItem-label {
486
+ font-weight: var(--base-text-weight-semibold, 600);
487
+ }
488
+ }
489
+
490
+ /* inline */
491
+ .ActionListItem-descriptionWrap--inline {
492
+ position: relative;
493
+ flex-direction: row;
494
+ align-items: baseline;
495
+ gap: var(--base-size-8, 8px);
496
+ }
497
+
498
+ /* description */
499
+ .ActionListItem-description {
500
+ font-size: var(--primer-text-body-size-small, 12px);
501
+ font-weight: var(--base-text-weight-normal, 400);
502
+ line-height: var(--primer-text-body-lineHeight-small, calc(20 / 12));
503
+ color: var(--color-fg-muted);
504
+ }
505
+
506
+ /* helper for grid alignment with multi-line content
507
+ span wrapping svg or text */
508
+ .ActionListItem-visual,
509
+ .ActionListItem-action {
510
+ display: flex;
511
+ min-height: var(--primer-control-medium-lineBoxHeight, 20px);
512
+ color: var(--color-fg-muted);
513
+ pointer-events: none;
514
+ fill: var(--color-fg-muted);
515
+ align-items: center;
516
+ }
517
+
518
+ /* text */
519
+ .ActionListItem-label {
520
+ position: relative;
521
+ font-size: var(--primer-text-body-size-medium, 14px);
522
+ font-weight: var(--base-text-weight-normal, 400);
523
+ line-height: var(--primer-text-body-lineHeight-medium, calc(20 / 14));
524
+ color: var(--color-fg-default);
525
+ }
526
+
527
+ .ActionListItem-label--truncate {
528
+ overflow: hidden;
529
+ text-overflow: ellipsis;
530
+ white-space: nowrap;
531
+ }
532
+
533
+ /* nested lists (only supports 1 level currently)
534
+ target ActionListItem--subItem for padding-left to maintain :active :after state */
535
+
536
+ .ActionListItem--subItem > .ActionListContent > .ActionListItem-label {
537
+ font-size: var(--primer-text-body-size-small, 12px);
538
+ }
539
+
540
+ /* trailing action icon button */
541
+
542
+ .ActionListItem--withActions {
543
+ display: flex;
544
+ flex-wrap: nowrap;
545
+ align-items: center;
546
+ }
547
+
548
+ .ActionListItem-trailingAction {
549
+ border-top-left-radius: 0;
550
+ border-bottom-left-radius: 0;
551
+ }
552
+
553
+ /* show trailing action button on hover */
554
+
555
+ .ActionListItem--trailingActionHover {
556
+ & .ActionListItem-trailingAction {
557
+ visibility: hidden;
558
+ }
559
+
560
+ &:hover,
561
+ &:focus-within {
562
+ & .ActionListItem-trailingAction {
563
+ visibility: visible;
564
+ }
565
+ }
566
+ }
567
+
568
+ /* ActionList::Divider */
569
+
570
+ .ActionList-sectionDivider {
571
+ /* with children */
572
+ &:not(:empty) {
573
+ display: flex;
574
+ padding: ($spacer-1 * 1.5) $spacer-2;
575
+ padding-inline: var(--primer-actionListContent-paddingBlock);
576
+ padding-block: var(--base-size-8, 8px);
577
+ font-size: var(--primer-text-body-size-small, 12px);
578
+ font-weight: var(--base-text-weight-semibold, 600);
579
+ color: var(--color-fg-muted);
580
+ flex-direction: column;
581
+ }
582
+
583
+ /* no children */
584
+ &:empty {
585
+ display: block;
586
+ height: var(--primer-borderWidth-thin, 1px);
587
+ padding: 0;
588
+ margin-block-start: calc(var(--base-size-8, 8px) - var(--primer-borderWidth-thin, 1px));
589
+ margin-block-end: var(--base-size-8, 8px);
590
+ margin-inline: calc(-1 * var(--base-size-8, 8px));
591
+ list-style: none;
592
+ background: var(--color-action-list-item-inline-divider);
593
+ border: 0;
594
+ }
595
+
596
+ .ActionList-sectionDivider-title {
597
+ font-size: var(--primer-text-body-size-small, 12px);
598
+ font-weight: var(--base-text-weight-semibold, 600);
599
+ color: var(--color-fg-muted);
600
+ }
601
+ }
602
+
603
+ .ActionList-sectionDivider--filled {
604
+ margin-block-start: calc(var(--base-size-8, 8px) - var(--primer-borderWidth-thin, 1px));
605
+ margin-block-end: var(--base-size-8, 8px);
606
+ margin-inline: calc(-1 * var(--base-size-8, 8px));
607
+ background: var(--color-canvas-subtle);
608
+ border-top: solid var(--primer-borderWidth-thin, 1px) var(--color-action-list-item-inline-divider);
609
+ border-bottom: solid var(--primer-borderWidth-thin, 1px) var(--color-action-list-item-inline-divider);
610
+
611
+ /* if no children, treat as divider */
612
+ &:empty {
613
+ height: var(--base-size-8, 8px);
614
+ box-sizing: border-box;
615
+ }
616
+
617
+ &:first-child {
618
+ margin-block-start: 0;
619
+ }
620
+ }
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ class ActionList
6
+ # Section heading rendered above the section contents.
7
+ class Divider < Primer::Component
8
+ DEFAULT_SCHEME = :subtle
9
+ SCHEME_MAPPINGS = {
10
+ DEFAULT_SCHEME => nil,
11
+ :filled => "ActionList-sectionDivider--filled"
12
+ }.freeze
13
+ SCHEME_OPTIONS = SCHEME_MAPPINGS.keys.freeze
14
+
15
+ # @param scheme [Symbol] Display a background color if scheme is `filled`.
16
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
17
+ def initialize(scheme: DEFAULT_SCHEME, **system_arguments)
18
+ @system_arguments = system_arguments
19
+ @system_arguments[:tag] = :li
20
+ @system_arguments[:role] = :separator
21
+ @system_arguments[:'aria-hidden'] = true
22
+ @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)
23
+ @system_arguments[:classes] = class_names(
24
+ "ActionList-sectionDivider",
25
+ SCHEME_MAPPINGS[@scheme]
26
+ )
27
+ end
28
+
29
+ def call
30
+ render(Primer::BaseComponent.new(**@system_arguments)) { "" }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,8 @@
1
+ <%= render(Primer::BaseComponent.new(**@system_arguments)) do %>
2
+ <%= render(Primer::BaseComponent.new(tag: @tag, classes: "ActionList-sectionDivider-title", id: @list_id)) do %>
3
+ <%= @title %>
4
+ <% end %>
5
+ <%= render Primer::ConditionalWrapper.new(condition: @subtitle.present?, tag: :span, classes: "ActionListItem-description") do %>
6
+ <%= @subtitle %>
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ class ActionList
6
+ # Heading used to describe each sub list within an action list.
7
+ class Heading < Primer::Component
8
+ DEFAULT_SCHEME = :subtle
9
+ SCHEME_MAPPINGS = {
10
+ DEFAULT_SCHEME => nil,
11
+ :filled => "ActionList-sectionDivider--filled"
12
+ }.freeze
13
+ SCHEME_OPTIONS = SCHEME_MAPPINGS.keys.freeze
14
+
15
+ # @param list_id [String] The unique identifier of the sub list the heading belongs to. Used internally.
16
+ # @param title [String] Sub list title.
17
+ # @param subtitle [String] Optional sub list description.
18
+ # @param scheme [Symbol] Display a background color if scheme is `filled`.
19
+ # @param tag [Symbol] Semantic tag for the heading.
20
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
21
+ def initialize(list_id:, title:, tag: :h3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments)
22
+ @tag = tag
23
+ @system_arguments = system_arguments
24
+ @list_id = list_id
25
+ @title = title
26
+ @subtitle = subtitle
27
+ @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)
28
+ @system_arguments[:tag] = :li
29
+ @system_arguments[:classes] = class_names(
30
+ "ActionList-sectionDivider",
31
+ SCHEME_MAPPINGS[@scheme],
32
+ @system_arguments[:classes]
33
+ )
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end