@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solexllc/usx-react",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "React component library for USX.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,9 +25,9 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@solexllc/usx": "0.4.0",
29
- "@solexllc/usx-theme": "0.5.0",
30
- "@solexllc/usx-uswds-fixes": "0.1.9",
28
+ "@solexllc/usx": "0.6.0",
29
+ "@solexllc/usx-theme": "0.7.0",
30
+ "@solexllc/usx-uswds-fixes": "0.1.11",
31
31
  "classnames": "^2.5.1",
32
32
  "prop-types": "^15.8.1"
33
33
  },
@@ -43,6 +43,7 @@
43
43
  "react-dom": ">=17"
44
44
  },
45
45
  "scripts": {
46
- "build": "vite build"
46
+ "build": "vite build",
47
+ "test": "pnpm build && node test/toggle-check.mjs && node test/quote-check.mjs && node test/composition-check.mjs && node test/asset-url-check.mjs"
47
48
  }
48
49
  }
package/src/assets.ts ADDED
@@ -0,0 +1,16 @@
1
+ declare global {
2
+ interface Window {
3
+ usxBaseUrl?: string;
4
+ }
5
+ }
6
+
7
+ export function getAssetUrl(assetPath: string, staticBaseUrl?: string): string {
8
+ if (/^[a-z][a-z\d+.-]*:/i.test(assetPath)) return assetPath;
9
+ const base = staticBaseUrl || (typeof window !== 'undefined' && window.usxBaseUrl) || '/';
10
+ return `${base.replace(/\/+$/, '')}/${assetPath.replace(/^\/+/, '')}`;
11
+ }
12
+
13
+ export function getAssetSrcSet(srcSet: string, staticBaseUrl?: string): string {
14
+ return srcSet.replace(/(^\s*|,\s*)(\S*[^,\s])(?=,?(?:\s|$))/g, (_match, separator, url) =>
15
+ `${separator}${getAssetUrl(url, staticBaseUrl)}`);
16
+ }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
+ import Icon from '../icon/Icon';
3
4
 
4
5
  export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
5
6
  heading?: string;
@@ -12,6 +13,7 @@ export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
12
13
  ariaLabel?: string;
13
14
  ariaLabelledby?: string;
14
15
  onDismiss?: () => void;
16
+ staticBaseUrl?: string;
15
17
  children?: React.ReactNode;
16
18
  }
17
19
 
@@ -26,6 +28,7 @@ export default function Alert({
26
28
  ariaLabel,
27
29
  ariaLabelledby,
28
30
  onDismiss = undefined,
31
+ staticBaseUrl,
29
32
  children = null,
30
33
  ...props
31
34
  }: AlertProps) {
@@ -77,9 +80,7 @@ export default function Alert({
77
80
  )}
78
81
  {onDismiss && (
79
82
  <button className="usx-alert__dismiss" aria-label="Dismiss alert" onClick={onDismiss}>
80
- <svg className="usa-icon usa-icon--size-3" aria-hidden="true" focusable="false" role="img">
81
- <use href="./img/sprite.svg#close" />
82
- </svg>
83
+ <Icon name="close" size={3} staticBaseUrl={staticBaseUrl} />
83
84
  </button>
84
85
  )}
85
86
  </div>
@@ -1,3 +1,4 @@
1
+ {% load components %}
1
2
  <div
2
3
  class="
3
4
  usa-alert
@@ -36,9 +37,7 @@
36
37
  {% endif %}
37
38
  {% if onDismiss %}
38
39
  <button class="usx-alert__dismiss" aria-label="Dismiss alert" onclick="{{ onDismiss }}">
39
- <svg class="usa-icon usa-icon--size-3" aria-hidden="true" focusable="false" role="img">
40
- <use href="./img/sprite.svg#close"></use>
41
- </svg>
40
+ {% icon name='close' size='3' staticBaseUrl=staticBaseUrl aria-hidden="true" focusable="false" role="img" %}{% endicon %}
42
41
  </button>
43
42
  {% endif %}
44
43
  </div>
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "alert",
3
3
  "template": "alert/alert.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
+ "staticBaseUrl": {
7
+ "type": "string",
8
+ "description": "Optional asset base for this component. A non-empty value overrides window.usxBaseUrl in React or STATIC_URL in Django; otherwise the global base or / is used. Asset filenames remain separate."
9
+ },
6
10
  "heading": {
7
11
  "type": "string",
8
12
  "description": "The heading of the alert, which provides a brief summary of the alert's content."
@@ -37,8 +41,15 @@
37
41
  "description": "Additional CSS classes to apply to the alert component."
38
42
  },
39
43
  "style": {
40
- "type": "string",
41
- "description": "Inline styles to apply to the alert component."
44
+ "type": "object",
45
+ "description": "Inline styles as a React CSSProperties object.",
46
+ "renderers": {
47
+ "react": { "type": "object" },
48
+ "django": {
49
+ "supported": false,
50
+ "description": "The Django template does not render this prop."
51
+ }
52
+ }
42
53
  },
43
54
  "role": {
44
55
  "type": "select",
@@ -64,7 +75,7 @@
64
75
  },
65
76
  "children": {
66
77
  "type": "slot",
67
- "description": "Alert rich content (React node / HTML string). If provided, this content will be rendered instead of the `heading` and `text` props."
78
+ "description": "Alert content as text or composed content (React nodes or a Django template fragment). When truthy, replaces text; the heading remains visible unless slim is enabled."
68
79
  }
69
80
  }
70
81
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "attribution",
3
3
  "template": "attribution/attribution.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "avatarProps": {
7
7
  "type": "object",
@@ -9,19 +9,19 @@
9
9
  "component": "avatar"
10
10
  },
11
11
  "media": {
12
- "type": "string",
12
+ "type": "slot",
13
13
  "description": "HTML for the left media area (avatar image or initials badge)."
14
14
  },
15
15
  "primary": {
16
- "type": "string",
16
+ "type": "slot",
17
17
  "description": "Primary text shown in the top-right cell."
18
18
  },
19
19
  "secondary": {
20
- "type": "string",
20
+ "type": "slot",
21
21
  "description": "Secondary text shown in the bottom-right cell."
22
22
  },
23
23
  "children": {
24
- "type": "string",
24
+ "type": "slot",
25
25
  "description": "Optional full custom markup. When provided, it overrides media/primary/secondary."
26
26
  },
27
27
  "className": {
@@ -1,11 +1,13 @@
1
1
  import React from 'react';
2
2
  import Icon from '../icon/Icon';
3
3
  import ClassNames from 'classnames';
4
+ import { getAssetUrl as assetUrl } from '../../assets';
4
5
 
5
6
  export interface BannerProps extends React.HTMLAttributes<HTMLElement> {
6
7
  id?: string;
7
8
  ariaLabel?: string;
8
9
  flagSrc?: string;
10
+ staticBaseUrl?: string;
9
11
  tld?: string;
10
12
  bannerText?: string;
11
13
  bannerActionText?: string;
@@ -19,7 +21,8 @@ export interface BannerProps extends React.HTMLAttributes<HTMLElement> {
19
21
  export default function Banner({
20
22
  id = 'gov-banner',
21
23
  ariaLabel = 'Official government website',
22
- flagSrc = ((typeof window !== 'undefined' && (window as { usxBaseUrl?: string }).usxBaseUrl) || '/') + 'img/us_flag_small.png',
24
+ flagSrc,
25
+ staticBaseUrl,
23
26
  tld = '.gov',
24
27
  bannerText = 'An official website of the United States government',
25
28
  bannerActionText = "Here's how you know",
@@ -28,14 +31,13 @@ export default function Banner({
28
31
  httpsHeading = `Secure ${tld} websites use HTTPS`,
29
32
  httpsText = (
30
33
  <>
31
- A <strong>lock</strong> (<Icon name="lock" size={1} />) or <strong>https://</strong> means
34
+ A <strong>lock</strong> (<Icon name="lock" size={1} staticBaseUrl={staticBaseUrl} />) or <strong>https://</strong> means
32
35
  you’ve safely connected to the {tld} website. Share sensitive information only on official, secure websites.
33
36
  </>
34
37
  ),
35
38
  className = '',
36
39
  ...props
37
40
  }: BannerProps) {
38
- const assetBaseUrl = (typeof window !== 'undefined' && (window as { usxBaseUrl?: string }).usxBaseUrl) || '/';
39
41
  const classes = ClassNames(
40
42
  'usa-banner',
41
43
  'usx-banner',
@@ -50,7 +52,7 @@ export default function Banner({
50
52
  <img
51
53
  aria-hidden="true"
52
54
  className="usa-banner__header-flag"
53
- src={flagSrc}
55
+ src={assetUrl(flagSrc ?? 'img/us_flag_small.png', staticBaseUrl)}
54
56
  alt=""
55
57
  />
56
58
  </div>
@@ -82,7 +84,7 @@ export default function Banner({
82
84
  <div className="usa-banner__guidance tablet:grid-col-6">
83
85
  <img
84
86
  className="usa-banner__icon usa-media-block__img"
85
- src={`${assetBaseUrl}img/icon-dot-gov.svg`}
87
+ src={assetUrl('img/icon-dot-gov.svg', staticBaseUrl)}
86
88
  role="img"
87
89
  alt=""
88
90
  aria-hidden="true"
@@ -98,7 +100,7 @@ export default function Banner({
98
100
  <div className="usa-banner__guidance tablet:grid-col-6">
99
101
  <img
100
102
  className="usa-banner__icon usa-media-block__img"
101
- src={`${assetBaseUrl}img/icon-https.svg`}
103
+ src={assetUrl('img/icon-https.svg', staticBaseUrl)}
102
104
  role="img"
103
105
  alt=""
104
106
  aria-hidden="true"
@@ -1,5 +1,4 @@
1
1
  {% load components %}
2
- {% load static %}
3
2
  {# Django template for Banner #}
4
3
  {% with effective_tld=tld|default:'.gov' %}
5
4
  <section
@@ -14,7 +13,7 @@
14
13
  <img
15
14
  aria-hidden="true"
16
15
  class="usa-banner__header-flag"
17
- src="{% if flagSrc %}{{ flagSrc }}{% else %}{% static 'img/us_flag_small.png' %}{% endif %}"
16
+ src="{% asset_url flagSrc|default:'img/us_flag_small.png' staticBaseUrl %}"
18
17
  alt=""
19
18
  />
20
19
  </div>
@@ -46,7 +45,7 @@
46
45
  <div class="usa-banner__guidance tablet:grid-col-6">
47
46
  <img
48
47
  class="usa-banner__icon usa-media-block__img"
49
- src="{% static 'img/icon-dot-gov.svg' %}"
48
+ src="{% asset_url 'img/icon-dot-gov.svg' staticBaseUrl %}"
50
49
  role="img"
51
50
  alt=""
52
51
  aria-hidden="true"
@@ -61,7 +60,7 @@
61
60
  <div class="usa-banner__guidance tablet:grid-col-6">
62
61
  <img
63
62
  class="usa-banner__icon usa-media-block__img"
64
- src="{% static 'img/icon-https.svg' %}"
63
+ src="{% asset_url 'img/icon-https.svg' staticBaseUrl %}"
65
64
  role="img"
66
65
  alt=""
67
66
  aria-hidden="true"
@@ -69,7 +68,7 @@
69
68
  <div class="usa-media-block__body">
70
69
  <p>
71
70
  <strong>{% if httpsHeading %}{{ httpsHeading }}{% else %}Secure {{ effective_tld }} websites use HTTPS{% endif %}</strong><br/>
72
- {% if httpsText %}{{ httpsText|safe }}{% else %}A <strong>lock</strong> ({% icon name="lock" size=1 ariaHidden=True focusable=False %}{% endicon %}) or <strong>https://</strong> means you've safely connected to the {{ effective_tld }} website. Share sensitive information only on official, secure websites.{% endif %}
71
+ {% if httpsText %}{{ httpsText|safe }}{% else %}A <strong>lock</strong> ({% icon name="lock" size=1 staticBaseUrl=staticBaseUrl ariaHidden=True focusable=False %}{% endicon %}) or <strong>https://</strong> means you've safely connected to the {{ effective_tld }} website. Share sensitive information only on official, secure websites.{% endif %}
73
72
  </p>
74
73
  </div>
75
74
  </div>
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "banner",
3
3
  "template": "banner/banner.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
+ "staticBaseUrl": {
7
+ "type": "string",
8
+ "description": "Optional asset base for this component. A non-empty value overrides window.usxBaseUrl in React or STATIC_URL in Django; otherwise the global base or / is used. Asset filenames remain separate."
9
+ },
6
10
  "id": {
7
11
  "type": "string",
8
12
  "description": "The unique ID for the banner, used for aria-controls and element targeting."
@@ -13,7 +17,7 @@
13
17
  },
14
18
  "flagSrc": {
15
19
  "type": "string",
16
- "description": "URL for the decorative banner flag image. Defaults to img/us_flag_small.png under the configured asset base."
20
+ "description": "Asset path for the decorative flag, resolved under staticBaseUrl or the global asset base. Defaults to img/us_flag_small.png. Fully qualified URLs pass through unchanged."
17
21
  },
18
22
  "tld": {
19
23
  "type": "string",
@@ -40,7 +44,7 @@
40
44
  "description": "Heading text for HTTPS section."
41
45
  },
42
46
  "httpsText": {
43
- "type": "string",
47
+ "type": "slot",
44
48
  "description": "Body text for the HTTPS section."
45
49
  },
46
50
  "className": {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import ClassNames from 'classnames';
2
3
 
3
4
  export interface BreadcrumbItem {
4
5
  href?: string;
@@ -27,7 +28,7 @@ export default function Breadcrumb({
27
28
  ...props
28
29
  }: BreadcrumbProps) {
29
30
  if (!items || items.length === 0) {
30
- const classes = ['usx-breadcrumb', className].filter(Boolean).join(' ');
31
+ const classes = ClassNames('usx-breadcrumb', className);
31
32
  return (
32
33
  <div className={classes} {...props}>
33
34
  {children || 'Breadcrumb'}
@@ -35,15 +36,13 @@ export default function Breadcrumb({
35
36
  );
36
37
  }
37
38
 
38
- const navClasses = [
39
+ const navClasses = ClassNames(
39
40
  'usa-breadcrumb',
40
41
  'usx-breadcrumb',
41
42
  wrap ? 'usa-breadcrumb--wrap' : null,
42
43
  truncate ? 'usa-breadcrumb--truncate' : null,
43
44
  className,
44
- ]
45
- .filter(Boolean)
46
- .join(' ');
45
+ );
47
46
 
48
47
  return (
49
48
  <nav className={navClasses} aria-label={ariaLabel} {...props}>
@@ -53,7 +52,7 @@ export default function Breadcrumb({
53
52
  >
54
53
  {items.map((item, idx) => {
55
54
  const isCurrent = !!item.current;
56
- const liClass = ['usa-breadcrumb__list-item', isCurrent ? 'usa-current' : null].filter(Boolean).join(' ');
55
+ const liClass = ClassNames('usa-breadcrumb__list-item', isCurrent ? 'usa-current' : null);
57
56
 
58
57
  return (
59
58
  <li
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "breadcrumb",
3
3
  "template": "breadcrumb/breadcrumb.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "items": [
7
7
  {
@@ -69,6 +69,16 @@
69
69
  "className": {
70
70
  "type": "string",
71
71
  "description": "Additional CSS classes to add to the nav element"
72
+ },
73
+ "children": {
74
+ "type": "slot",
75
+ "description": "Fallback content rendered when no breadcrumb items are supplied (React only).",
76
+ "renderers": {
77
+ "django": {
78
+ "supported": false,
79
+ "description": "The Django template does not consume children."
80
+ }
81
+ }
72
82
  }
73
83
  }
74
84
  }
@@ -70,7 +70,7 @@ export default function Button({
70
70
  const classes = ClassNames(
71
71
  'usa-button',
72
72
  'usx-button',
73
- variant ? variantClasses[variant] : variantClasses['primary'],
73
+ variant && variantClasses[variant],
74
74
  big && 'usa-button--big',
75
75
  inverse && 'usa-button--inverse',
76
76
  ghost && 'usx-button--ghost',
@@ -5,7 +5,7 @@
5
5
  href="{{ href }}"
6
6
  class="
7
7
  usa-button usx-button
8
- usa-button--{{ variant|default:'primary' }}
8
+ {% if variant %} usa-button--{{ variant }}{% endif %}
9
9
  {% if big == True %} usa-button--big{% endif %}
10
10
  {% if disabled == True %} usa-button--disabled{% endif %}
11
11
  {% if inverse == True %} usa-button--inverse{% endif %}
@@ -21,7 +21,7 @@
21
21
  type="{{ type|default:'button' }}"
22
22
  class="
23
23
  usa-button usx-button
24
- usa-button--{{ variant|default:'primary' }}
24
+ {% if variant %} usa-button--{{ variant }}{% endif %}
25
25
  {% if big == True %} usa-button--big{% endif %}
26
26
  {% if disabled == True %} usa-button--disabled{% endif %}
27
27
  {% if inverse == True %} usa-button--inverse{% endif %}
@@ -183,7 +183,7 @@
183
183
  </button>
184
184
 
185
185
  <h3 class="site-preview-heading">Outline inverse</h3>
186
- <div class="bg-base-darkest padding-1" style="max-width: fit-content">
186
+ <div class="bg-surface-inverse padding-1" style="max-width: fit-content">
187
187
  <button
188
188
  class="usa-button usx-button usa-button--outline usa-button--inverse"
189
189
  type="button"
@@ -356,7 +356,7 @@
356
356
  Copy
357
357
  </button>
358
358
  </div>
359
- <div class="margin-bottom-3 bg-primary-darkest padding-1">
359
+ <div class="margin-bottom-3 bg-surface-inverse padding-1">
360
360
  <button class="usa-button usx-button usx-button--ghost usa-button--inverse" type="button">
361
361
  Inverse
362
362
  </button>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "button",
3
3
  "template": "button/button.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "label": {
7
7
  "type": "string",
@@ -15,7 +15,8 @@
15
15
  "accent-cool",
16
16
  "accent-warm",
17
17
  "base",
18
- "outline"
18
+ "outline",
19
+ "unstyled"
19
20
  ],
20
21
  "description": "The visual style of the button, which can be used to indicate the importance or type of action the button represents."
21
22
  },
@@ -88,12 +89,19 @@
88
89
  "description": "Additional CSS classes to apply to the button component."
89
90
  },
90
91
  "style": {
91
- "type": "string",
92
- "description": "Inline styles to apply to the button component."
92
+ "type": "object",
93
+ "description": "Inline styles as a React CSSProperties object.",
94
+ "renderers": {
95
+ "react": { "type": "object" },
96
+ "django": {
97
+ "supported": false,
98
+ "description": "The Django template does not render this prop."
99
+ }
100
+ }
93
101
  },
94
102
  "children": {
95
- "type": "string",
96
- "description": "Inner HTML or text to be displayed within the button, allowing for more complex content such as additional elements or formatting."
103
+ "type": "slot",
104
+ "description": "Button content as text or composed content (React nodes or a Django template fragment); takes precedence over label when truthy."
97
105
  },
98
106
  "extraAttributes": {
99
107
  "type": "object",
@@ -3,7 +3,7 @@
3
3
  <ul class="usa-button-group usx-button-group {% if segmented %}usa-button-group--segmented{% endif %} {{ className }}">
4
4
  {% for item in buttonProps %}
5
5
  <li class="usa-button-group__item{% if item.itemClassName %} {{ item.itemClassName }}{% endif %}">
6
- {% button label=item.label variant=item.variant type=item.type disabled=item.disabled onClick=item.onClick href=item.href isExternal=item.isExternal big=item.big inverse=item.inverse loading=item.loading iconProps=item.iconProps className=item.className style=item.style extraAttributes=item.extraAttributes %}{{ item.children }}{% endbutton %}
6
+ {% button props=item %}{{ item.children|safe }}{% endbutton %}
7
7
  </li>
8
8
  {% endfor %}
9
9
  </ul>
@@ -1,8 +1,8 @@
1
1
  {% load components %}
2
2
 
3
- <div class="{% if under_collection %}usa-collection__calendar-date{% endif %} usx-calendar-date">
3
+ <div class="{% if underCollection %}usa-collection__calendar-date{% endif %} usx-calendar-date">
4
4
  <time datetime="{{ datetime }}">
5
- <span class="{% if under_collection %}usa-collection__calendar-date-month{% endif %} usx-calendar-date-month">{{ datetime|parse_iso|date:"M"|upper }}</span>
6
- <span class="{% if under_collection %}usa-collection__calendar-date-day{% endif %} usx-calendar-date-day">{{ datetime|parse_iso|date:"j" }}</span>
5
+ <span class="{% if underCollection %}usa-collection__calendar-date-month{% endif %} usx-calendar-date-month">{{ datetime|parse_iso|date:"M"|upper }}</span>
6
+ <span class="{% if underCollection %}usa-collection__calendar-date-day{% endif %} usx-calendar-date-day">{{ datetime|parse_iso|date:"j" }}</span>
7
7
  </time>
8
8
  </div>
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import ClassNames from 'classnames';
3
+
4
+ export interface CalloutProps extends Omit<React.HTMLAttributes<HTMLElement>, 'content' | 'color'> {
5
+ className?: string;
6
+ strokeColor?: string;
7
+ indent?: 'sm' | 'md' | 'lg' | 'xl' | null;
8
+ dedent?: boolean;
9
+ big?: boolean;
10
+ orientation?: 'horizontal' | 'vertical';
11
+ children?: React.ReactNode;
12
+ content?: React.ReactNode;
13
+ backgroundColor?: string;
14
+ textColor?: string;
15
+ element?: 'div' | 'section' | 'aside' | 'blockquote';
16
+ cite?: string;
17
+ }
18
+
19
+ export default function Callout({
20
+ className,
21
+ strokeColor,
22
+ indent,
23
+ dedent,
24
+ big,
25
+ orientation = 'horizontal',
26
+ children,
27
+ content,
28
+ backgroundColor,
29
+ textColor,
30
+ element = 'div',
31
+ ...props
32
+ }: CalloutProps) {
33
+ const Element = element;
34
+
35
+ return (
36
+ <Element
37
+ className={ClassNames(
38
+ 'usx-callout',
39
+ orientation === 'vertical' && 'usx-callout--vertical',
40
+ strokeColor && `usx-border-${strokeColor}`,
41
+ indent && `usx-callout--indent-${indent}`,
42
+ dedent && 'usx-callout--dedent',
43
+ (big ?? orientation === 'horizontal') && 'usx-callout--big',
44
+ backgroundColor && `bg-${backgroundColor}`,
45
+ textColor && `text-${textColor}`,
46
+ className
47
+ )}
48
+ {...props}
49
+ >
50
+ {children ?? content}
51
+ </Element>
52
+ );
53
+ }
@@ -0,0 +1,5 @@
1
+ {% with tag=element|default:'div' %}
2
+ <{% if tag == 'section' or tag == 'aside' or tag == 'blockquote' %}{{ tag }}{% else %}div{% endif %} class="usx-callout{% if orientation == 'vertical' %} usx-callout--vertical{% endif %}{% if strokeColor %} usx-border-{{ strokeColor }}{% endif %}{% if indent %} usx-callout--indent-{{ indent }}{% endif %}{% if dedent %} usx-callout--dedent{% endif %}{% if big or orientation|default:'horizontal' == 'horizontal' %}{% if big is not False %} usx-callout--big{% endif %}{% endif %}{% if backgroundColor %} bg-{{ backgroundColor }}{% endif %}{% if textColor %} text-{{ textColor }}{% endif %}{% if className %} {{ className }}{% endif %}"{% if tag == 'blockquote' and cite %} cite="{{ cite }}"{% endif %}>
3
+ {% if children != None %}{{ children|safe }}{% elif content != None %}{{ content|safe }}{% endif %}
4
+ </{% if tag == 'section' or tag == 'aside' or tag == 'blockquote' %}{{ tag }}{% else %}div{% endif %}>
5
+ {% endwith %}
@@ -0,0 +1,76 @@
1
+ <div class="padding-3">
2
+ <section class="margin-bottom-4">
3
+ <h2>Default</h2>
4
+ <div class="usx-callout usx-callout--big">Related information goes here.</div>
5
+ </section>
6
+
7
+ <section class="margin-bottom-4">
8
+ <h2>Thin Horizontal</h2>
9
+ <div class="usx-callout usx-border-info">A horizontal callout with a thinner left border.</div>
10
+ </section>
11
+
12
+ <section class="margin-bottom-4">
13
+ <h2>Vertical</h2>
14
+ <div class="usx-callout usx-callout--vertical">A vertical callout with its default top border.</div>
15
+ </section>
16
+
17
+ <section class="margin-bottom-4">
18
+ <h2>Big Vertical</h2>
19
+ <div class="usx-callout usx-callout--vertical usx-border-info usx-callout--big">A vertical callout with a thicker top border.</div>
20
+ </section>
21
+
22
+ <section class="margin-bottom-4">
23
+ <h2>Colors</h2>
24
+ <div class="usx-callout usx-border-primary usx-callout--big bg-base-lightest text-primary padding-y-2 padding-right-2">Independent border, background, text, and spacing styles.</div>
25
+ </section>
26
+
27
+ <section class="margin-bottom-4">
28
+ <h2>Indent SM</h2>
29
+ <div class="usx-callout usx-callout--indent-sm usx-callout--big">Indent: sm.</div>
30
+ </section>
31
+
32
+ <section class="margin-bottom-4">
33
+ <h2>Indent MD</h2>
34
+ <div class="usx-callout usx-callout--indent-md usx-callout--big">Indent: md.</div>
35
+ </section>
36
+
37
+ <section class="margin-bottom-4">
38
+ <h2>Indent LG</h2>
39
+ <div class="usx-callout usx-callout--indent-lg usx-callout--big">Indent: lg.</div>
40
+ </section>
41
+
42
+ <section class="margin-bottom-4">
43
+ <h2>Indent XL</h2>
44
+ <div class="usx-callout usx-callout--indent-xl usx-callout--big">Indent: xl.</div>
45
+ </section>
46
+
47
+ <section class="margin-bottom-4">
48
+ <h2>Dedent</h2>
49
+ <div class="usx-callout usx-callout--dedent usx-callout--big">Pulled left beyond the normal content edge.</div>
50
+ </section>
51
+
52
+ <section class="margin-bottom-4">
53
+ <h2>Section</h2>
54
+ <section class="usx-callout usx-callout--big"><h3>Program details</h3><p>Related information in a semantic section.</p></section>
55
+ </section>
56
+
57
+ <section class="margin-bottom-4">
58
+ <h2>Aside</h2>
59
+ <aside class="usx-callout usx-callout--big">Supplementary information in an aside.</aside>
60
+ </section>
61
+
62
+ <section class="margin-bottom-4">
63
+ <h2>Blockquote</h2>
64
+ <blockquote class="usx-callout usx-callout--big" cite="https://example.com/report">A sourced quotation using the blockquote root.</blockquote>
65
+ </section>
66
+
67
+ <section class="margin-bottom-4">
68
+ <h2>Children Override</h2>
69
+ <div class="usx-callout usx-callout--big"><p><strong>Children win.</strong> Rich content can include <a class="usa-link usx-link usa-link--external" href="#details">links</a> and emphasis.</p></div>
70
+ </section>
71
+
72
+ <section class="margin-bottom-4">
73
+ <h2>Empty Children</h2>
74
+ <div class="usx-callout usx-callout--big padding-y-2"></div>
75
+ </section>
76
+ </div>