@solexllc/usx-react 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/index.cjs +231 -98
  2. package/dist/index.js +231 -98
  3. package/package.json +5 -5
  4. package/src/components/accordion/accordion.html +596 -291
  5. package/src/components/alert/alert.html +112 -148
  6. package/src/components/attribution/attribution.html +50 -21
  7. package/src/components/avatar/avatar.html +86 -51
  8. package/src/components/breadcrumb/breadcrumb.html +45 -66
  9. package/src/components/button/button.html +363 -226
  10. package/src/components/callout/Callout.tsx +1 -2
  11. package/src/components/callout/callout.django.html +2 -2
  12. package/src/components/callout/callout.html +0 -5
  13. package/src/components/callout/config.json +1 -5
  14. package/src/components/card/Card.tsx +6 -3
  15. package/src/components/card/card.django.html +2 -2
  16. package/src/components/card/card.html +1032 -35
  17. package/src/components/card/config.json +6 -2
  18. package/src/components/card-group/card-group.html +388 -95
  19. package/src/components/carousel/Carousel.tsx +42 -71
  20. package/src/components/carousel/carousel.django.html +22 -46
  21. package/src/components/carousel/carousel.html +715 -32
  22. package/src/components/carousel/config.json +25 -12
  23. package/src/components/character-count/character-count.html +231 -26
  24. package/src/components/checkbox/checkbox.html +313 -241
  25. package/src/components/checkbox-group/checkbox-group.html +346 -26
  26. package/src/components/clickable/clickable.html +168 -83
  27. package/src/components/code/Code.tsx +4 -3
  28. package/src/components/code/code.django.html +1 -1
  29. package/src/components/code/config.json +4 -0
  30. package/src/components/collection/collection.html +203 -379
  31. package/src/components/combobox/combobox.html +21 -9
  32. package/src/components/container/container.html +2616 -80
  33. package/src/components/copy-to-clipboard/copy-to-clipboard.html +48 -20
  34. package/src/components/details/Details.tsx +69 -0
  35. package/src/components/details/config.json +73 -0
  36. package/src/components/details/details.django.html +7 -0
  37. package/src/components/details/details.html +186 -0
  38. package/src/components/error-message/error-message.html +15 -2
  39. package/src/components/error-page/ErrorPage.tsx +169 -0
  40. package/src/components/error-page/config.json +152 -0
  41. package/src/components/error-page/error-page.django.html +80 -0
  42. package/src/components/error-page/error-page.html +437 -0
  43. package/src/components/eyebrow/eyebrow.html +8 -4
  44. package/src/components/fieldset/fieldset.html +33 -7
  45. package/src/components/file-input/file-input.html +310 -31
  46. package/src/components/file-list/file-list.html +191 -7
  47. package/src/components/footer/footer.html +611 -232
  48. package/src/components/header/header.html +2553 -611
  49. package/src/components/hero/hero.html +300 -38
  50. package/src/components/hint/hint.html +7 -2
  51. package/src/components/identifier/identifier.html +483 -255
  52. package/src/components/image/Image.tsx +2 -2
  53. package/src/components/image/image.django.html +4 -10
  54. package/src/components/image/image.html +144 -29
  55. package/src/components/indicator/indicator.html +25 -23
  56. package/src/components/label/label.html +15 -16
  57. package/src/components/language-selector/language-selector.html +74 -25
  58. package/src/components/layout/layout.html +991 -21
  59. package/src/components/legend/legend.html +10 -9
  60. package/src/components/list/list.html +45 -25
  61. package/src/components/page/Page.tsx +15 -2
  62. package/src/components/page/config.json +13 -1
  63. package/src/components/page/page.django.html +2 -2
  64. package/src/components/page/page.html +29 -8
  65. package/src/components/pagination/pagination.html +907 -305
  66. package/src/components/prose/prose.html +244 -85
  67. package/src/components/quote/Quote.tsx +1 -1
  68. package/src/components/quote/config.json +1 -2
  69. package/src/components/quote/quote.html +2 -7
  70. package/src/components/radio-buttons/radio-buttons.html +623 -127
  71. package/src/components/required/required.html +3 -4
  72. package/src/components/search/search.html +336 -54
  73. package/src/components/section/section.html +73 -11
  74. package/src/components/select/select.html +112 -58
  75. package/src/components/skipnav/skipnav.html +40 -1
  76. package/src/components/spinner/spinner.html +143 -23
  77. package/src/components/step-indicator/step-indicator.html +26 -68
  78. package/src/components/swap/swap.html +99 -154
  79. package/src/components/table/table.html +2168 -988
  80. package/src/components/tag/tag.html +73 -17
  81. package/src/components/task-list/task-list.html +252 -15
  82. package/src/components/theme-picker/theme-picker.html +26 -8
  83. package/src/components/toggle/toggle.html +64 -5
  84. package/src/index.js +2 -0
@@ -1,10 +1,13 @@
1
- <span id="example-text-to-copy">Example text to copy.</span></span>
1
+ <span id="example-text-to-copy">Example text to copy.</span>
2
2
 
3
3
  <h3 class="site-preview-heading">Copy to Clipboard</h3>
4
4
  <span class="usx-tooltip">
5
-
6
- <button class="usa-button usx-button usx-button--ghost usx-copy"
7
- onclick="navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)">
5
+ <button
6
+ class="usa-button usx-button usx-button--ghost usx-copy"
7
+ onclick="
8
+ navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)
9
+ "
10
+ >
8
11
  <svg class="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
9
12
  <use href="./img/sprite.svg#content_copy"></use>
10
13
  </svg>
@@ -12,15 +15,22 @@
12
15
  <use href="./img/sprite.svg#check"></use>
13
16
  </svg>
14
17
  </button>
15
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copy" role="tooltip">Copy to
16
- clipboard</span>
17
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip">Copied</span>
18
+ <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copy" role="tooltip"
19
+ >Copy to clipboard</span
20
+ >
21
+ <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip"
22
+ >Copied</span
23
+ >
18
24
  </span>
19
25
 
20
26
  <h3 class="site-preview-heading">With Text</h3>
21
27
  <span class="usx-tooltip">
22
- <button class="usa-button usx-button usx-button--ghost usx-copy"
23
- onclick="navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)">
28
+ <button
29
+ class="usa-button usx-button usx-button--ghost usx-copy"
30
+ onclick="
31
+ navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)
32
+ "
33
+ >
24
34
  <svg class="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
25
35
  <use href="./img/sprite.svg#content_copy"></use>
26
36
  </svg>
@@ -29,15 +39,21 @@
29
39
  </svg>
30
40
  <span class="margin-left-1">Copy</span>
31
41
  </button>
32
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip">Copied</span>
42
+ <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip"
43
+ >Copied</span
44
+ >
33
45
  </span>
34
46
 
35
47
  <h3 class="site-preview-heading">Dark Background</h3>
36
48
  <div class="bg-primary-darkest padding-2">
37
49
  <h3 class="site-preview-heading text-white">Default</h3>
38
50
  <span class="usx-tooltip">
39
- <button class="usa-button usx-button usx-button--ghost usx-copy usx-copy--dark"
40
- onclick="navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)">
51
+ <button
52
+ class="usa-button usx-button usx-button--ghost usx-copy usx-copy--dark"
53
+ onclick="
54
+ navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)
55
+ "
56
+ >
41
57
  <svg class="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
42
58
  <use href="./img/sprite.svg#content_copy"></use>
43
59
  </svg>
@@ -45,16 +61,24 @@
45
61
  <use href="./img/sprite.svg#check"></use>
46
62
  </svg>
47
63
  </button>
48
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copy" role="tooltip">Copy to
49
- clipboard</span>
50
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip">Copied</span>
64
+ <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copy" role="tooltip"
65
+ >Copy to clipboard</span
66
+ >
67
+ <span
68
+ class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied"
69
+ role="tooltip"
70
+ >Copied</span
71
+ >
51
72
  </span>
52
73
 
53
-
54
74
  <h3 class="site-preview-heading text-white">With Text</h3>
55
75
  <span class="usx-tooltip">
56
- <button class="usa-button usa-button--inverse usx-button usx-button--ghost usx-copy"
57
- onclick="navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)">
76
+ <button
77
+ class="usa-button usa-button--inverse usx-button usx-button--ghost usx-copy"
78
+ onclick="
79
+ navigator.clipboard.writeText(document.getElementById('example-text-to-copy').textContent)
80
+ "
81
+ >
58
82
  <svg class="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
59
83
  <use href="./img/sprite.svg#content_copy"></use>
60
84
  </svg>
@@ -63,6 +87,10 @@
63
87
  </svg>
64
88
  <span class="margin-left-1">Copy</span>
65
89
  </button>
66
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip">Copied</span>
90
+ <span
91
+ class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied"
92
+ role="tooltip"
93
+ >Copied</span
94
+ >
67
95
  </span>
68
- </div>
96
+ </div>
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import ClassNames from 'classnames';
3
+
4
+ export interface DetailsProps {
5
+ summary: string;
6
+ text?: string;
7
+ children?: React.ReactNode;
8
+ open?: boolean;
9
+ markerColor?: string;
10
+ underlineColor?: string;
11
+ contentBorderColor?: string;
12
+ noContentBorder?: boolean;
13
+ noSummaryUnderline?: boolean;
14
+ className?: string;
15
+ summaryClassName?: string;
16
+ summaryTextClassName?: string;
17
+ contentClassName?: string;
18
+ }
19
+
20
+ /** A native disclosure for optional supporting content. */
21
+ export default function Details({
22
+ summary = 'Details',
23
+ text = '',
24
+ children = null,
25
+ open = false,
26
+ markerColor = undefined,
27
+ underlineColor = undefined,
28
+ contentBorderColor = undefined,
29
+ noContentBorder = false,
30
+ noSummaryUnderline = false,
31
+ className = '',
32
+ summaryClassName = '',
33
+ summaryTextClassName = '',
34
+ contentClassName = '',
35
+ }: DetailsProps) {
36
+ const detailsClassName = ClassNames(
37
+ 'usx-details',
38
+ { 'usx-details--borderless': noContentBorder },
39
+ { 'usx-details--no-underline': noSummaryUnderline },
40
+ className
41
+ );
42
+ const summaryClassNames = ClassNames(
43
+ 'usx-details__summary',
44
+ { [`marker-${markerColor}`]: markerColor },
45
+ summaryClassName
46
+ );
47
+ const summaryTextClassNames = ClassNames(
48
+ 'usx-details__summary-text',
49
+ { [`border-${underlineColor}`]: underlineColor },
50
+ summaryTextClassName
51
+ );
52
+ const compositeContentClassName = ClassNames(
53
+ 'usx-details__content',
54
+ { [`border-${contentBorderColor}`]: !noContentBorder && contentBorderColor },
55
+ contentClassName
56
+ );
57
+
58
+ return (
59
+ <details className={detailsClassName} open={open || undefined}>
60
+ <summary className={summaryClassNames}>
61
+ {/* ::marker is here */}
62
+ <span className={summaryTextClassNames}>{summary || 'Details'}</span>
63
+ </summary>
64
+ <div className={compositeContentClassName}>
65
+ {children ?? <p className="usx-details__text">{text}</p>}
66
+ </div>
67
+ </details>
68
+ );
69
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "details",
3
+ "template": "details/details.django.html",
4
+ "version": 1,
5
+ "required": ["summary"],
6
+ "default": {
7
+ "summary": "Help finding your reference number",
8
+ "text": "Your reference number is included in the confirmation email we sent you."
9
+ },
10
+ "props": {
11
+ "summary": {
12
+ "type": "string",
13
+ "default": "Details",
14
+ "description": "Text label describing the supporting content. Always escaped."
15
+ },
16
+ "text": {
17
+ "type": "string",
18
+ "default": "",
19
+ "description": "Plain-text content. Always escaped; line breaks and indentation are preserved, and long lines wrap. Ignored when children is supplied."
20
+ },
21
+ "children": {
22
+ "type": "slot",
23
+ "description": "Composed content. Takes precedence over text when supplied, including an empty string."
24
+ },
25
+ "open": {
26
+ "type": "boolean",
27
+ "default": false,
28
+ "description": "Whether the native disclosure is initially open."
29
+ },
30
+ "markerColor": {
31
+ "type": "string",
32
+ "description": "USX color utility name for the summary marker, such as primary. Adds marker-{value} to the summary."
33
+ },
34
+ "underlineColor": {
35
+ "type": "string",
36
+ "description": "USWDS color utility name for the summary underline, such as secondary. Adds border-{value} to the summary text span."
37
+ },
38
+ "contentBorderColor": {
39
+ "type": "string",
40
+ "description": "USWDS color utility name for the content border, such as accent-cool. Adds border-{value} to the content unless noContentBorder is true."
41
+ },
42
+ "noContentBorder": {
43
+ "type": "boolean",
44
+ "default": false,
45
+ "description": "Whether to remove the content border."
46
+ },
47
+ "noSummaryUnderline": {
48
+ "type": "boolean",
49
+ "default": false,
50
+ "description": "Whether to remove the summary underline."
51
+ },
52
+ "className": {
53
+ "type": "string",
54
+ "default": "",
55
+ "description": "Additional CSS classes for the details element, including font and spacing utilities."
56
+ },
57
+ "summaryClassName": {
58
+ "type": "string",
59
+ "default": "",
60
+ "description": "Additional CSS classes for the summary element, including font and spacing utilities."
61
+ },
62
+ "summaryTextClassName": {
63
+ "type": "string",
64
+ "default": "",
65
+ "description": "Additional CSS classes for the summary text span, including font and spacing utilities."
66
+ },
67
+ "contentClassName": {
68
+ "type": "string",
69
+ "default": "",
70
+ "description": "Additional CSS classes for the content element, including font and spacing utilities."
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,7 @@
1
+ {# Django template for Details #}
2
+ {% load components %}
3
+ {% fragment as summaryText %}<span class="usx-details__summary-text{% if underlineColor %} border-{{ underlineColor|force_escape }}{% endif %}{% if summaryTextClassName %} {{ summaryTextClassName }}{% endif %}">{% if summary %}{{ summary|force_escape }}{% else %}Details{% endif %}</span>{% endfragment %}
4
+ <details class="usx-details{% if noContentBorder %} usx-details--borderless{% endif %}{% if noSummaryUnderline %} usx-details--no-underline{% endif %}{% if className %} {{ className }}{% endif %}"{% if open %} open{% endif %}>
5
+ <summary class="usx-details__summary{% if markerColor %} marker-{{ markerColor|force_escape }}{% endif %}{% if summaryClassName %} {{ summaryClassName }}{% endif %}">{{ summaryText }}</summary>
6
+ <div class="usx-details__content{% if not noContentBorder and contentBorderColor %} border-{{ contentBorderColor|force_escape }}{% endif %}{% if contentClassName %} {{ contentClassName }}{% endif %}">{% if children != None %}{% if children is not True and children is not False %}{{ children|safe }}{% endif %}{% else %}<p class="usx-details__text">{{ text|default_if_none:''|force_escape }}</p>{% endif %}</div>
7
+ </details>
@@ -0,0 +1,186 @@
1
+ <h3 class="site-preview-heading">Default</h3>
2
+ <details class="usx-details">
3
+ <summary class="usx-details__summary">
4
+ <span class="usx-details__summary-text">Help finding your reference number</span>
5
+ </summary>
6
+ <div class="usx-details__content">
7
+ <!-- prettier-ignore -->
8
+ <p class="usx-details__text">Your reference number is included in the confirmation email we sent you.</p>
9
+ </div>
10
+ </details>
11
+
12
+ <h3 class="site-preview-heading">Open</h3>
13
+ <details class="usx-details" open="">
14
+ <summary class="usx-details__summary">
15
+ <span class="usx-details__summary-text">How we use your contact details</span>
16
+ </summary>
17
+ <div class="usx-details__content">
18
+ <!-- prettier-ignore -->
19
+ <p class="usx-details__text">We use your email address to send updates about your request.
20
+ We will contact you if we need more information.</p>
21
+ </div>
22
+ </details>
23
+
24
+ <h3 class="site-preview-heading">Rich Content</h3>
25
+ <details class="usx-details">
26
+ <summary class="usx-details__summary">
27
+ <span class="usx-details__summary-text">Other ways to find your reference number</span>
28
+ </summary>
29
+ <div class="usx-details__content">
30
+ <p>You can find your reference number in:</p>
31
+ <ul>
32
+ <li>The subject line of your confirmation email</li>
33
+ <li>The letter we sent after receiving your request</li>
34
+ </ul>
35
+ <p>
36
+ If you still need help,
37
+ <a href="mailto:help@example.gov" class="usa-link usx-link">contact the support team</a>.
38
+ </p>
39
+ </div>
40
+ </details>
41
+
42
+ <h3 class="site-preview-heading">Plain Text</h3>
43
+ <details class="usx-details" open="">
44
+ <summary class="usx-details__summary">
45
+ <span class="usx-details__summary-text">Example reference format</span>
46
+ </summary>
47
+ <div class="usx-details__content">
48
+ <!-- prettier-ignore -->
49
+ <p class="usx-details__text">Enter the reference exactly as shown:
50
+ &lt;reference&gt; &amp; &lt;year&gt;
51
+
52
+ Markup is displayed as text.</p>
53
+ </div>
54
+ </details>
55
+
56
+ <h3 class="site-preview-heading">Typography</h3>
57
+ <details class="usx-details font-serif-lg text-italic" open="">
58
+ <summary class="usx-details__summary">
59
+ <span class="usx-details__summary-text">Typography example</span>
60
+ </summary>
61
+ <div class="usx-details__content font-mono-sm text-muted text-no-italic">
62
+ <!-- prettier-ignore -->
63
+ <p class="usx-details__text">This content demonstrates the default typography styles applied to the details component.</p>
64
+ </div>
65
+ </details>
66
+
67
+ <h3 class="site-preview-heading">Colors</h3>
68
+ <details class="usx-details" open="">
69
+ <summary class="usx-details__summary marker-error">
70
+ <span class="usx-details__summary-text border-secondary">Supporting information</span>
71
+ </summary>
72
+ <div class="usx-details__content border-accent-cool">
73
+ <!-- prettier-ignore -->
74
+ <p class="usx-details__text">The marker, summary underline, and content border can each use a different color utility.</p>
75
+ </div>
76
+ </details>
77
+
78
+ <h3 class="site-preview-heading">Mono Color</h3>
79
+ <details class="usx-details" open="">
80
+ <summary class="usx-details__summary marker-ink">
81
+ <span class="usx-details__summary-text border-ink">Mono color example</span>
82
+ </summary>
83
+ <div class="usx-details__content border-ink">
84
+ <!-- prettier-ignore -->
85
+ <p class="usx-details__text">This example demonstrates using a single color for all decorative elements.</p>
86
+ </div>
87
+ </details>
88
+
89
+ <h3 class="site-preview-heading">Borderless</h3>
90
+ <details class="usx-details usx-details--borderless" open="">
91
+ <summary class="usx-details__summary">
92
+ <span class="usx-details__summary-text">Help within a compact layout</span>
93
+ </summary>
94
+ <div class="usx-details__content">
95
+ <!-- prettier-ignore -->
96
+ <p class="usx-details__text">The content border is removed while the summary underline remains visible.</p>
97
+ </div>
98
+ </details>
99
+
100
+ <h3 class="site-preview-heading">No Summary Underline</h3>
101
+ <details class="usx-details usx-details--no-underline" open="">
102
+ <summary class="usx-details__summary">
103
+ <span class="usx-details__summary-text">Supporting documents</span>
104
+ </summary>
105
+ <div class="usx-details__content">
106
+ <!-- prettier-ignore -->
107
+ <p class="usx-details__text">The summary has no underline. The native marker and content border remain visible.</p>
108
+ </div>
109
+ </details>
110
+
111
+ <h3 class="site-preview-heading">Minimal Decoration</h3>
112
+ <details class="usx-details usx-details--borderless usx-details--no-underline" open="">
113
+ <summary class="usx-details__summary marker-ink">
114
+ <span class="usx-details__summary-text">Additional information</span>
115
+ </summary>
116
+ <div class="usx-details__content">
117
+ <!-- prettier-ignore -->
118
+ <p class="usx-details__text">Both decorations can be removed together. The native marker still indicates the disclosure state.</p>
119
+ </div>
120
+ </details>
121
+
122
+ <h3 class="site-preview-heading">Custom Styles</h3>
123
+ <details class="usx-details font-family-mono font-mono-sm margin-top-3" open="">
124
+ <summary class="usx-details__summary">
125
+ <span class="usx-details__summary-text">Request information</span>
126
+ </summary>
127
+ <div class="usx-details__content">
128
+ <!-- prettier-ignore -->
129
+ <p class="usx-details__text">Reference: REQUEST-10482
130
+ Status: Waiting for review</p>
131
+ </div>
132
+ </details>
133
+
134
+ <h3 class="site-preview-heading">Custom Content Styles</h3>
135
+ <details class="usx-details" open="">
136
+ <summary class="usx-details__summary">
137
+ <span class="usx-details__summary-text">Request information</span>
138
+ </summary>
139
+ <div
140
+ class="usx-details__content font-family-mono font-mono-sm bg-surface-inverse text-inverse padding-2 usx-rounded-lg"
141
+ >
142
+ <!-- prettier-ignore -->
143
+ <p class="usx-details__text">Reference: REQUEST-10482
144
+ Status: Waiting for review</p>
145
+ </div>
146
+ </details>
147
+
148
+ <h3 class="site-preview-heading">Tough On The Eyes</h3>
149
+ <details class="usx-details bg-violet text-yellow" open="">
150
+ <summary class="usx-details__summary marker-warning">
151
+ <span class="usx-details__summary-text border-secondary">Tough on the eyes example</span>
152
+ </summary>
153
+ <div class="usx-details__content border-accent-cool bg-green text-info">
154
+ <!-- prettier-ignore -->
155
+ <p class="usx-details__text">This example demonstrates all color utilities applied together for testing visual contrast and readability.</p>
156
+ </div>
157
+ </details>
158
+
159
+ <h3 class="site-preview-heading">Nested Details</h3>
160
+ <details class="usx-details usx-details--borderless usx-details--no-underline" open="">
161
+ <summary class="usx-details__summary">
162
+ <span class="usx-details__summary-text">Nested details example</span>
163
+ </summary>
164
+ <div class="usx-details__content">
165
+ <details class="usx-details usx-details--borderless usx-details--no-underline" open="">
166
+ <summary class="usx-details__summary">
167
+ <span class="usx-details__summary-text">Nested summary</span>
168
+ </summary>
169
+ <div class="usx-details__content">
170
+ <details class="usx-details usx-details--borderless usx-details--no-underline" open="">
171
+ <summary class="usx-details__summary">
172
+ <span class="usx-details__summary-text">Nested nested summary</span>
173
+ </summary>
174
+ <div class="usx-details__content">
175
+ <details class="usx-details usx-details--no-underline" open="">
176
+ <summary class="usx-details__summary">
177
+ <span class="usx-details__summary-text">Nested nested nested summary</span>
178
+ </summary>
179
+ <div class="usx-details__content border-secondary">Deeply nested content</div>
180
+ </details>
181
+ </div>
182
+ </details>
183
+ </div>
184
+ </details>
185
+ </div>
186
+ </details>
@@ -1,2 +1,15 @@
1
- <!-- Default -->
2
- <span id="error-1" class="usa-error-message usx-error-message" role="alert">Enter a valid email address.</span>
1
+ <h3 class="site-preview-heading">Default</h3>
2
+ <span
3
+ class="usa-error-message usx-error-message"
4
+ role="alert"
5
+ id="html-error-message-default-error-1"
6
+ >Enter a valid email address.</span
7
+ >
8
+
9
+ <h3 class="site-preview-heading">With Custom Class</h3>
10
+ <span
11
+ class="usa-error-message usx-error-message text-normal text-italic"
12
+ role="alert"
13
+ id="html-error-message-with-custom-class-error-2"
14
+ >Enter a valid email address.</span
15
+ >
@@ -0,0 +1,169 @@
1
+ import React from 'react';
2
+ import ClassNames from 'classnames';
3
+ import ButtonGroup from '../button-group/ButtonGroup';
4
+ import Details, { type DetailsProps } from '../details/Details';
5
+ import Image from '../image/Image';
6
+ import Link from '../link/Link';
7
+ import Page from '../page/Page';
8
+ import Prose from '../prose/Prose';
9
+
10
+ export interface ErrorPageAction {
11
+ label: string;
12
+ href: string;
13
+ variant?:
14
+ | 'primary'
15
+ | 'secondary'
16
+ | 'accent-cool'
17
+ | 'accent-warm'
18
+ | 'base'
19
+ | 'outline'
20
+ | 'unstyled';
21
+ isExternal?: boolean;
22
+ className?: string;
23
+ itemClassName?: string;
24
+ }
25
+
26
+ export interface ErrorPageSupportLink {
27
+ label: string;
28
+ href: string;
29
+ external?: boolean;
30
+ newTab?: boolean;
31
+ className?: string;
32
+ }
33
+
34
+ export interface ErrorPageProps {
35
+ id?: string;
36
+ title: string;
37
+ description?: string;
38
+ guidance?: string;
39
+ actions?: ErrorPageAction[];
40
+ supportHeading?: string;
41
+ supportText?: string;
42
+ supportLinks?: ErrorPageSupportLink[];
43
+ cats?: boolean;
44
+ catAlt?: string;
45
+ errorCode?: string | number;
46
+ errorCodeLabel?: string;
47
+ referenceId?: string;
48
+ referenceLabel?: string;
49
+ detailsProps?: DetailsProps | null;
50
+ children?: React.ReactNode;
51
+ className?: string;
52
+ }
53
+
54
+ const DEFAULT_TITLE = 'We couldn’t complete your request';
55
+ const DEFAULT_DESCRIPTION = 'We’re sorry. Please try again later.';
56
+
57
+ /**
58
+ * A shared recovery page for HTTP errors and application error fallbacks.
59
+ * The host application remains responsible for the response status, document
60
+ * title, logging, diagnostic access and redaction, focus movement, and any
61
+ * framework-specific error boundary.
62
+ */
63
+ export default function ErrorPage({
64
+ id = 'main-content',
65
+ title = DEFAULT_TITLE,
66
+ description = DEFAULT_DESCRIPTION,
67
+ guidance = '',
68
+ actions = [],
69
+ supportHeading = '',
70
+ supportText = '',
71
+ supportLinks = [],
72
+ cats = false,
73
+ catAlt = '',
74
+ errorCode,
75
+ errorCodeLabel = 'Error code',
76
+ referenceId = '',
77
+ referenceLabel = 'Reference ID',
78
+ detailsProps = null,
79
+ children = null,
80
+ className = '',
81
+ }: ErrorPageProps) {
82
+ const pageId = id || 'main-content';
83
+ const pageTitle = title || DEFAULT_TITLE;
84
+ const pageDescription = description || DEFAULT_DESCRIPTION;
85
+ const titleId = `${pageId}-title`;
86
+ const supportHeadingId = `${pageId}-support-heading`;
87
+ const pageActions = Array.isArray(actions) ? actions : [];
88
+ const pageSupportLinks = Array.isArray(supportLinks) ? supportLinks : [];
89
+ const hasSupport = Boolean(supportHeading || supportText || pageSupportLinks.length);
90
+ const hasErrorCode = errorCode !== undefined && errorCode !== null && errorCode !== '';
91
+ const hasMeta = hasErrorCode || Boolean(referenceId);
92
+ const catImageAlt = catAlt || `Cat illustration for HTTP error ${errorCode}`;
93
+ const classes = ClassNames('usx-error-page', className);
94
+
95
+ return (
96
+ <Page id={pageId} title={pageTitle} titleId={titleId} className={classes}>
97
+ <Prose className="usx-error-page__body">
98
+ <p className="usa-intro usx-error-page__description margin-bottom-4">{pageDescription}</p>
99
+
100
+ {cats && Boolean(errorCode) && (
101
+ <Image src={`https://http.cat/${errorCode}`} alt={catImageAlt} />
102
+ )}
103
+
104
+ {(guidance || children) && (
105
+ <div className="usx-error-page__content">
106
+ {guidance && <p>{guidance}</p>}
107
+ {children}
108
+ </div>
109
+ )}
110
+ </Prose>
111
+
112
+ {pageActions.length > 0 && (
113
+ <ButtonGroup buttonProps={pageActions} className="usx-error-page__actions" />
114
+ )}
115
+
116
+ <Prose className="usx-error-page__body">
117
+ {hasSupport && (
118
+ <section
119
+ className="usx-error-page__support"
120
+ {...(supportHeading ? { 'aria-labelledby': supportHeadingId } : {})}
121
+ >
122
+ {supportHeading && (
123
+ <h2 id={supportHeadingId} className="usx-error-page__support-heading">
124
+ {supportHeading}
125
+ </h2>
126
+ )}
127
+ {supportText && <p>{supportText}</p>}
128
+ {pageSupportLinks.length > 0 && (
129
+ <ul className="usx-error-page__support-links">
130
+ {pageSupportLinks.map(({ label, ...linkProps }, index) => (
131
+ <li key={index}>
132
+ <Link {...linkProps}>{label}</Link>
133
+ </li>
134
+ ))}
135
+ </ul>
136
+ )}
137
+ </section>
138
+ )}
139
+
140
+ {hasMeta && (
141
+ <div className="usx-error-page__meta text-base font-body-2xs">
142
+ {hasErrorCode && (
143
+ <p>
144
+ <strong>{errorCodeLabel || 'Error code'}:</strong>{' '}
145
+ <span className="usx-error-page__meta-value">{errorCode}</span>
146
+ </p>
147
+ )}
148
+ {referenceId && (
149
+ <p>
150
+ <strong>{referenceLabel || 'Reference ID'}:</strong>{' '}
151
+ <span className="usx-error-page__meta-value">{referenceId}</span>
152
+ </p>
153
+ )}
154
+ </div>
155
+ )}
156
+
157
+ {detailsProps && (
158
+ <Details
159
+ {...detailsProps}
160
+ className={ClassNames(
161
+ 'usx-error-page__details font-family-mono font-mono-sm',
162
+ detailsProps.className
163
+ )}
164
+ />
165
+ )}
166
+ </Prose>
167
+ </Page>
168
+ );
169
+ }