@solexllc/usx-react 0.3.1 → 0.5.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 (135) hide show
  1. package/README.md +132 -0
  2. package/dist/index.cjs +504 -450
  3. package/dist/index.js +504 -450
  4. package/package.json +6 -5
  5. package/src/assets.ts +16 -0
  6. package/src/components/alert/Alert.tsx +4 -3
  7. package/src/components/alert/alert.django.html +2 -3
  8. package/src/components/alert/config.json +15 -4
  9. package/src/components/attribution/config.json +5 -5
  10. package/src/components/banner/Banner.tsx +8 -6
  11. package/src/components/banner/banner.django.html +4 -5
  12. package/src/components/banner/config.json +7 -3
  13. package/src/components/breadcrumb/Breadcrumb.tsx +5 -6
  14. package/src/components/breadcrumb/config.json +11 -1
  15. package/src/components/button/Button.tsx +1 -1
  16. package/src/components/button/button.django.html +2 -2
  17. package/src/components/button/button.html +2 -2
  18. package/src/components/button/config.json +14 -6
  19. package/src/components/button-group/button-group.django.html +1 -1
  20. package/src/components/calendar-date/calendar-date.django.html +3 -3
  21. package/src/components/callout/Callout.tsx +53 -0
  22. package/src/components/callout/callout.django.html +5 -0
  23. package/src/components/callout/callout.html +76 -0
  24. package/src/components/callout/config.json +74 -0
  25. package/src/components/card/Card.tsx +18 -34
  26. package/src/components/card/card.django.html +12 -10
  27. package/src/components/card/config.json +15 -40
  28. package/src/components/card-group/card-group.django.html +1 -1
  29. package/src/components/carousel/Carousel.tsx +3 -2
  30. package/src/components/carousel/carousel.django.html +13 -2
  31. package/src/components/carousel/config.json +2 -2
  32. package/src/components/character-count/config.json +2 -2
  33. package/src/components/checkbox-group/CheckboxGroup.tsx +10 -20
  34. package/src/components/checkbox-group/checkbox-group.django.html +10 -4
  35. package/src/components/checkbox-group/config.json +10 -5
  36. package/src/components/clickable/clickable.html +21 -39
  37. package/src/components/clickable/config.json +2 -2
  38. package/src/components/code/Code.tsx +4 -27
  39. package/src/components/code/code.django.html +3 -9
  40. package/src/components/code/config.json +4 -0
  41. package/src/components/collection/Collection.tsx +5 -5
  42. package/src/components/collection/collection.django.html +2 -4
  43. package/src/components/collection/config.json +7 -6
  44. package/src/components/combobox/config.json +4 -4
  45. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +35 -24
  46. package/src/components/copy-to-clipboard/config.json +14 -7
  47. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +14 -14
  48. package/src/components/date-picker/config.json +4 -4
  49. package/src/components/date-range-picker/config.json +7 -7
  50. package/src/components/error-message/config.json +2 -2
  51. package/src/components/eyebrow/Eyebrow.tsx +2 -1
  52. package/src/components/eyebrow/config.json +2 -2
  53. package/src/components/fieldset/config.json +5 -5
  54. package/src/components/file-input/FileInput.tsx +3 -2
  55. package/src/components/file-input/config.json +5 -5
  56. package/src/components/file-list/FileList.tsx +2 -1
  57. package/src/components/file-list/config.json +2 -2
  58. package/src/components/footer/Footer.tsx +31 -11
  59. package/src/components/footer/config.json +4 -0
  60. package/src/components/footer/footer.django.html +10 -9
  61. package/src/components/form-group/config.json +2 -2
  62. package/src/components/header/Branding.tsx +9 -6
  63. package/src/components/header/Header.tsx +3 -1
  64. package/src/components/header/config.json +4 -0
  65. package/src/components/header/header.django.html +5 -26
  66. package/src/components/header/header.html +10 -10
  67. package/src/components/hero/Hero.tsx +8 -14
  68. package/src/components/hero/config.json +36 -27
  69. package/src/components/hero/hero.django.html +2 -2
  70. package/src/components/hint/config.json +2 -2
  71. package/src/components/icon/Icon.tsx +6 -3
  72. package/src/components/icon/config.json +12 -6
  73. package/src/components/icon/icon.django.html +6 -4
  74. package/src/components/image/Image.tsx +8 -4
  75. package/src/components/image/config.json +10 -2
  76. package/src/components/image/image.django.html +8 -6
  77. package/src/components/in-page-nav/config.json +11 -1
  78. package/src/components/indicator/config.json +2 -2
  79. package/src/components/input/config.json +2 -2
  80. package/src/components/label/config.json +2 -2
  81. package/src/components/language-selector/config.json +2 -2
  82. package/src/components/layout/Layout.tsx +1 -1
  83. package/src/components/layout/config.json +9 -9
  84. package/src/components/layout/layout.django.html +1 -1
  85. package/src/components/legend/config.json +3 -3
  86. package/src/components/link/config.json +2 -2
  87. package/src/components/memorable-date/config.json +9 -9
  88. package/src/components/misc-banner/MiscBanner.tsx +2 -1
  89. package/src/components/misc-banner/config.json +2 -2
  90. package/src/components/modal/config.json +2 -2
  91. package/src/components/page/Page.tsx +2 -1
  92. package/src/components/page/config.json +7 -7
  93. package/src/components/page/page.django.html +1 -1
  94. package/src/components/pagination/Pagination.tsx +2 -1
  95. package/src/components/pagination/container/PaginationContainer.tsx +2 -1
  96. package/src/components/prose/config.json +5 -1
  97. package/src/components/quote/Quote.tsx +58 -0
  98. package/src/components/quote/config.json +51 -0
  99. package/src/components/quote/quote.django.html +15 -0
  100. package/src/components/quote/quote.html +66 -0
  101. package/src/components/radio-buttons/config.json +3 -3
  102. package/src/components/range-slider/RangeSlider.tsx +2 -1
  103. package/src/components/range-slider/config.json +4 -4
  104. package/src/components/required/config.json +2 -2
  105. package/src/components/section/Section.tsx +6 -2
  106. package/src/components/section/config.json +19 -6
  107. package/src/components/section/section.django.html +9 -2
  108. package/src/components/select/config.json +2 -2
  109. package/src/components/site-alert/SiteAlert.tsx +5 -6
  110. package/src/components/skipnav/config.json +2 -2
  111. package/src/components/spinner/Spinner.tsx +18 -25
  112. package/src/components/spinner/config.json +4 -0
  113. package/src/components/spinner/spinner.django.html +4 -6
  114. package/src/components/summary-box/config.json +3 -3
  115. package/src/components/swap/Swap.tsx +4 -3
  116. package/src/components/swap/config.json +4 -4
  117. package/src/components/switch/config.json +2 -2
  118. package/src/components/table/config.json +13 -3
  119. package/src/components/tag/config.json +2 -2
  120. package/src/components/tag-group/config.json +2 -2
  121. package/src/components/text-area/config.json +2 -2
  122. package/src/components/time-picker/config.json +4 -4
  123. package/src/components/toggle/Toggle.tsx +69 -40
  124. package/src/components/toggle/config.json +42 -10
  125. package/src/components/toggle/toggle.django.html +25 -17
  126. package/src/components/toggle/toggle.html +319 -85
  127. package/src/components/tooltip/Tooltip.tsx +4 -2
  128. package/src/components/tooltip/config.json +9 -4
  129. package/src/components/tooltip/tooltip.django.html +1 -1
  130. package/src/components/villain/Villain.tsx +2 -1
  131. package/src/index.js +2 -1
  132. package/src/components/block/Block.tsx +0 -78
  133. package/src/components/block/block.django.html +0 -26
  134. package/src/components/block/block.html +0 -162
  135. package/src/components/block/config.json +0 -88
@@ -4,6 +4,7 @@ import Input from '../input/Input';
4
4
  import Button from '../button/Button';
5
5
  import Icon from '../icon/Icon';
6
6
  import ClassNames from 'classnames';
7
+ import { getAssetUrl } from '../../assets';
7
8
 
8
9
  // ── Sub-components ──────────────────────────────────────────────────────────
9
10
 
@@ -38,7 +39,7 @@ export interface FooterNavColumnProps {
38
39
  }
39
40
  export function FooterNavColumn({ heading, links = [], className = '' }: FooterNavColumnProps) {
40
41
  return (
41
- <section className={['usa-footer__primary-content usa-footer__primary-content--collapsible usx-footer__nav-column', className].filter(Boolean).join(' ')}>
42
+ <section className={ClassNames('usa-footer__primary-content usa-footer__primary-content--collapsible usx-footer__nav-column', className)}>
42
43
  {heading && <h4 className="usa-footer__primary-link">{heading}</h4>}
43
44
  {links.length > 0 && (
44
45
  <ul className="usa-list usa-list--unstyled">
@@ -72,7 +73,7 @@ export function FooterSignUp({
72
73
  className = '',
73
74
  }: FooterSignUpProps) {
74
75
  return (
75
- <div className={['usa-sign-up usx-footer__sign-up', className].filter(Boolean).join(' ')}>
76
+ <div className={ClassNames('usa-sign-up usx-footer__sign-up', className)}>
76
77
  <h3 className="usa-sign-up__heading">{heading}</h3>
77
78
  <form className="usa-form" action={action || undefined} onSubmit={onSubmit || undefined}>
78
79
  <Input
@@ -95,16 +96,17 @@ export interface FooterSocialLink {
95
96
  }
96
97
  export interface FooterSocialLinksProps {
97
98
  links?: FooterSocialLink[];
99
+ staticBaseUrl?: string;
98
100
  className?: string;
99
101
  }
100
- export function FooterSocialLinks({ links = [], className = '' }: FooterSocialLinksProps) {
102
+ export function FooterSocialLinks({ links = [], staticBaseUrl, className = '' }: FooterSocialLinksProps) {
101
103
  if (!links.length) return null;
102
104
  return (
103
- <div className={['usa-footer__social-links grid-row grid-gap-1 usx-footer__social-links', className].filter(Boolean).join(' ')}>
105
+ <div className={ClassNames('usa-footer__social-links grid-row grid-gap-1 usx-footer__social-links', className)}>
104
106
  {links.map((link, i) => (
105
107
  <div key={i} className="grid-col-auto">
106
108
  <a className="usa-social-link" href={link.href} aria-label={link.alt}>
107
- <img className="usa-social-link__icon" src={link.icon} alt={link.alt} />
109
+ <img className="usa-social-link__icon" src={getAssetUrl(link.icon, staticBaseUrl)} alt={link.alt} />
108
110
  </a>
109
111
  </div>
110
112
  ))}
@@ -146,7 +148,7 @@ export function FooterContact({
146
148
 
147
149
  if (!heading && allLinks.length === 0) return null;
148
150
  return (
149
- <address className={['usa-footer__address usx-footer__contact', className].filter(Boolean).join(' ')}>
151
+ <address className={ClassNames('usa-footer__address usx-footer__contact', className)}>
150
152
  {heading && <p className="usa-footer__contact-heading">{heading}</p>}
151
153
  {allLinks.length > 0 && (
152
154
  <div className="usa-footer__contact-info grid-row grid-gap">
@@ -172,6 +174,7 @@ export interface FooterProps extends React.HTMLAttributes<HTMLElement> {
172
174
  signUp?: FooterSignUpProps | null;
173
175
  branding?: BrandingProps | null;
174
176
  brandingUrl?: string;
177
+ staticBaseUrl?: string;
175
178
  socialLinks?: FooterSocialLink[];
176
179
  contactHeading?: string | null;
177
180
  contactPhone?: LinkShape | null;
@@ -193,6 +196,7 @@ export default function Footer({
193
196
  signUp = null,
194
197
  branding = null,
195
198
  brandingUrl = '/',
199
+ staticBaseUrl,
196
200
  socialLinks = [],
197
201
  contactHeading = null,
198
202
  contactPhone = null,
@@ -206,7 +210,7 @@ export default function Footer({
206
210
  const variantClass = variant === 'big' ? 'usa-footer--big'
207
211
  : variant === 'slim' ? 'usa-footer--slim'
208
212
  : '';
209
- const classes = ['usa-footer', variantClass, 'usx-footer', className].filter(Boolean).join(' ');
213
+ const classes = ClassNames('usa-footer', variantClass, 'usx-footer', className);
210
214
 
211
215
  const returnToTopEl = returnToTop ? (
212
216
  <FooterReturnToTop
@@ -225,12 +229,12 @@ export default function Footer({
225
229
  />
226
230
  ) : null;
227
231
 
228
- const socialEl = socialLinks.length > 0 ? <FooterSocialLinks links={socialLinks} /> : null;
232
+ const socialEl = socialLinks.length > 0 ? <FooterSocialLinks links={socialLinks} staticBaseUrl={staticBaseUrl} /> : null;
229
233
  const logoClassName = variant === 'slim'
230
234
  ? 'usa-footer__logo grid-row grid-gap-2 usx-footer__logo'
231
235
  : 'usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2 usx-footer__logo';
232
236
  const brandingEl = branding ? (
233
- <Branding branding={branding} projectUrl={brandingUrl} className={logoClassName} />
237
+ <Branding branding={branding} projectUrl={brandingUrl} staticBaseUrl={staticBaseUrl} className={logoClassName} />
234
238
  ) : null;
235
239
 
236
240
  const secondaryContactBlock = (socialEl || contactEl) ? (
@@ -287,6 +291,12 @@ export default function Footer({
287
291
 
288
292
  // ── Slim footer ───────────────────────────────────────────────────────────
289
293
  if (variant === 'slim') {
294
+ const slimContactLinks = [
295
+ normalizeContactLink(contactPhone, 'tel:'),
296
+ normalizeContactLink(contactEmail, 'mailto:'),
297
+ ...contactLinks,
298
+ ].filter(Boolean) as FooterContactLink[];
299
+
290
300
  return (
291
301
  <footer className={classes} {...props}>
292
302
  {returnToTopEl}
@@ -308,9 +318,19 @@ export default function Footer({
308
318
  </nav>
309
319
  </div>
310
320
  )}
311
- {contactEl && (
321
+ {slimContactLinks.length > 0 && (
312
322
  <div className="mobile-lg:grid-col-4">
313
- {contactEl}
323
+ <address className="usa-footer__address usx-footer__contact">
324
+ <div className="grid-row grid-gap">
325
+ {slimContactLinks.map((link, index) => (
326
+ <div key={index} className="grid-col-auto mobile-lg:grid-col-12 desktop:grid-col-auto">
327
+ <div className="usa-footer__contact-info">
328
+ <a href={link.href}>{link.text}</a>
329
+ </div>
330
+ </div>
331
+ ))}
332
+ </div>
333
+ </address>
314
334
  </div>
315
335
  )}
316
336
  </div>
@@ -3,6 +3,10 @@
3
3
  "template": "footer/footer.django.html",
4
4
  "version": 1,
5
5
  "props": {
6
+ "staticBaseUrl": {
7
+ "type": "string",
8
+ "description": "Optional branding and social-image asset base, overriding window.usxBaseUrl in React or STATIC_URL in Django. Defaults to the global base or /."
9
+ },
6
10
  "variant": {
7
11
  "type": "select",
8
12
  "options": [
@@ -145,6 +145,7 @@
145
145
  </div>{# /primary-section #}
146
146
 
147
147
  {# ── Secondary section ──────────────────────────────────────── #}
148
+ {% firstof branding.alt branding.title '' as brandingLabel %}
148
149
  {% if branding or socialLinks or contactHeading or contactPhone or contactEmail or contactLinks %}
149
150
  <div class="usa-footer__secondary-section">
150
151
  <div class="grid-container">
@@ -155,16 +156,16 @@
155
156
  <div class="usa-logo usx-logo usa-footer__logo grid-row grid-gap-2 usx-footer__logo">
156
157
  {% if branding.logo %}
157
158
  {% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-image usx-logo__image">{% else %}<div class="usx-image usx-logo__image">{% endif %}
158
- {% image src=branding.logo alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant' %}{% endimage %}
159
- {% if branding.logoInverse %}{% image src=branding.logoInverse alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant usx-logo__variant--inverse' %}{% endimage %}{% endif %}
159
+ {% image src=branding.logo alt=brandingLabel staticBaseUrl=staticBaseUrl className='usx-logo__variant' %}{% endimage %}
160
+ {% if branding.logoInverse %}{% image src=branding.logoInverse alt=brandingLabel staticBaseUrl=staticBaseUrl className='usx-logo__variant usx-logo__variant--inverse' %}{% endimage %}{% endif %}
160
161
  {% if brandingUrl %}</a>{% else %}</div>{% endif %}
161
162
  {% else %}
162
163
  <em class="usa-logo__text">
163
164
  {% if branding.symbol %}
164
- <img src="{{ branding.symbol }}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant" />
165
+ <img src="{% asset_url branding.symbol staticBaseUrl %}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant" />
165
166
  {% endif %}
166
167
  {% if branding.symbolInverse %}
167
- <img src="{{ branding.symbolInverse }}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant usx-logo__variant--inverse" />
168
+ <img src="{% asset_url branding.symbolInverse staticBaseUrl %}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant usx-logo__variant--inverse" />
168
169
  {% endif %}
169
170
  {% if branding.title %}
170
171
  {% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-logo__title">{{ branding.title }}</a>
@@ -182,16 +183,16 @@
182
183
  <div class="usa-logo usx-logo usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2 usx-footer__logo">
183
184
  {% if branding.logo %}
184
185
  {% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-image usx-logo__image">{% else %}<div class="usx-image usx-logo__image">{% endif %}
185
- {% image src=branding.logo alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant' %}{% endimage %}
186
- {% if branding.logoInverse %}{% image src=branding.logoInverse alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant usx-logo__variant--inverse' %}{% endimage %}{% endif %}
186
+ {% image src=branding.logo alt=brandingLabel staticBaseUrl=staticBaseUrl className='usx-logo__variant' %}{% endimage %}
187
+ {% if branding.logoInverse %}{% image src=branding.logoInverse alt=brandingLabel staticBaseUrl=staticBaseUrl className='usx-logo__variant usx-logo__variant--inverse' %}{% endimage %}{% endif %}
187
188
  {% if brandingUrl %}</a>{% else %}</div>{% endif %}
188
189
  {% else %}
189
190
  <em class="usa-logo__text">
190
191
  {% if branding.symbol %}
191
- <img src="{{ branding.symbol }}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant" />
192
+ <img src="{% asset_url branding.symbol staticBaseUrl %}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant" />
192
193
  {% endif %}
193
194
  {% if branding.symbolInverse %}
194
- <img src="{{ branding.symbolInverse }}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant usx-logo__variant--inverse" />
195
+ <img src="{% asset_url branding.symbolInverse staticBaseUrl %}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant usx-logo__variant--inverse" />
195
196
  {% endif %}
196
197
  {% if branding.title %}
197
198
  {% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-logo__title">{{ branding.title }}</a>
@@ -209,7 +210,7 @@
209
210
  {% for social in socialLinks %}
210
211
  <div class="grid-col-auto">
211
212
  <a class="usa-social-link" href="{{ social.href }}"{% if social.alt %} aria-label="{{ social.alt }}"{% endif %}>
212
- <img class="usa-social-link__icon" src="{{ social.icon }}" alt="{{ social.alt|default:'' }}" />
213
+ <img class="usa-social-link__icon" src="{% asset_url social.icon staticBaseUrl %}" alt="{{ social.alt|default:'' }}" />
213
214
  </a>
214
215
  </div>
215
216
  {% endfor %}
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "form-group",
3
3
  "template": "form-group/form-group.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "children": {
7
- "type": "string",
7
+ "type": "slot",
8
8
  "default": null,
9
9
  "description": "Inner HTML content of the form group."
10
10
  },
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import Image from '../image/Image';
3
3
  import ClassNames from 'classnames';
4
+ import { getAssetUrl } from '../../assets';
4
5
 
5
6
  export interface BrandingLogoSource {
6
7
  srcSet: string;
@@ -26,10 +27,11 @@ export interface BrandingConfig {
26
27
  export interface BrandingProps extends React.HTMLAttributes<HTMLDivElement> {
27
28
  branding: BrandingConfig;
28
29
  projectUrl?: string;
30
+ staticBaseUrl?: string;
29
31
  className?: string;
30
32
  }
31
33
 
32
- function BrandingContent({ config, projectUrl }: { config: BrandingConfig; projectUrl?: string }) {
34
+ function BrandingContent({ config, projectUrl, staticBaseUrl }: { config: BrandingConfig; projectUrl?: string; staticBaseUrl?: string }) {
33
35
  const { title, symbol, symbolInverse, logo, logoInverse, alt } = config;
34
36
  const label = alt ?? title ?? '';
35
37
 
@@ -41,10 +43,11 @@ function BrandingContent({ config, projectUrl }: { config: BrandingConfig; proje
41
43
  {...(projectUrl ? { href: projectUrl } : {})}
42
44
  className="usx-image usx-logo__image"
43
45
  >
44
- <Image src={logo} alt={label} className="usx-logo__variant" />
46
+ <Image src={logo} alt={label} staticBaseUrl={staticBaseUrl} className="usx-logo__variant" />
45
47
  {logoInverse && (
46
48
  <Image
47
49
  src={logoInverse}
50
+ staticBaseUrl={staticBaseUrl}
48
51
  alt={label}
49
52
  className="usx-logo__variant usx-logo__variant--inverse"
50
53
  />
@@ -56,11 +59,11 @@ function BrandingContent({ config, projectUrl }: { config: BrandingConfig; proje
56
59
  return (
57
60
  <em className="usa-logo__text">
58
61
  {symbol && (
59
- <img src={symbol} alt="" aria-hidden="true" className="usx-logo__symbol usx-logo__variant" />
62
+ <img src={getAssetUrl(symbol, staticBaseUrl)} alt="" aria-hidden="true" className="usx-logo__symbol usx-logo__variant" />
60
63
  )}
61
64
  {symbolInverse && (
62
65
  <img
63
- src={symbolInverse}
66
+ src={getAssetUrl(symbolInverse, staticBaseUrl)}
64
67
  alt=""
65
68
  aria-hidden="true"
66
69
  className="usx-logo__symbol usx-logo__variant usx-logo__variant--inverse"
@@ -75,7 +78,7 @@ function BrandingContent({ config, projectUrl }: { config: BrandingConfig; proje
75
78
  );
76
79
  }
77
80
 
78
- export default function Branding({ branding, projectUrl = '/', className = '', ...props }: BrandingProps) {
81
+ export default function Branding({ branding, projectUrl = '/', staticBaseUrl, className = '', ...props }: BrandingProps) {
79
82
  if (!branding) return null;
80
83
 
81
84
  const classes = ClassNames(
@@ -86,7 +89,7 @@ export default function Branding({ branding, projectUrl = '/', className = '', .
86
89
 
87
90
  return (
88
91
  <div className={classes} {...props}>
89
- <BrandingContent config={branding} projectUrl={projectUrl} />
92
+ <BrandingContent config={branding} projectUrl={projectUrl} staticBaseUrl={staticBaseUrl} />
90
93
  </div>
91
94
  );
92
95
  }
@@ -160,6 +160,7 @@ function PrimaryNav({
160
160
  export interface HeaderProps extends React.HTMLAttributes<HTMLElement> {
161
161
  id?: string;
162
162
  branding: BrandingProps;
163
+ staticBaseUrl?: string;
163
164
  projectUrl?: string;
164
165
  navSections?: HeaderNavSection[];
165
166
  secondaryLinks?: HeaderNavLink[];
@@ -178,6 +179,7 @@ export interface HeaderProps extends React.HTMLAttributes<HTMLElement> {
178
179
  export default function Header({
179
180
  id = 'header',
180
181
  branding,
182
+ staticBaseUrl,
181
183
  projectUrl = '/',
182
184
  navSections = [],
183
185
  secondaryLinks = [],
@@ -208,7 +210,7 @@ export default function Header({
208
210
 
209
211
  const navbar = (
210
212
  <div className="usa-navbar">
211
- <Branding branding={branding} projectUrl={projectUrl} />
213
+ <Branding branding={branding} projectUrl={projectUrl} staticBaseUrl={staticBaseUrl} />
212
214
  <button type="button" className="usa-menu-btn align-center">
213
215
  {useMenuIcon ? <Icon name="menu" size={3} /> : 'Menu'}
214
216
  </button>
@@ -3,6 +3,10 @@
3
3
  "template": "header/header.django.html",
4
4
  "version": 1,
5
5
  "props": {
6
+ "staticBaseUrl": {
7
+ "type": "string",
8
+ "description": "Optional branding image asset base, overriding window.usxBaseUrl in React or STATIC_URL in Django. Defaults to the global base or /."
9
+ },
6
10
  "id": {
7
11
  "type": "string",
8
12
  "default": "header",
@@ -14,41 +14,20 @@
14
14
  <div class="usa-navbar">
15
15
  <div class="usa-logo usx-logo">
16
16
  {% if branding.logo %}
17
+ {% firstof branding.alt branding.title '' as brandingLabel %}
17
18
  <a href="{{ projectUrl|default:'/' }}" class="usx-image usx-logo__image">
18
- <div class="usx-image usx-logo__variant">
19
- {% if branding.logo.fallback %}
20
- <picture>
21
- {% for source in branding.logo.sources %}
22
- <source srcset="{{ source.srcSet }}"{% if source.media %} media="{{ source.media }}"{% endif %}{% if source.type %} type="{{ source.type }}"{% endif %}{% if source.sizes %} sizes="{{ source.sizes }}"{% endif %} />
23
- {% endfor %}
24
- <img src="{{ branding.logo.fallback }}" alt="{{ branding.title }}" />
25
- </picture>
26
- {% else %}
27
- <img src="{{ branding.logo }}" alt="{{ branding.title }}" />
28
- {% endif %}
29
- </div>
19
+ {% image src=branding.logo alt=brandingLabel staticBaseUrl=staticBaseUrl className='usx-logo__variant' %}{% endimage %}
30
20
  {% if branding.logoInverse %}
31
- <div class="usx-image usx-logo__variant usx-logo__variant--inverse">
32
- {% if branding.logoInverse.fallback %}
33
- <picture>
34
- {% for source in branding.logoInverse.sources %}
35
- <source srcset="{{ source.srcSet }}"{% if source.media %} media="{{ source.media }}"{% endif %}{% if source.type %} type="{{ source.type }}"{% endif %}{% if source.sizes %} sizes="{{ source.sizes }}"{% endif %} />
36
- {% endfor %}
37
- <img src="{{ branding.logoInverse.fallback }}" alt="{{ branding.title }}" />
38
- </picture>
39
- {% else %}
40
- <img src="{{ branding.logoInverse }}" alt="{{ branding.title }}" />
41
- {% endif %}
42
- </div>
21
+ {% image src=branding.logoInverse alt=brandingLabel staticBaseUrl=staticBaseUrl className='usx-logo__variant usx-logo__variant--inverse' %}{% endimage %}
43
22
  {% endif %}
44
23
  </a>
45
24
  {% elif branding.symbol or branding.symbolInverse or branding.title %}
46
25
  <em class="usa-logo__text">
47
26
  {% if branding.symbol %}
48
- <img src="{{ branding.symbol }}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant" />
27
+ <img src="{% asset_url branding.symbol staticBaseUrl %}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant" />
49
28
  {% endif %}
50
29
  {% if branding.symbolInverse %}
51
- <img src="{{ branding.symbolInverse }}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant usx-logo__variant--inverse" />
30
+ <img src="{% asset_url branding.symbolInverse staticBaseUrl %}" alt="" aria-hidden="true" class="usx-logo__symbol usx-logo__variant usx-logo__variant--inverse" />
52
31
  {% endif %}
53
32
  {% if branding.title %}
54
33
  <a href="{{ projectUrl|default:'/' }}" class="usx-logo__title">{{ branding.title }}</a>
@@ -1,6 +1,6 @@
1
1
  <h3 class="site-preview-heading">Basic header</h3>
2
2
  <div class="usa-overlay"></div>
3
- <header class="usa-header usa-header--basic">
3
+ <header class="usa-header usx-header usa-header--basic">
4
4
  <div class="usa-nav-container">
5
5
  <div class="usa-navbar">
6
6
  <div class="usa-logo usx-logo">
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
  <button type="button" class="usa-menu-btn">Menu</button>
12
12
  </div>
13
- <nav aria-label="Primary navigation" class="usa-nav">
13
+ <nav aria-label="Primary navigation" class="usa-nav usx-nav">
14
14
  <button type="button" class="usa-nav__close">
15
15
  <img src="/img/usa-icons/close.svg" role="img" alt="Close" />
16
16
  </button>
@@ -104,7 +104,7 @@
104
104
 
105
105
  <h3 class="site-preview-heading">Basic header with megamenu</h3>
106
106
  <div class="usa-overlay"></div>
107
- <header class="usa-header usa-header--basic usa-header--megamenu">
107
+ <header class="usa-header usx-header usa-header--basic usa-header--megamenu">
108
108
  <div class="usa-nav-container">
109
109
  <div class="usa-navbar">
110
110
  <div class="usa-logo usx-logo">
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
  <button type="button" class="usa-menu-btn">Menu</button>
116
116
  </div>
117
- <nav aria-label="Primary navigation" class="usa-nav">
117
+ <nav aria-label="Primary navigation" class="usa-nav usx-nav">
118
118
  <button type="button" class="usa-nav__close">
119
119
  <img src="/img/usa-icons/close.svg" role="img" alt="Close" />
120
120
  </button>
@@ -295,7 +295,7 @@
295
295
 
296
296
  <h3 class="site-preview-heading">Extended header</h3>
297
297
  <div class="usa-overlay"></div>
298
- <header class="usa-header usa-header--extended">
298
+ <header class="usa-header usx-header usa-header--extended">
299
299
  <div class="usa-navbar">
300
300
  <div class="usa-logo usx-logo">
301
301
  <em class="usa-logo__text"
@@ -304,7 +304,7 @@
304
304
  </div>
305
305
  <button type="button" class="usa-menu-btn">Menu</button>
306
306
  </div>
307
- <nav aria-label="Primary navigation" class="usa-nav">
307
+ <nav aria-label="Primary navigation" class="usa-nav usx-nav">
308
308
  <div class="usa-nav__inner">
309
309
  <button type="button" class="usa-nav__close">
310
310
  <img src="/img/usa-icons/close.svg" role="img" alt="Close" />
@@ -413,7 +413,7 @@
413
413
 
414
414
  <h3 class="site-preview-heading">Basic header with megamenu</h3>
415
415
  <div class="usa-overlay"></div>
416
- <header class="usa-header usa-header--extended">
416
+ <header class="usa-header usx-header usa-header--extended">
417
417
  <div class="usa-navbar">
418
418
  <div class="usa-logo usx-logo">
419
419
  <em class="usa-logo__text"
@@ -422,7 +422,7 @@
422
422
  </div>
423
423
  <button type="button" class="usa-menu-btn">Menu</button>
424
424
  </div>
425
- <nav aria-label="Primary navigation" class="usa-nav">
425
+ <nav aria-label="Primary navigation" class="usa-nav usx-nav">
426
426
  <div class="usa-nav__inner">
427
427
  <button type="button" class="usa-nav__close">
428
428
  <img src="/img/usa-icons/close.svg" role="img" alt="Close" />
@@ -619,7 +619,7 @@
619
619
 
620
620
  <h3 class="site-preview-heading">Colored background w/ Logo</h3>
621
621
  <div class="usa-overlay"></div>
622
- <header class="usa-header usa-header--extended">
622
+ <header class="usa-header usx-header usa-header--extended">
623
623
  <div class="usa-navbar bg-primary-lighter">
624
624
  <div class="usa-logo usx-logo">
625
625
  <a href="/" class="usx-image usx-logo__image">
@@ -628,7 +628,7 @@
628
628
  </div>
629
629
  <button type="button" class="usa-menu-btn">Menu</button>
630
630
  </div>
631
- <nav aria-label="Primary navigation" class="usa-nav">
631
+ <nav aria-label="Primary navigation" class="usa-nav usx-nav">
632
632
  <div class="usa-nav__inner">
633
633
  <button type="button" class="usa-nav__close">
634
634
  <img src="/img/usa-icons/close.svg" role="img" alt="Close" />
@@ -1,12 +1,8 @@
1
1
  import React from 'react';
2
- import Button from '../button/Button';
2
+ import ClassNames from 'classnames';
3
+ import Button, { type ButtonProps } from '../button/Button';
3
4
  import Search, { SearchProps } from '../search/Search';
4
5
 
5
- export interface HeroButtonProps {
6
- href?: string;
7
- text: string;
8
- onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLButtonElement>;
9
- }
10
6
 
11
7
  export interface HeroSecondaryContent {
12
8
  title?: string;
@@ -18,7 +14,7 @@ export interface HeroProps extends React.HTMLAttributes<HTMLElement> {
18
14
  title?: string;
19
15
  callout?: string;
20
16
  paragraph?: string;
21
- button?: HeroButtonProps | null;
17
+ buttonProps?: ButtonProps | null;
22
18
  searchProps?: SearchProps | null;
23
19
  backgroundImage?: string;
24
20
  backgroundPosition?: React.CSSProperties['backgroundPosition'];
@@ -37,7 +33,7 @@ export default function Hero({
37
33
  title = '',
38
34
  callout = '',
39
35
  paragraph = '',
40
- button = null,
36
+ buttonProps = null,
41
37
  searchProps = null,
42
38
  backgroundImage = '',
43
39
  backgroundPosition,
@@ -56,7 +52,7 @@ export default function Hero({
56
52
  const Heading = headingLevel;
57
53
  const secondaryHeadings = { h1: 'h2', h2: 'h3', h3: 'h4', h4: 'h5', h5: 'h6' } as const;
58
54
  const SecondaryHeading = secondaryHeadings[headingLevel];
59
- const classes = [
55
+ const classes = ClassNames(
60
56
  'usx-hero',
61
57
  overlay && 'usx-hero--has-overlay',
62
58
  overlayOpacity !== undefined && 'usx-hero--custom-overlay',
@@ -64,7 +60,7 @@ export default function Hero({
64
60
  !boxed && 'usx-hero--unboxed',
65
61
  secondaryContent && 'usx-hero--split',
66
62
  className,
67
- ].filter(Boolean).join(' ');
63
+ );
68
64
 
69
65
  const heroStyle: React.CSSProperties & { '--hero-overlay-opacity'?: number } = {
70
66
  ...(backgroundImage ? { backgroundImage: `url('${backgroundImage}')` } : {}),
@@ -83,10 +79,8 @@ export default function Hero({
83
79
  </Heading>
84
80
  {paragraph && <p className="usx-hero__paragraph">{paragraph}</p>}
85
81
  {searchProps && <Search {...searchProps} />}
86
- {!searchProps && button && (
87
- <Button variant="primary" href={button.href} onClick={button.onClick}>
88
- {button.text}
89
- </Button>
82
+ {!searchProps && buttonProps && (
83
+ <Button {...buttonProps} />
90
84
  )}
91
85
  </div>
92
86
  {secondaryContent && (
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "hero",
3
3
  "template": "hero/hero.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "title": "The hero heading",
7
7
  "callout": "A callout heading",
8
8
  "paragraph": "A short description of the hero section that provides context for the call to action.",
9
- "button": {
9
+ "backgroundImage": "https://designsystem.digital.gov/img/introducing-uswds-2-0/built-to-grow--alt.jpg",
10
+ "overlay": true,
11
+ "buttonProps": {
10
12
  "href": "#",
11
13
  "text": "Call to action"
12
- },
13
- "backgroundImage": "https://designsystem.digital.gov/img/introducing-uswds-2-0/built-to-grow--alt.jpg",
14
- "overlay": true
14
+ }
15
15
  },
16
16
  "props": {
17
17
  "title": {
@@ -26,23 +26,10 @@
26
26
  "type": "string",
27
27
  "description": "Optional body paragraph text"
28
28
  },
29
- "button": {
29
+ "buttonProps": {
30
30
  "type": "object",
31
- "description": "Optional call-to-action button. Mutually exclusive with search.",
32
- "properties": {
33
- "href": {
34
- "type": "string",
35
- "description": "Button link URL"
36
- },
37
- "text": {
38
- "type": "string",
39
- "description": "Button label text"
40
- },
41
- "onClick": {
42
- "type": "function",
43
- "description": "Optional click handler for the button"
44
- }
45
- }
31
+ "component": "button",
32
+ "description": "Button props. Search takes precedence when searchProps is supplied."
46
33
  },
47
34
  "searchProps": {
48
35
  "type": "object",
@@ -55,7 +42,11 @@
55
42
  },
56
43
  "contentPosition": {
57
44
  "type": "select",
58
- "options": ["left", "center", "right"],
45
+ "options": [
46
+ "left",
47
+ "center",
48
+ "right"
49
+ ],
59
50
  "default": "left",
60
51
  "description": "Main content position. Secondary content sits opposite on desktop for left/right layouts, and below for centered or mobile layouts. Reading order always starts with the main content."
61
52
  },
@@ -74,7 +65,13 @@
74
65
  },
75
66
  "headingLevel": {
76
67
  "type": "select",
77
- "options": ["h1", "h2", "h3", "h4", "h5"],
68
+ "options": [
69
+ "h1",
70
+ "h2",
71
+ "h3",
72
+ "h4",
73
+ "h5"
74
+ ],
78
75
  "default": "h1",
79
76
  "description": "Main heading element, independent of visual size. Secondary content uses the next heading level."
80
77
  },
@@ -82,14 +79,26 @@
82
79
  "type": "object",
83
80
  "description": "Optional unboxed supporting content: title, paragraph, and link. Stacks after the main content on mobile; use overlay or a suitable background for readable contrast.",
84
81
  "properties": {
85
- "title": { "type": "string", "description": "Supporting heading" },
86
- "paragraph": { "type": "string", "description": "Supporting description" },
82
+ "title": {
83
+ "type": "string",
84
+ "description": "Supporting heading"
85
+ },
86
+ "paragraph": {
87
+ "type": "string",
88
+ "description": "Supporting description"
89
+ },
87
90
  "link": {
88
91
  "type": "object",
89
92
  "description": "Optional secondary text link",
90
93
  "properties": {
91
- "href": { "type": "string", "description": "Destination URL" },
92
- "text": { "type": "string", "description": "Link text" }
94
+ "href": {
95
+ "type": "string",
96
+ "description": "Destination URL"
97
+ },
98
+ "text": {
99
+ "type": "string",
100
+ "description": "Link text"
101
+ }
93
102
  }
94
103
  }
95
104
  }
@@ -14,8 +14,8 @@
14
14
  {% if paragraph %}<p class="usx-hero__paragraph">{{ paragraph }}</p>{% endif %}
15
15
  {% if searchProps %}
16
16
  {% search id=searchProps.id ariaLabel=searchProps.ariaLabel searchKey=searchProps.searchKey label=searchProps.label icon=searchProps.icon iconOnly=searchProps.iconOnly buttonVariant=searchProps.buttonVariant big=searchProps.big action=searchProps.action placeholder=searchProps.placeholder defaultValue=searchProps.defaultValue onSubmit=searchProps.onSubmit className=searchProps.className|default:'' %}{% endsearch %}
17
- {% elif button %}
18
- {% button variant="primary" href=button.href %}{{ button.text }}{% endbutton %}
17
+ {% elif buttonProps %}
18
+ {% button props=buttonProps %}{{ buttonProps.children|safe }}{% endbutton %}
19
19
  {% endif %}
20
20
  </div>
21
21
  {% if secondaryContent %}