@solexllc/usx-react 0.4.0 → 0.6.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 (105) hide show
  1. package/README.md +99 -0
  2. package/dist/index.cjs +576 -442
  3. package/dist/index.js +576 -442
  4. package/package.json +5 -5
  5. package/src/components/attribution/config.json +5 -5
  6. package/src/components/banner/config.json +2 -2
  7. package/src/components/breadcrumb/Breadcrumb.tsx +5 -6
  8. package/src/components/breadcrumb/config.json +11 -1
  9. package/src/components/button/button.html +2 -2
  10. package/src/components/button-group/button-group.django.html +1 -1
  11. package/src/components/calendar-date/calendar-date.django.html +3 -3
  12. package/src/components/callout/Callout.tsx +53 -0
  13. package/src/components/callout/callout.django.html +5 -0
  14. package/src/components/callout/callout.html +76 -0
  15. package/src/components/callout/config.json +74 -0
  16. package/src/components/card/Card.tsx +18 -34
  17. package/src/components/card/card.django.html +12 -10
  18. package/src/components/card/config.json +15 -40
  19. package/src/components/card-group/card-group.django.html +1 -1
  20. package/src/components/carousel/Carousel.tsx +3 -2
  21. package/src/components/carousel/carousel.django.html +13 -2
  22. package/src/components/carousel/config.json +2 -2
  23. package/src/components/character-count/config.json +2 -2
  24. package/src/components/checkbox-group/CheckboxGroup.tsx +10 -20
  25. package/src/components/checkbox-group/checkbox-group.django.html +10 -4
  26. package/src/components/checkbox-group/config.json +10 -5
  27. package/src/components/clickable/clickable.html +21 -39
  28. package/src/components/clickable/config.json +2 -2
  29. package/src/components/collection/Collection.tsx +5 -5
  30. package/src/components/collection/collection.django.html +2 -4
  31. package/src/components/collection/config.json +7 -6
  32. package/src/components/combobox/config.json +4 -4
  33. package/src/components/container/Container.tsx +108 -0
  34. package/src/components/container/_layout-classes.django.html +12 -0
  35. package/src/components/container/config.json +288 -0
  36. package/src/components/container/container.django.html +13 -0
  37. package/src/components/container/container.html +125 -0
  38. package/src/components/date-picker/config.json +4 -4
  39. package/src/components/date-range-picker/config.json +7 -7
  40. package/src/components/error-message/config.json +2 -2
  41. package/src/components/eyebrow/Eyebrow.tsx +2 -1
  42. package/src/components/eyebrow/config.json +2 -2
  43. package/src/components/fieldset/config.json +5 -5
  44. package/src/components/file-input/FileInput.tsx +3 -2
  45. package/src/components/file-input/config.json +5 -5
  46. package/src/components/file-list/FileList.tsx +2 -1
  47. package/src/components/file-list/config.json +2 -2
  48. package/src/components/footer/Footer.tsx +5 -5
  49. package/src/components/form-group/config.json +2 -2
  50. package/src/components/hero/Hero.tsx +8 -14
  51. package/src/components/hero/config.json +36 -27
  52. package/src/components/hero/hero.django.html +2 -2
  53. package/src/components/hint/config.json +2 -2
  54. package/src/components/in-page-nav/config.json +11 -1
  55. package/src/components/indicator/config.json +2 -2
  56. package/src/components/input/config.json +2 -2
  57. package/src/components/label/config.json +2 -2
  58. package/src/components/language-selector/config.json +2 -2
  59. package/src/components/layout/Layout.tsx +1 -1
  60. package/src/components/legend/config.json +3 -3
  61. package/src/components/link/config.json +2 -2
  62. package/src/components/memorable-date/config.json +9 -9
  63. package/src/components/misc-banner/MiscBanner.tsx +2 -1
  64. package/src/components/misc-banner/config.json +2 -2
  65. package/src/components/modal/config.json +2 -2
  66. package/src/components/page/Page.tsx +2 -1
  67. package/src/components/page/config.json +7 -7
  68. package/src/components/page/page.django.html +1 -1
  69. package/src/components/pagination/Pagination.tsx +2 -1
  70. package/src/components/pagination/container/PaginationContainer.tsx +2 -1
  71. package/src/components/prose/config.json +5 -1
  72. package/src/components/quote/Quote.tsx +58 -0
  73. package/src/components/quote/config.json +51 -0
  74. package/src/components/quote/quote.django.html +15 -0
  75. package/src/components/quote/quote.html +66 -0
  76. package/src/components/radio-buttons/config.json +3 -3
  77. package/src/components/range-slider/RangeSlider.tsx +2 -1
  78. package/src/components/range-slider/config.json +4 -4
  79. package/src/components/required/config.json +2 -2
  80. package/src/components/section/Section.tsx +6 -2
  81. package/src/components/section/config.json +19 -6
  82. package/src/components/section/section.django.html +9 -2
  83. package/src/components/select/config.json +2 -2
  84. package/src/components/site-alert/SiteAlert.tsx +5 -6
  85. package/src/components/skipnav/config.json +2 -2
  86. package/src/components/summary-box/config.json +3 -3
  87. package/src/components/swap/Swap.tsx +4 -3
  88. package/src/components/swap/config.json +4 -4
  89. package/src/components/switch/config.json +2 -2
  90. package/src/components/table/config.json +13 -3
  91. package/src/components/tag/config.json +2 -2
  92. package/src/components/tag-group/config.json +2 -2
  93. package/src/components/text-area/config.json +2 -2
  94. package/src/components/time-picker/config.json +4 -4
  95. package/src/components/toggle/Toggle.tsx +69 -40
  96. package/src/components/toggle/config.json +42 -10
  97. package/src/components/toggle/toggle.django.html +25 -17
  98. package/src/components/toggle/toggle.html +319 -85
  99. package/src/components/tooltip/config.json +2 -2
  100. package/src/components/villain/Villain.tsx +2 -1
  101. package/src/index.js +3 -1
  102. package/src/components/block/Block.tsx +0 -78
  103. package/src/components/block/block.django.html +0 -26
  104. package/src/components/block/block.html +0 -162
  105. 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.4.0",
3
+ "version": "0.6.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.5.0",
29
- "@solexllc/usx-theme": "0.6.0",
30
- "@solexllc/usx-uswds-fixes": "0.1.10",
28
+ "@solexllc/usx": "0.7.0",
29
+ "@solexllc/usx-theme": "0.8.0",
30
+ "@solexllc/usx-uswds-fixes": "0.1.12",
31
31
  "classnames": "^2.5.1",
32
32
  "prop-types": "^15.8.1"
33
33
  },
@@ -44,6 +44,6 @@
44
44
  },
45
45
  "scripts": {
46
46
  "build": "vite build",
47
- "test": "pnpm build && node test/asset-url-check.mjs"
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 && node test/container-check.mjs"
48
48
  }
49
49
  }
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "name": "banner",
3
3
  "template": "banner/banner.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "staticBaseUrl": {
7
7
  "type": "string",
@@ -44,7 +44,7 @@
44
44
  "description": "Heading text for HTTPS section."
45
45
  },
46
46
  "httpsText": {
47
- "type": "string",
47
+ "type": "slot",
48
48
  "description": "Body text for the HTTPS section."
49
49
  },
50
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
  }
@@ -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>
@@ -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 && `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 %} 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 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 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 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>
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "callout",
3
+ "template": "callout/callout.django.html",
4
+ "version": 1,
5
+ "props": {
6
+ "className": {
7
+ "type": "string",
8
+ "description": "Additional classes."
9
+ },
10
+ "strokeColor": {
11
+ "type": "string",
12
+ "description": "Border color token. Omit to leave the border color utility unset."
13
+ },
14
+ "indent": {
15
+ "type": "select",
16
+ "description": "Left indentation.",
17
+ "options": [
18
+ "sm",
19
+ "md",
20
+ "lg",
21
+ "xl"
22
+ ]
23
+ },
24
+ "dedent": {
25
+ "type": "boolean",
26
+ "description": "Pull the callout left beyond the content edge.",
27
+ "default": false
28
+ },
29
+ "big": {
30
+ "type": "boolean",
31
+ "description": "Use a thicker border."
32
+ },
33
+ "orientation": {
34
+ "type": "select",
35
+ "description": "Horizontal uses a left border; vertical uses a top border.",
36
+ "options": [
37
+ "horizontal",
38
+ "vertical"
39
+ ],
40
+ "default": "horizontal"
41
+ },
42
+ "children": {
43
+ "type": "slot",
44
+ "description": "Body content. Takes precedence over content when supplied."
45
+ },
46
+ "content": {
47
+ "type": "slot",
48
+ "description": "Fallback body content, ignored when children is supplied."
49
+ },
50
+ "backgroundColor": {
51
+ "type": "string",
52
+ "description": "Background utility token: bg-{backgroundColor}."
53
+ },
54
+ "textColor": {
55
+ "type": "string",
56
+ "description": "Text utility token: text-{textColor}."
57
+ },
58
+ "element": {
59
+ "type": "select",
60
+ "description": "Root HTML element.",
61
+ "options": [
62
+ "div",
63
+ "section",
64
+ "aside",
65
+ "blockquote"
66
+ ],
67
+ "default": "div"
68
+ },
69
+ "cite": {
70
+ "type": "string",
71
+ "description": "Source URL when the root element is blockquote."
72
+ }
73
+ }
74
+ }
@@ -2,32 +2,16 @@ import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
  import ButtonGroup from '../button-group/ButtonGroup';
4
4
  import type { ButtonGroupItemProps } from '../button-group/ButtonGroup';
5
- import Tag from '../tag/Tag';
6
- import Image from '../image/Image';
5
+ import Tag, { type TagProps } from '../tag/Tag';
6
+ import Image, { type ImageProps } from '../image/Image';
7
7
  import Carousel from '../carousel/Carousel';
8
8
 
9
- export interface CardTag {
10
- value: string;
11
- color?: string;
12
- }
13
-
14
- export interface CardAction {
15
- children: string;
16
- variant?: ButtonGroupItemProps['variant'];
17
- onClick?: () => void;
18
- }
19
-
20
- export interface CardImage {
21
- src: string;
22
- alt: string;
23
- }
24
-
25
9
  export interface CardProps extends React.HTMLAttributes<HTMLElement> {
26
10
  title?: string;
27
11
  description?: string;
28
- tags?: CardTag[];
29
- actions?: CardAction[];
30
- images?: CardImage[];
12
+ tagProps?: TagProps[];
13
+ buttonProps?: ButtonGroupItemProps[];
14
+ imageProps?: ImageProps[];
31
15
  headerFirst?: boolean;
32
16
  flag?: boolean;
33
17
  mediaRight?: boolean;
@@ -42,9 +26,9 @@ export interface CardProps extends React.HTMLAttributes<HTMLElement> {
42
26
  export default function Card({
43
27
  title,
44
28
  description,
45
- tags,
46
- actions,
47
- images,
29
+ tagProps,
30
+ buttonProps,
31
+ imageProps,
48
32
  headerFirst = false,
49
33
  flag = false,
50
34
  mediaRight = false,
@@ -75,22 +59,22 @@ export default function Card({
75
59
  }
76
60
  );
77
61
 
78
- const hasStructuredContent = title || description || tags || actions || images;
62
+ const hasStructuredContent = title || description || tagProps || buttonProps || imageProps;
79
63
  const shouldRenderStructured = hasStructuredContent && !children;
80
64
 
81
- const hasImages = images && images.length > 0;
82
- const useCarousel = images && images.length > 1;
65
+ const hasImages = imageProps && imageProps.length > 0;
66
+ const useCarousel = imageProps && imageProps.length > 1;
83
67
  const media = useCarousel ? (
84
68
  <Carousel
85
69
  id={`${props.id || 'card'}-carousel`}
86
70
  showDots={showCarouselDots}
87
71
  className="usx-card__carousel"
88
- slides={images?.map((img, index) => ({
89
- content: <Image key={index} {...img} hideCaption={true} />,
72
+ slides={imageProps?.map((img, index) => ({
73
+ content: <Image key={index} hideCaption={true} {...img} />,
90
74
  }))}
91
75
  />
92
76
  ) : hasImages ? (
93
- <Image {...images[0]} hideCaption={true} className="usa-card__img" />
77
+ <Image hideCaption={true} {...imageProps[0]} className={ClassNames('usa-card__img', imageProps[0].className)} />
94
78
  ) : null;
95
79
 
96
80
  return (
@@ -111,9 +95,9 @@ export default function Card({
111
95
  )}
112
96
 
113
97
  <div className="usa-card__body">
114
- {tags && tags.length > 0 && (
98
+ {tagProps && tagProps.length > 0 && (
115
99
  <div className="usx-tag-group">
116
- {tags.map((tag, index) => (
100
+ {tagProps.map((tag, index) => (
117
101
  <Tag key={index} {...tag} />
118
102
  ))}
119
103
  </div>
@@ -123,9 +107,9 @@ export default function Card({
123
107
  )}
124
108
  </div>
125
109
 
126
- {actions && actions.length > 0 && (
110
+ {buttonProps && buttonProps.length > 0 && (
127
111
  <div className="usa-card__footer">
128
- <ButtonGroup buttonProps={actions} className="flex-wrap" />
112
+ <ButtonGroup buttonProps={buttonProps} className="flex-wrap" />
129
113
  </div>
130
114
  )}
131
115
  </>
@@ -3,26 +3,28 @@
3
3
  <div class="usa-card__container">
4
4
  {% if children %}
5
5
  {{ children }}
6
- {% elif title or description or tags or actions or images %}
6
+ {% elif title or description or tagProps or buttonProps or imageProps %}
7
7
  {% if title %}
8
8
  <div class="usa-card__header">
9
9
  <h4 class="usa-card__heading">{{ title }}</h4>
10
10
  </div>
11
11
  {% endif %}
12
- {% if images and images|length > 1 %}
12
+ {% if imageProps and imageProps|length > 1 %}
13
13
  <div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
14
- {% carousel slides=images id=id|default:'card'|add:'-carousel' showDots=showCarouselDots|default_bool:True className='usx-card__carousel' %}{% endcarousel %}
14
+ {% carousel slides=imageProps id=id|default:'card'|add:'-carousel' showDots=showCarouselDots|default_bool:True className='usx-card__carousel' %}{% endcarousel %}
15
15
  </div>
16
- {% elif images and images.0 %}
16
+ {% elif imageProps and imageProps.0 %}
17
17
  <div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
18
- {% image src=images.0.src alt=images.0.alt caption=images.0.caption hideCaption=True href=images.0.href rounded=images.0.rounded circular=images.0.circular objectFit=images.0.objectFit maxWidth=images.0.maxWidth maxHeight=images.0.maxHeight className='usa-card__img' %}{% endimage %}
18
+ {% with imageClass=imageProps.0.className|default:'' %}
19
+ {% image props=imageProps.0 hideCaption=imageProps.0.hideCaption|default_bool:True className='usa-card__img '|add:imageClass %}{{ imageProps.0.children|safe }}{% endimage %}
20
+ {% endwith %}
19
21
  </div>
20
22
  {% endif %}
21
23
  <div class="usa-card__body">
22
- {% if tags %}
24
+ {% if tagProps %}
23
25
  <div class="usx-tag-group">
24
- {% for tag in tags %}
25
- {% tag value=tag.value color=tag.color %}{% endtag %}
26
+ {% for tag in tagProps %}
27
+ {% tag props=tag %}{{ tag.children|safe }}{% endtag %}
26
28
  {% endfor %}
27
29
  </div>
28
30
  {% endif %}
@@ -30,9 +32,9 @@
30
32
  <p>{{ description }}</p>
31
33
  {% endif %}
32
34
  </div>
33
- {% if actions %}
35
+ {% if buttonProps %}
34
36
  <div class="usa-card__footer">
35
- {% button_group buttonProps=actions className='flex-wrap' %}{% endbutton_group %}
37
+ {% button_group buttonProps=buttonProps className='flex-wrap' %}{% endbutton_group %}
36
38
  </div>
37
39
  {% endif %}
38
40
  {% else %}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "card",
3
3
  "template": "card/card.django.html",
4
- "version": 1,
4
+ "version": 3,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
@@ -15,62 +15,37 @@
15
15
  "type": "string",
16
16
  "description": "The description text displayed in the card body"
17
17
  },
18
- "tags": {
18
+ "tagProps": {
19
19
  "type": "array",
20
- "description": "Array of tag objects with value and color properties",
20
+ "description": "Props for each tag component.",
21
21
  "items": {
22
22
  "type": "object",
23
- "description": "Card tag.",
24
- "properties": {
25
- "value": {
26
- "type": "string",
27
- "description": "Tag text"
28
- },
29
- "color": {
30
- "type": "string",
31
- "description": "Tag color variant"
32
- }
33
- }
23
+ "component": "tag",
24
+ "description": "Props passed to the tag component."
34
25
  }
35
26
  },
36
- "actions": {
27
+ "buttonProps": {
37
28
  "type": "array",
38
- "description": "Array of action button objects",
29
+ "description": "Props for each button component.",
39
30
  "items": {
40
31
  "type": "object",
41
- "description": "Card action button.",
32
+ "component": "button",
33
+ "description": "Props passed to the button component.",
42
34
  "properties": {
43
- "children": {
44
- "type": "string",
45
- "description": "Button text"
46
- },
47
- "variant": {
35
+ "itemClassName": {
48
36
  "type": "string",
49
- "description": "Button variant"
50
- },
51
- "onClick": {
52
- "type": "function",
53
- "description": "Click handler"
37
+ "description": "Additional classes for the button group list item."
54
38
  }
55
39
  }
56
40
  }
57
41
  },
58
- "images": {
42
+ "imageProps": {
59
43
  "type": "array",
60
- "description": "Array of image objects; multiple images render as a carousel",
44
+ "description": "Props for each image component.",
61
45
  "items": {
62
46
  "type": "object",
63
- "description": "Card image.",
64
- "properties": {
65
- "src": {
66
- "type": "string",
67
- "description": "Image source URL"
68
- },
69
- "alt": {
70
- "type": "string",
71
- "description": "Alt text for the image"
72
- }
73
- }
47
+ "component": "image",
48
+ "description": "Props passed to the image component."
74
49
  }
75
50
  },
76
51
  "headerFirst": {
@@ -1,6 +1,6 @@
1
1
  {% load components %}
2
2
  <ul class="usa-card-group usx-card-group{% if className %} {{ className }}{% endif %}">
3
3
  {% for card in cardProps %}
4
- {% card tag='li' title=card.title description=card.description footer=card.footer actions=card.actions images=card.images flag=card.flag mediaRight=card.mediaRight headerFirst=card.headerFirst className=card.className %}{% endcard %}
4
+ {% card props=card tag='li' %}{{ card.children|safe }}{% endcard %}
5
5
  {% endfor %}
6
6
  </ul>