@solexllc/usx-react 0.1.8 → 0.3.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 (33) hide show
  1. package/README.md +93 -0
  2. package/dist/index.cjs +27 -16
  3. package/dist/index.js +27 -16
  4. package/package.json +4 -4
  5. package/src/components/accordion/Accordion.tsx +10 -5
  6. package/src/components/accordion/accordion.django.html +5 -5
  7. package/src/components/accordion/config.json +11 -1
  8. package/src/components/button/Button.tsx +1 -1
  9. package/src/components/button/button.django.html +3 -3
  10. package/src/components/button-group/ButtonGroup.tsx +8 -3
  11. package/src/components/button-group/button-group.django.html +1 -1
  12. package/src/components/button-group/config.json +7 -1
  13. package/src/components/card/Card.tsx +6 -5
  14. package/src/components/card/card.django.html +7 -5
  15. package/src/components/card/config.json +5 -1
  16. package/src/components/carousel/carousel.django.html +3 -3
  17. package/src/components/checkbox-group/CheckboxGroup.tsx +1 -1
  18. package/src/components/code/Code.tsx +3 -2
  19. package/src/components/code/code.django.html +1 -1
  20. package/src/components/code/code.html +43 -0
  21. package/src/components/code/config.json +6 -1
  22. package/src/components/footer/footer.django.html +8 -8
  23. package/src/components/footer/footer.html +45 -21
  24. package/src/components/image/image.django.html +1 -1
  25. package/src/components/layout/Layout.tsx +10 -9
  26. package/src/components/layout/config.json +10 -0
  27. package/src/components/layout/layout.django.html +2 -2
  28. package/src/components/layout/layout.html +2 -2
  29. package/src/components/required/Required.tsx +1 -1
  30. package/src/components/required/required.django.html +1 -1
  31. package/src/components/spinner/Spinner.tsx +6 -5
  32. package/src/components/spinner/config.json +6 -6
  33. package/src/components/spinner/spinner.django.html +4 -3
package/README.md CHANGED
@@ -33,6 +33,99 @@ at the repo root for the full, up-to-date list of implemented components.
33
33
 
34
34
  ## Token usage
35
35
 
36
+ ### Responsive Layout
37
+
38
+ `.usx-layout` owns the responsive outer padding: 12px (1.5 units)
39
+ below desktop and 32px (4 units) at desktop. `SingleColumnLayout` and the grid's
40
+ main content have no padding. The left sidebar has 32px of right padding, and
41
+ the right sidebar has 32px of left padding, keeping the inner gap large at
42
+ every width where sidebars are visible. These gaps are included in the sidebar
43
+ widths. Expanded sidebars extend into the outer gutter without removing the
44
+ inner gap. CSS container queries show supplied sidebars when
45
+ their combined widths fit alongside the minimum main-column width, capped by
46
+ the normal content maximum. Both sidebars appear together when both are supplied.
47
+ This works for expandable and non-expandable layouts and does not change when
48
+ expansion is toggled. Each sidebar adds 16rem outside
49
+ the configured 64rem content maximum. The unpadded main-column cap subtracts
50
+ twice the current outer gutter from that maximum, preserving the previous
51
+ readable width. The same subtraction applies to the expanded maximum.
52
+ A grid without sidebars matches the
53
+ single-column layout at every width. Expansion changes the content maximum to
54
+ 100rem without changing gutters or sidebar visibility.
55
+
56
+ The main content, rather than the combined content-and-sidebar group, centers
57
+ when there is enough space on both sides. With default widths, all variants
58
+ align at 96rem of outer width (64rem configured content width plus room for a
59
+ 16rem sidebar on either side).
60
+ Before that point, visible columns fill the available width until they reach
61
+ their caps; absent sidebars do not reserve tracks. A one-sidebar layout may
62
+ remain off-center while there is insufficient space to center its capped main
63
+ column without overlapping the sidebar. Expanded content aligns at 132rem of
64
+ outer width.
65
+
66
+ With the themed stylesheet and generated theme CSS loaded, these runtime tokens
67
+ can be set on a layout or an ancestor:
68
+
69
+ | Token | Default |
70
+ | --- | --- |
71
+ | `--usx-layout-gutter-mobile` | `0.75rem` |
72
+ | `--usx-layout-gutter` | `2rem` |
73
+
74
+ The desktop gutter token also supplies the fixed inner sidebar gap. Widths and
75
+ their container-query thresholds are configured together at Sass compile time:
76
+
77
+ | Sass variable | Default |
78
+ | --- | --- |
79
+ | `$usx-layout-max-width` | `64rem` |
80
+ | `$usx-layout-expanded-max-width` | `100rem` |
81
+ | `$usx-layout-sidebar-width` | `16rem` |
82
+ | `$usx-layout-content-min-width` | `32rem` |
83
+
84
+ The minimum main-column width is unpadded content space. Set it to match
85
+ the reading or control space your content needs. Default sidebar thresholds
86
+ are 48rem with one sidebar and 64rem with both. A narrow theme with 12rem
87
+ sidebars needs 44rem with one and 56rem with both. Measurements use the parent
88
+ layout's content-box width after outer padding, not the viewport, so embedded
89
+ layouts behave the same way. With default 16px root text and gutter values,
90
+ sidebars appear at outer widths of 792px (one) and 1088px (both).
91
+ Use nonnegative length values; percentage widths are not supported for these
92
+ grid sizing tokens. Sidebar detection uses CSS `:has()` with direct children.
93
+ Hidden sidebar content is also unavailable to assistive technology: provide
94
+ essential navigation or actions elsewhere on small screens.
95
+
96
+ For a static Sass build, configure the matching `$usx-layout-*` variables before
97
+ loading component styles. Existing `$max-layout-width` and `$max-sidebar-width`
98
+ remain the static defaults when the new width settings are unset. Runtime gutter
99
+ hooks take precedence in the themed build. `$usx-layout-breakpoint` defaults to
100
+ `$breakpoint-desktop` (1024px) and accepts a CSS length such as `880px`.
101
+ It controls the outer gutters, not sidebar visibility. Configure it at
102
+ compile time, since CSS custom properties cannot set media-query thresholds.
103
+
104
+ CSS container queries show the expand/contract button only when the two widths
105
+ differ by more than one pixel, accounting for visible sidebar tracks. React
106
+ only manages the expanded state; there are no JavaScript size measurements.
107
+ The expanded state is preserved when resizing temporarily removes the difference.
108
+ Django and static HTML use the same sizing and visibility rules.
109
+
110
+ The `layout.sizing()` mixin accepts `$gutter-mobile` and `$gutter` lengths
111
+ (defaults: 12px and 32px). It uses these for static padding and subtracts them
112
+ from the expansion thresholds at the corresponding viewport breakpoint.
113
+ For custom gutters, pass the same lengths used by your runtime gutter tokens
114
+ or static Sass overrides. CSS size queries cannot read custom properties, so
115
+ changing runtime gutters alone does not update the compiled button threshold.
116
+ The compact comparison uses `$gutter-mobile: 1rem` and `$gutter: 2.5rem`.
117
+
118
+ The custom grid does not require `grid-row`, `grid-col`, or `grid-gap`. USWDS's
119
+ site-margin settings still control its own containers; align those settings
120
+ with the USX gutter values when mixing both container types. Do not add a
121
+ second padded `grid-container` around Layout unless nested gutters are intended.
122
+
123
+ Layout stories use fullscreen previews. `ResponsiveComparison` and
124
+ `ThemedComparison` cover no, left, right, and both sidebars. When checking
125
+ expansion, expand at desktop width and resize without reloading the story.
126
+
127
+ ### Component Tokens
128
+
36
129
  Component `.scss` files consume design token variables published by
37
130
  `@solexllc/usx-theme` (for example `$usx-color-primary`, `$usx-spacing-md`,
38
131
  `$usx-radius-md`). These compile to `var(--usx-*, <default>)` by default, so
package/dist/index.cjs CHANGED
@@ -75,15 +75,16 @@
75
75
  id,
76
76
  content,
77
77
  expanded = false,
78
- className,
78
+ headingClassName,
79
+ contentClassName,
79
80
  headingLevel = "h3",
80
81
  handleToggle
81
82
  }) {
82
- const headingClasses = classNames("usa-accordion__heading", className);
83
+ const headingClasses = classNames("usa-accordion__heading", headingClassName);
83
84
  const contentClasses = classNames(
84
85
  "usa-accordion__content",
85
86
  "usa-prose",
86
- className
87
+ contentClassName
87
88
  );
88
89
  const Heading = headingLevel;
89
90
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -120,6 +121,8 @@
120
121
  headingLevel = "h3",
121
122
  iconPosition,
122
123
  className = "",
124
+ headingClassName = "",
125
+ contentClassName = "",
123
126
  ...props
124
127
  }) {
125
128
  const accordionClasses = classNames(
@@ -141,7 +144,8 @@
141
144
  {
142
145
  ...item,
143
146
  headingLevel,
144
- className
147
+ headingClassName,
148
+ contentClassName
145
149
  },
146
150
  item.id
147
151
  ))
@@ -564,23 +568,24 @@
564
568
  const Spinner = ({
565
569
  size = 3,
566
570
  color = null,
567
- label = "Loading...",
568
- omitLabel = false,
571
+ label = null,
572
+ screenReaderLabel = null,
569
573
  staticUrlPrefix = getDefaultStaticUrlPrefix(),
570
574
  className = "",
571
575
  ...props
572
576
  }) => {
573
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { role: "status", "aria-live": "polite", className, ...props, children: [
577
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { role: "status", "aria-live": "polite", className: `usx-spinner ${className}`, ...props, children: [
574
578
  /* @__PURE__ */ jsxRuntime.jsx(
575
579
  "svg",
576
580
  {
577
- className: "usa-icon usx-spinner " + (size === 1 ? "usx-spinner--size-1" : "usa-icon--size-" + size) + (color ? " text-" + color : ""),
581
+ className: "usa-icon " + (size === 1 ? "usx-spinner--size-1" : "usa-icon--size-" + size) + (color ? " text-" + color : ""),
578
582
  "aria-hidden": "true",
579
583
  focusable: "false",
580
584
  children: /* @__PURE__ */ jsxRuntime.jsx("use", { href: staticUrlPrefix + "spinner" })
581
585
  }
582
586
  ),
583
- !omitLabel && label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usa-sr-only", children: label })
587
+ screenReaderLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usa-sr-only", children: screenReaderLabel }),
588
+ label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usa-label usx-label", children: label })
584
589
  ] });
585
590
  };
586
591
  function Button({
@@ -620,7 +625,7 @@
620
625
  const classes = classNames(
621
626
  "usa-button",
622
627
  "usx-button",
623
- variant && variantClasses[variant],
628
+ variant ? variantClasses[variant] : variantClasses["primary"],
624
629
  big && "usa-button--big",
625
630
  inverse && "usa-button--inverse",
626
631
  ghost && "usx-button--ghost",
@@ -681,7 +686,7 @@
681
686
  segmented && "usa-button-group--segmented",
682
687
  className
683
688
  );
684
- return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: classes, ...props, children: buttonProps.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-button-group__item", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { ...item, children: item.children }) }, index)) });
689
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: classes, ...props, children: buttonProps.map(({ itemClassName, ...item }, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: classNames("usa-button-group__item", itemClassName), children: /* @__PURE__ */ jsxRuntime.jsx(Button, { ...item, children: item.children }) }, index)) });
685
690
  }
686
691
  function CalendarDate({
687
692
  datetime,
@@ -920,7 +925,9 @@
920
925
  id: `${props.id || "card"}-carousel`,
921
926
  showDots: showCarouselDots,
922
927
  className: "usx-card__carousel",
923
- slides: images == null ? void 0 : images.map((img, index) => /* @__PURE__ */ jsxRuntime.jsx(Image, { ...img, hideCaption: true }, index))
928
+ slides: images == null ? void 0 : images.map((img, index) => ({
929
+ content: /* @__PURE__ */ jsxRuntime.jsx(Image, { ...img, hideCaption: true }, index)
930
+ }))
924
931
  }
925
932
  ) : hasImages ? /* @__PURE__ */ jsxRuntime.jsx(Image, { ...images[0], hideCaption: true, className: "usa-card__img" }) : null;
926
933
  return /* @__PURE__ */ jsxRuntime.jsx(RootTag, { className: cardClasses, ...props, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-card__container", children: shouldRenderStructured ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -930,7 +937,7 @@
930
937
  tags && tags.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-tag-group", children: tags.map((tag, index) => /* @__PURE__ */ jsxRuntime.jsx(Tag, { ...tag }, index)) }),
931
938
  description && (typeof description === "string" ? /* @__PURE__ */ jsxRuntime.jsx("p", { children: description }) : description)
932
939
  ] }),
933
- actions && actions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-card__footer", children: /* @__PURE__ */ jsxRuntime.jsx(ButtonGroup, { items: actions, className: "flex-wrap" }) })
940
+ actions && actions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-card__footer", children: /* @__PURE__ */ jsxRuntime.jsx(ButtonGroup, { buttonProps: actions, className: "flex-wrap" }) })
934
941
  ] }) : children || "Card" }) });
935
942
  }
936
943
  function CardGroup({ cardProps = [], className = "", ...props }) {
@@ -950,6 +957,7 @@
950
957
  const classes = classNames("usx-required", className);
951
958
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
952
959
  /* @__PURE__ */ jsxRuntime.jsx("abbr", { title, className: classes, ...props, children: "*" }),
960
+ " ",
953
961
  children ? children : ""
954
962
  ] });
955
963
  };
@@ -1263,7 +1271,7 @@
1263
1271
  const CheckboxGroup = ({
1264
1272
  tile = false,
1265
1273
  small = false,
1266
- legend = "Select one or more options",
1274
+ legend,
1267
1275
  required = false,
1268
1276
  hint = null,
1269
1277
  error = null,
@@ -1341,14 +1349,14 @@
1341
1349
  document.body.removeChild(ta);
1342
1350
  }
1343
1351
  }
1344
- function Code({ lines = [], copyText = null, className = "" }) {
1352
+ function Code({ lines = [], allowHtml = false, copyText = null, className = "" }) {
1345
1353
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames("usx-mockup-code", className), children: [
1346
1354
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-mockup-code__content", children: lines.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx(
1347
1355
  "pre",
1348
1356
  {
1349
1357
  ...line.prefix != null ? { "data-prefix": line.prefix } : {},
1350
1358
  className: line.className || void 0,
1351
- children: /* @__PURE__ */ jsxRuntime.jsx("code", { dangerouslySetInnerHTML: { __html: line.code } })
1359
+ children: allowHtml ? /* @__PURE__ */ jsxRuntime.jsx("code", { dangerouslySetInnerHTML: { __html: line.code } }) : /* @__PURE__ */ jsxRuntime.jsx("code", { children: line.code })
1352
1360
  },
1353
1361
  i
1354
1362
  )) }),
@@ -2704,6 +2712,9 @@
2704
2712
  {
2705
2713
  variant: "primary",
2706
2714
  ghost: true,
2715
+ type: "button",
2716
+ "aria-label": expanded ? "Contract" : "Expand",
2717
+ "aria-expanded": expanded,
2707
2718
  className: "usx-layout__expand-button",
2708
2719
  onClick: () => setExpanded((value) => !value),
2709
2720
  children: [
package/dist/index.js CHANGED
@@ -73,15 +73,16 @@ function AccordionItem({
73
73
  id,
74
74
  content,
75
75
  expanded = false,
76
- className,
76
+ headingClassName,
77
+ contentClassName,
77
78
  headingLevel = "h3",
78
79
  handleToggle
79
80
  }) {
80
- const headingClasses = classNames("usa-accordion__heading", className);
81
+ const headingClasses = classNames("usa-accordion__heading", headingClassName);
81
82
  const contentClasses = classNames(
82
83
  "usa-accordion__content",
83
84
  "usa-prose",
84
- className
85
+ contentClassName
85
86
  );
86
87
  const Heading = headingLevel;
87
88
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -118,6 +119,8 @@ function Accordion({
118
119
  headingLevel = "h3",
119
120
  iconPosition,
120
121
  className = "",
122
+ headingClassName = "",
123
+ contentClassName = "",
121
124
  ...props
122
125
  }) {
123
126
  const accordionClasses = classNames(
@@ -139,7 +142,8 @@ function Accordion({
139
142
  {
140
143
  ...item,
141
144
  headingLevel,
142
- className
145
+ headingClassName,
146
+ contentClassName
143
147
  },
144
148
  item.id
145
149
  ))
@@ -562,23 +566,24 @@ const getDefaultStaticUrlPrefix = () => {
562
566
  const Spinner = ({
563
567
  size = 3,
564
568
  color = null,
565
- label = "Loading...",
566
- omitLabel = false,
569
+ label = null,
570
+ screenReaderLabel = null,
567
571
  staticUrlPrefix = getDefaultStaticUrlPrefix(),
568
572
  className = "",
569
573
  ...props
570
574
  }) => {
571
- return /* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", className, ...props, children: [
575
+ return /* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", className: `usx-spinner ${className}`, ...props, children: [
572
576
  /* @__PURE__ */ jsx(
573
577
  "svg",
574
578
  {
575
- className: "usa-icon usx-spinner " + (size === 1 ? "usx-spinner--size-1" : "usa-icon--size-" + size) + (color ? " text-" + color : ""),
579
+ className: "usa-icon " + (size === 1 ? "usx-spinner--size-1" : "usa-icon--size-" + size) + (color ? " text-" + color : ""),
576
580
  "aria-hidden": "true",
577
581
  focusable: "false",
578
582
  children: /* @__PURE__ */ jsx("use", { href: staticUrlPrefix + "spinner" })
579
583
  }
580
584
  ),
581
- !omitLabel && label && /* @__PURE__ */ jsx("span", { className: "usa-sr-only", children: label })
585
+ screenReaderLabel && /* @__PURE__ */ jsx("span", { className: "usa-sr-only", children: screenReaderLabel }),
586
+ label && /* @__PURE__ */ jsx("span", { className: "usa-label usx-label", children: label })
582
587
  ] });
583
588
  };
584
589
  function Button({
@@ -618,7 +623,7 @@ function Button({
618
623
  const classes = classNames(
619
624
  "usa-button",
620
625
  "usx-button",
621
- variant && variantClasses[variant],
626
+ variant ? variantClasses[variant] : variantClasses["primary"],
622
627
  big && "usa-button--big",
623
628
  inverse && "usa-button--inverse",
624
629
  ghost && "usx-button--ghost",
@@ -679,7 +684,7 @@ function ButtonGroup({
679
684
  segmented && "usa-button-group--segmented",
680
685
  className
681
686
  );
682
- return /* @__PURE__ */ jsx("ul", { className: classes, ...props, children: buttonProps.map((item, index) => /* @__PURE__ */ jsx("li", { className: "usa-button-group__item", children: /* @__PURE__ */ jsx(Button, { ...item, children: item.children }) }, index)) });
687
+ return /* @__PURE__ */ jsx("ul", { className: classes, ...props, children: buttonProps.map(({ itemClassName, ...item }, index) => /* @__PURE__ */ jsx("li", { className: classNames("usa-button-group__item", itemClassName), children: /* @__PURE__ */ jsx(Button, { ...item, children: item.children }) }, index)) });
683
688
  }
684
689
  function CalendarDate({
685
690
  datetime,
@@ -918,7 +923,9 @@ function Card({
918
923
  id: `${props.id || "card"}-carousel`,
919
924
  showDots: showCarouselDots,
920
925
  className: "usx-card__carousel",
921
- slides: images == null ? void 0 : images.map((img, index) => /* @__PURE__ */ jsx(Image, { ...img, hideCaption: true }, index))
926
+ slides: images == null ? void 0 : images.map((img, index) => ({
927
+ content: /* @__PURE__ */ jsx(Image, { ...img, hideCaption: true }, index)
928
+ }))
922
929
  }
923
930
  ) : hasImages ? /* @__PURE__ */ jsx(Image, { ...images[0], hideCaption: true, className: "usa-card__img" }) : null;
924
931
  return /* @__PURE__ */ jsx(RootTag, { className: cardClasses, ...props, children: /* @__PURE__ */ jsx("div", { className: "usa-card__container", children: shouldRenderStructured ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -928,7 +935,7 @@ function Card({
928
935
  tags && tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "usx-tag-group", children: tags.map((tag, index) => /* @__PURE__ */ jsx(Tag, { ...tag }, index)) }),
929
936
  description && (typeof description === "string" ? /* @__PURE__ */ jsx("p", { children: description }) : description)
930
937
  ] }),
931
- actions && actions.length > 0 && /* @__PURE__ */ jsx("div", { className: "usa-card__footer", children: /* @__PURE__ */ jsx(ButtonGroup, { items: actions, className: "flex-wrap" }) })
938
+ actions && actions.length > 0 && /* @__PURE__ */ jsx("div", { className: "usa-card__footer", children: /* @__PURE__ */ jsx(ButtonGroup, { buttonProps: actions, className: "flex-wrap" }) })
932
939
  ] }) : children || "Card" }) });
933
940
  }
934
941
  function CardGroup({ cardProps = [], className = "", ...props }) {
@@ -948,6 +955,7 @@ const Required = ({
948
955
  const classes = classNames("usx-required", className);
949
956
  return /* @__PURE__ */ jsxs(Fragment, { children: [
950
957
  /* @__PURE__ */ jsx("abbr", { title, className: classes, ...props, children: "*" }),
958
+ " ",
951
959
  children ? children : ""
952
960
  ] });
953
961
  };
@@ -1261,7 +1269,7 @@ function Fieldset({
1261
1269
  const CheckboxGroup = ({
1262
1270
  tile = false,
1263
1271
  small = false,
1264
- legend = "Select one or more options",
1272
+ legend,
1265
1273
  required = false,
1266
1274
  hint = null,
1267
1275
  error = null,
@@ -1339,14 +1347,14 @@ function usxCopy(text) {
1339
1347
  document.body.removeChild(ta);
1340
1348
  }
1341
1349
  }
1342
- function Code({ lines = [], copyText = null, className = "" }) {
1350
+ function Code({ lines = [], allowHtml = false, copyText = null, className = "" }) {
1343
1351
  return /* @__PURE__ */ jsxs("div", { className: classNames("usx-mockup-code", className), children: [
1344
1352
  /* @__PURE__ */ jsx("div", { className: "usx-mockup-code__content", children: lines.map((line, i) => /* @__PURE__ */ jsx(
1345
1353
  "pre",
1346
1354
  {
1347
1355
  ...line.prefix != null ? { "data-prefix": line.prefix } : {},
1348
1356
  className: line.className || void 0,
1349
- children: /* @__PURE__ */ jsx("code", { dangerouslySetInnerHTML: { __html: line.code } })
1357
+ children: allowHtml ? /* @__PURE__ */ jsx("code", { dangerouslySetInnerHTML: { __html: line.code } }) : /* @__PURE__ */ jsx("code", { children: line.code })
1350
1358
  },
1351
1359
  i
1352
1360
  )) }),
@@ -2702,6 +2710,9 @@ function Layout({
2702
2710
  {
2703
2711
  variant: "primary",
2704
2712
  ghost: true,
2713
+ type: "button",
2714
+ "aria-label": expanded ? "Contract" : "Expand",
2715
+ "aria-expanded": expanded,
2705
2716
  className: "usx-layout__expand-button",
2706
2717
  onClick: () => setExpanded((value) => !value),
2707
2718
  children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solexllc/usx-react",
3
- "version": "0.1.8",
3
+ "version": "0.3.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.1.8",
29
- "@solexllc/usx-theme": "0.2.3",
30
- "@solexllc/usx-uswds-fixes": "0.1.5",
28
+ "@solexllc/usx": "0.3.0",
29
+ "@solexllc/usx-theme": "0.4.0",
30
+ "@solexllc/usx-uswds-fixes": "0.1.8",
31
31
  "classnames": "^2.5.1",
32
32
  "prop-types": "^15.8.1"
33
33
  },
@@ -8,7 +8,8 @@ export interface AccordionItemProps {
8
8
  id: string;
9
9
  content: React.ReactNode;
10
10
  expanded?: boolean;
11
- className?: string;
11
+ headingClassName?: string;
12
+ contentClassName?: string;
12
13
  headingLevel?: AccordionHeadingLevel;
13
14
  handleToggle?: React.MouseEventHandler<HTMLButtonElement>;
14
15
  }
@@ -26,15 +27,16 @@ function AccordionItem({
26
27
  id,
27
28
  content,
28
29
  expanded = false,
29
- className,
30
+ headingClassName,
31
+ contentClassName,
30
32
  headingLevel = 'h3',
31
33
  handleToggle,
32
34
  }: AccordionItemProps) {
33
- const headingClasses = classnames('usa-accordion__heading', className)
35
+ const headingClasses = classnames('usa-accordion__heading', headingClassName)
34
36
  const contentClasses = classnames(
35
37
  'usa-accordion__content',
36
38
  'usa-prose',
37
- className
39
+ contentClassName
38
40
  )
39
41
 
40
42
  const Heading = headingLevel
@@ -72,6 +74,8 @@ export function Accordion({
72
74
  headingLevel = 'h3',
73
75
  iconPosition,
74
76
  className = '',
77
+ headingClassName = '',
78
+ contentClassName = '',
75
79
  ...props
76
80
  }: AccordionProps) {
77
81
  const accordionClasses = classnames(
@@ -95,7 +99,8 @@ export function Accordion({
95
99
  key={item.id}
96
100
  {...item}
97
101
  headingLevel={headingLevel}
98
- className={className}
102
+ headingClassName={headingClassName}
103
+ contentClassName={contentClassName}
99
104
  />
100
105
  ))}
101
106
  </div>
@@ -7,13 +7,13 @@
7
7
  >
8
8
  {% for item in items %}
9
9
  {% if headingLevel == 'h1' %}
10
- <h1 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
10
+ <h1 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ headingClassName }}">
11
11
  {% elif headingLevel == 'h2' %}
12
- <h2 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
12
+ <h2 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ headingClassName }}">
13
13
  {% elif headingLevel == 'h4' %}
14
- <h4 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
14
+ <h4 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ headingClassName }}">
15
15
  {% else %}
16
- <h3 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
16
+ <h3 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ headingClassName }}">
17
17
  {% endif %}
18
18
  <button
19
19
  class="usa-accordion__button"
@@ -35,7 +35,7 @@
35
35
 
36
36
  <div
37
37
  id="{{ id }}-{{ forloop.counter0 }}-content"
38
- class="usa-accordion__content"
38
+ class="usa-accordion__content usa-prose {{ contentClassName }}"
39
39
  aria-labelledby="{{ id }}-{{ forloop.counter0 }}-heading"
40
40
  hidden
41
41
  >
@@ -30,7 +30,17 @@
30
30
  "className": {
31
31
  "type": "string",
32
32
  "default": "",
33
- "description": "Additional CSS classes to apply to the accordion. Use iconPosition to set the icon position for this accordion. For live global theming, set --usx-accordion-icon-position to 1.25rem auto (start) or auto 1.25rem (end)."
33
+ "description": "Additional CSS classes to apply to the accordion."
34
+ },
35
+ "headingClassName": {
36
+ "type": "string",
37
+ "default": "",
38
+ "description": "Additional CSS classes to apply to the accordion heading."
39
+ },
40
+ "contentClassName": {
41
+ "type": "string",
42
+ "default": "",
43
+ "description": "Additional CSS classes to apply to the accordion content."
34
44
  }
35
45
  }
36
46
  }
@@ -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],
73
+ variant ? variantClasses[variant] : variantClasses['primary'],
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
- {% if variant and variant != '' %} usa-button--{{ variant }}{% endif %}
8
+ usa-button--{{ variant|default:'primary' }}
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 %}
@@ -18,10 +18,10 @@
18
18
  {% else %}
19
19
 
20
20
  <button
21
- type="{{ type }}"
21
+ type="{{ type|default:'button' }}"
22
22
  class="
23
23
  usa-button usx-button
24
- {% if variant and variant != '' %} usa-button--{{ variant }}{% endif %}
24
+ usa-button--{{ variant|default:'primary' }}
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 %}
@@ -2,8 +2,13 @@ import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
  import Button from '../button/Button';
4
4
  import type { ButtonProps } from '../button/Button';
5
+
6
+ export type ButtonGroupItemProps = ButtonProps & {
7
+ itemClassName?: string;
8
+ };
9
+
5
10
  export interface ButtonGroupProps extends React.HTMLAttributes<HTMLUListElement> {
6
- buttonProps?: ButtonProps[];
11
+ buttonProps?: ButtonGroupItemProps[];
7
12
  segmented?: boolean;
8
13
  className?: string;
9
14
  }
@@ -21,8 +26,8 @@ export default function ButtonGroup({
21
26
  );
22
27
  return (
23
28
  <ul className={classes} {...props}>
24
- {buttonProps.map((item, index) => (
25
- <li key={index} className="usa-button-group__item">
29
+ {buttonProps.map(({ itemClassName, ...item }, index) => (
30
+ <li key={index} className={ClassNames('usa-button-group__item', itemClassName)}>
26
31
  <Button {...item}>
27
32
  {item.children}
28
33
  </Button>
@@ -2,7 +2,7 @@
2
2
  {# Django template for ButtonGroup #}
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
- <li class="usa-button-group__item">
5
+ <li class="usa-button-group__item{% if item.itemClassName %} {{ item.itemClassName }}{% endif %}">
6
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 %}
7
7
  </li>
8
8
  {% endfor %}
@@ -9,7 +9,13 @@
9
9
  "items": {
10
10
  "type": "object",
11
11
  "description": "Button item.",
12
- "component": "button"
12
+ "component": "button",
13
+ "properties": {
14
+ "itemClassName": {
15
+ "type": "string",
16
+ "description": "Additional CSS classes on the list item wrapping the button."
17
+ }
18
+ }
13
19
  }
14
20
  },
15
21
  "segmented": {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
  import ButtonGroup from '../button-group/ButtonGroup';
4
+ import type { ButtonGroupItemProps } from '../button-group/ButtonGroup';
4
5
  import Tag from '../tag/Tag';
5
6
  import Image from '../image/Image';
6
7
  import Carousel from '../carousel/Carousel';
@@ -12,7 +13,7 @@ export interface CardTag {
12
13
 
13
14
  export interface CardAction {
14
15
  children: string;
15
- variant?: string;
16
+ variant?: ButtonGroupItemProps['variant'];
16
17
  onClick?: () => void;
17
18
  }
18
19
 
@@ -84,9 +85,9 @@ export default function Card({
84
85
  id={`${props.id || 'card'}-carousel`}
85
86
  showDots={showCarouselDots}
86
87
  className="usx-card__carousel"
87
- slides={images?.map((img, index) => (
88
- <Image key={index} {...img} hideCaption={true} />
89
- ))}
88
+ slides={images?.map((img, index) => ({
89
+ content: <Image key={index} {...img} hideCaption={true} />,
90
+ }))}
90
91
  />
91
92
  ) : hasImages ? (
92
93
  <Image {...images[0]} hideCaption={true} className="usa-card__img" />
@@ -124,7 +125,7 @@ export default function Card({
124
125
 
125
126
  {actions && actions.length > 0 && (
126
127
  <div className="usa-card__footer">
127
- <ButtonGroup items={actions} className="flex-wrap" />
128
+ <ButtonGroup buttonProps={actions} className="flex-wrap" />
128
129
  </div>
129
130
  )}
130
131
  </>
@@ -1,7 +1,9 @@
1
1
  {% load components %}
2
- <{% if tag %}{{ tag }}{% else %}div{% endif %} class="usa-card{% if headerFirst %} usa-card--header-first{% endif %}{% if flag %} usa-card--flag{% endif %}{% if mediaRight %} usa-card--media-right{% endif %}{% if className %} {{ className }}{% endif %}">
2
+ <{% if tag %}{{ tag }}{% else %}div{% endif %}{% if id %} id="{{ id }}"{% endif %} class="usa-card usx-card{% if headerFirst %} usa-card--header-first{% endif %}{% if flag %} usa-card--flag{% endif %}{% if mediaRight %} usa-card--media-right{% endif %}{% if className %} {{ className }}{% endif %}">
3
3
  <div class="usa-card__container">
4
- {% if title or description or tags or actions or images %}
4
+ {% if children %}
5
+ {{ children }}
6
+ {% elif title or description or tags or actions or images %}
5
7
  {% if title %}
6
8
  <div class="usa-card__header">
7
9
  <h4 class="usa-card__heading">{{ title }}</h4>
@@ -9,11 +11,11 @@
9
11
  {% endif %}
10
12
  {% if images and images|length > 1 %}
11
13
  <div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
12
- {% carousel slides=images id=id|default:'card'|add:'-carousel' showDots=showCarouselDots|default:True className='' %}{% endcarousel %}
14
+ {% carousel slides=images id=id|default:'card'|add:'-carousel' showDots=showCarouselDots|default_bool:True className='usx-card__carousel' %}{% endcarousel %}
13
15
  </div>
14
16
  {% elif images and images.0 %}
15
17
  <div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
16
- {% image src=images.0.src alt=images.0.alt hideCaption=True className='usa-card__img' %}{% endimage %}
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 %}
17
19
  </div>
18
20
  {% endif %}
19
21
  <div class="usa-card__body">
@@ -30,7 +32,7 @@
30
32
  </div>
31
33
  {% if actions %}
32
34
  <div class="usa-card__footer">
33
- {% button_group items=actions %}{% endbutton_group %}
35
+ {% button_group buttonProps=actions className='flex-wrap' %}{% endbutton_group %}
34
36
  </div>
35
37
  {% endif %}
36
38
  {% else %}
@@ -3,6 +3,10 @@
3
3
  "template": "card/card.django.html",
4
4
  "version": 1,
5
5
  "props": {
6
+ "id": {
7
+ "type": "string",
8
+ "description": "Card element ID, also used as the prefix for carousel slide IDs."
9
+ },
6
10
  "title": {
7
11
  "type": "string",
8
12
  "description": "The title text displayed in the card header"
@@ -53,7 +57,7 @@
53
57
  },
54
58
  "images": {
55
59
  "type": "array",
56
- "description": "Array of image objects (currently uses first image)",
60
+ "description": "Array of image objects; multiple images render as a carousel",
57
61
  "items": {
58
62
  "type": "object",
59
63
  "description": "Card image.",
@@ -1,8 +1,8 @@
1
1
  {% load components %}
2
2
 
3
3
  {# Django template for Carousel #}
4
- <div class="usx-carousel {{ className|default:'' }}">
5
- <div class="usx-carousel__viewport" tabindex="-1" role="region" aria-roledescription="carousel" aria-label="{{ ariaLabel|default:'Featured content' }}">
4
+ <div class="usx-carousel {{ className|default:'' }}" role="region" aria-roledescription="carousel" aria-label="{{ ariaLabel|default:'Featured content' }}">
5
+ <div class="usx-carousel__viewport" tabindex="-1">
6
6
  <div class="usx-carousel__track">
7
7
  {% if children %}
8
8
  {{ children|safe }}
@@ -12,7 +12,7 @@
12
12
  {% if slide.content %}
13
13
  {{ slide.content|safe }}
14
14
  {% elif slide.src %}
15
- {% image src=slide.src alt=slide.alt caption=slide.caption hideCaption=True objectFit=slide.objectFit className=slide.className %}{% endimage %}
15
+ {% image src=slide.src alt=slide.alt caption=slide.caption hideCaption=True href=slide.href rounded=slide.rounded circular=slide.circular objectFit=slide.objectFit maxWidth=slide.maxWidth maxHeight=slide.maxHeight className=slide.className %}{% endimage %}
16
16
  {% else %}
17
17
  {# Fallback: render the slide object/string directly #}
18
18
  {{ slide|safe }}
@@ -28,7 +28,7 @@ export interface CheckboxGroupProps extends React.HTMLAttributes<HTMLFieldSetEle
28
28
  const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
29
29
  tile = false,
30
30
  small = false,
31
- legend = 'Select one or more options',
31
+ legend,
32
32
  required = false,
33
33
  hint = null,
34
34
  error = null,
@@ -24,11 +24,12 @@ export interface CodeLine {
24
24
 
25
25
  export interface CodeProps {
26
26
  lines?: CodeLine[];
27
+ allowHtml?: boolean;
27
28
  copyText?: string | null;
28
29
  className?: string;
29
30
  }
30
31
 
31
- export default function Code({ lines = [], copyText = null, className = '' }: CodeProps) {
32
+ export default function Code({ lines = [], allowHtml = false, copyText = null, className = '' }: CodeProps) {
32
33
  return (
33
34
  <div className={ClassNames('usx-mockup-code', className)}>
34
35
  <div className="usx-mockup-code__content">
@@ -38,7 +39,7 @@ export default function Code({ lines = [], copyText = null, className = '' }: Co
38
39
  {...(line.prefix != null ? { 'data-prefix': line.prefix } : {})}
39
40
  className={line.className || undefined}
40
41
  >
41
- <code dangerouslySetInnerHTML={{ __html: line.code }} />
42
+ {allowHtml ? <code dangerouslySetInnerHTML={{ __html: line.code }} /> : <code>{line.code}</code>}
42
43
  </pre>
43
44
  ))}
44
45
  </div>
@@ -4,7 +4,7 @@
4
4
  {% for line in lines %}
5
5
  <pre
6
6
  {% if line.prefix %} data-prefix="{{ line.prefix }}"{% endif %}{% if line.className %} class="{{ line.className }}"{% endif %}
7
- ><code>{{ line.code|safe }}</code></pre>
7
+ ><code>{% if allowHtml %}{{ line.code|safe }}{% else %}{{ line.code|force_escape }}{% endif %}</code></pre>
8
8
  {% endfor %}
9
9
  </div>
10
10
  {% if copyText %}
@@ -32,6 +32,49 @@
32
32
  </div>
33
33
  </div>
34
34
 
35
+ <h3 class="site-preview-heading">HTML Markup as Literal Text</h3>
36
+ <div class="usx-mockup-code">
37
+ <div class="usx-mockup-code__content">
38
+ <pre data-prefix="1"><code>&lt;section aria-label="Account &amp; settings"&gt;</code></pre>
39
+ <pre data-prefix="2"><code> &lt;h2&gt;Contact information&lt;/h2&gt;</code></pre>
40
+ <pre data-prefix="3"><code> &lt;p&gt;Use &amp;lt;Page&amp;gt; to define the page.&lt;/p&gt;</code></pre>
41
+ <pre data-prefix="4"><code>&lt;/section&gt;</code></pre>
42
+ </div>
43
+ </div>
44
+
45
+ <h3 class="site-preview-heading">React Markup as Literal Text</h3>
46
+ <div class="usx-mockup-code">
47
+ <div class="usx-mockup-code__content">
48
+ <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
49
+ <pre data-prefix="2"><code> &lt;Page title="Account" tabIndex={-1}&gt;</code></pre>
50
+ <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
51
+ <pre data-prefix="4"><code> &lt;ContactDetails user={currentUser} /&gt;</code></pre>
52
+ <pre data-prefix="5"><code> &lt;/Section&gt;</code></pre>
53
+ <pre data-prefix="6"><code> &lt;/Page&gt;</code></pre>
54
+ <pre data-prefix="7"><code>&lt;/Layout&gt;</code></pre>
55
+ </div>
56
+ </div>
57
+
58
+ <h3 class="site-preview-heading">React Markup with an HTML Fragment</h3>
59
+ <div class="usx-mockup-code">
60
+ <div class="usx-mockup-code__content">
61
+ <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
62
+ <pre data-prefix="2"><code> &lt;Page title="<strong>Account</strong>" tabIndex={-1}&gt;</code></pre>
63
+ <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
64
+ <pre data-prefix="4"><code> &lt;ContactDetails user={currentUser} /&gt;</code></pre>
65
+ <pre data-prefix="5"><code> &lt;/Section&gt;</code></pre>
66
+ <pre data-prefix="6"><code> &lt;/Page&gt;</code></pre>
67
+ <pre data-prefix="7"><code>&lt;/Layout&gt;</code></pre>
68
+ </div>
69
+ </div>
70
+
71
+ <h3 class="site-preview-heading">Rendered HTML Fragment</h3>
72
+ <div class="usx-mockup-code">
73
+ <div class="usx-mockup-code__content">
74
+ <pre data-prefix=">"><code>This <em>line</em> has <strong>HTML fragments</strong></code></pre>
75
+ </div>
76
+ </div>
77
+
35
78
  <h3 class="site-preview-heading">Without Prefix</h3>
36
79
  <div class="usx-mockup-code">
37
80
  <div class="usx-mockup-code__content">
@@ -15,7 +15,7 @@
15
15
  "properties": {
16
16
  "code": {
17
17
  "type": "string",
18
- "description": "Line content."
18
+ "description": "Literal line content, including HTML or JSX source. Interpreted as trusted HTML only when allowHtml is true."
19
19
  },
20
20
  "prefix": {
21
21
  "type": "string",
@@ -28,6 +28,11 @@
28
28
  }
29
29
  }
30
30
  },
31
+ "allowHtml": {
32
+ "type": "boolean",
33
+ "default": false,
34
+ "description": "Render line content as HTML instead of literal text. Only enable for trusted HTML; content is not sanitized. Leave false when documenting HTML or React markup."
35
+ },
31
36
  "copyText": {
32
37
  "type": "string",
33
38
  "description": "Text to copy when the copy button is clicked. If provided, shows the copy button."
@@ -154,10 +154,10 @@
154
154
  {% if branding %}
155
155
  <div class="usa-logo usx-logo usa-footer__logo grid-row grid-gap-2 usx-footer__logo">
156
156
  {% if branding.logo %}
157
- {% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-logo__image">{% endif %}
158
- <img src="{{ branding.logo }}" alt="{{ branding.alt|default:branding.title|default:'' }}" class="usx-logo__variant" />
159
- {% if branding.logoInverse %}<img src="{{ branding.logoInverse }}" alt="{{ branding.alt|default:branding.title|default:'' }}" class="usx-logo__variant usx-logo__variant--inverse" />{% endif %}
160
- {% if brandingUrl %}</a>{% endif %}
157
+ {% 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 %}
160
+ {% if brandingUrl %}</a>{% else %}</div>{% endif %}
161
161
  {% else %}
162
162
  <em class="usa-logo__text">
163
163
  {% if branding.symbol %}
@@ -181,10 +181,10 @@
181
181
  {% if branding %}
182
182
  <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
183
  {% if branding.logo %}
184
- {% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-logo__image">{% endif %}
185
- <img src="{{ branding.logo }}" alt="{{ branding.alt|default:branding.title|default:'' }}" class="usx-logo__variant" />
186
- {% if branding.logoInverse %}<img src="{{ branding.logoInverse }}" alt="{{ branding.alt|default:branding.title|default:'' }}" class="usx-logo__variant usx-logo__variant--inverse" />{% endif %}
187
- {% if brandingUrl %}</a>{% endif %}
184
+ {% 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 %}
187
+ {% if brandingUrl %}</a>{% else %}</div>{% endif %}
188
188
  {% else %}
189
189
  <em class="usa-logo__text">
190
190
  {% if branding.symbol %}
@@ -127,14 +127,22 @@
127
127
  <div class="grid-container">
128
128
  <div class="grid-row grid-gap">
129
129
  <div
130
- class="usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
130
+ class="usa-logo usx-logo usa-footer__logo usx-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
131
131
  >
132
- <div class="mobile-lg:grid-col-auto">
133
- <img class="usa-footer__logo-img" src="/assets/img/logo-img.png" alt="" />
134
- </div>
135
- <div class="mobile-lg:grid-col-auto">
136
- <p class="usa-footer__logo-heading">&lt;Name of Agency&gt;</p>
137
- </div>
132
+ <a href="/" class="usx-image usx-logo__image">
133
+ <div class="usx-image usx-logo__variant">
134
+ <picture>
135
+ <source media="(min-width: 40em)" srcset="linear-w-symbol_left.svg" />
136
+ <img src="symbol-only.svg" alt="Agency Name" />
137
+ </picture>
138
+ </div>
139
+ <div class="usx-image usx-logo__variant usx-logo__variant--inverse">
140
+ <picture>
141
+ <source media="(min-width: 40em)" srcset="white_linear-w-symbol_left.png" />
142
+ <img src="white_symbol-only.png" alt="Agency Name" />
143
+ </picture>
144
+ </div>
145
+ </a>
138
146
  </div>
139
147
  <div class="usa-footer__contact-links mobile-lg:grid-col-6">
140
148
  <div class="usa-footer__social-links grid-row grid-gap-1">
@@ -242,14 +250,22 @@
242
250
  <div class="grid-container">
243
251
  <div class="grid-row grid-gap">
244
252
  <div
245
- class="usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
253
+ class="usa-logo usx-logo usa-footer__logo usx-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
246
254
  >
247
- <div class="mobile-lg:grid-col-auto">
248
- <img class="usa-footer__logo-img" src="/assets/img/logo-img.png" alt="" />
249
- </div>
250
- <div class="mobile-lg:grid-col-auto">
251
- <p class="usa-footer__logo-heading">&lt;Name of Agency&gt;</p>
252
- </div>
255
+ <a href="/" class="usx-image usx-logo__image">
256
+ <div class="usx-image usx-logo__variant">
257
+ <picture>
258
+ <source media="(min-width: 40em)" srcset="linear-w-symbol_left.svg" />
259
+ <img src="symbol-only.svg" alt="Agency Name" />
260
+ </picture>
261
+ </div>
262
+ <div class="usx-image usx-logo__variant usx-logo__variant--inverse">
263
+ <picture>
264
+ <source media="(min-width: 40em)" srcset="white_linear-w-symbol_left.png" />
265
+ <img src="white_symbol-only.png" alt="Agency Name" />
266
+ </picture>
267
+ </div>
268
+ </a>
253
269
  </div>
254
270
  <div class="usa-footer__contact-links mobile-lg:grid-col-6">
255
271
  <div class="usa-footer__social-links grid-row grid-gap-1">
@@ -379,13 +395,21 @@
379
395
  </div>
380
396
  <div class="usa-footer__secondary-section">
381
397
  <div class="grid-container">
382
- <div class="usa-footer__logo grid-row grid-gap-2">
383
- <div class="grid-col-auto">
384
- <img class="usa-footer__logo-img" src="/assets/img/logo-img.png" alt="" />
385
- </div>
386
- <div class="grid-col-auto">
387
- <p class="usa-footer__logo-heading">&lt;Agency Contact Center&gt;</p>
388
- </div>
398
+ <div class="usa-logo usx-logo usa-footer__logo usx-footer__logo grid-row grid-gap-2">
399
+ <a href="/" class="usx-image usx-logo__image">
400
+ <div class="usx-image usx-logo__variant">
401
+ <picture>
402
+ <source media="(min-width: 40em)" srcset="linear-w-symbol_left.svg" />
403
+ <img src="symbol-only.svg" alt="Agency Name" />
404
+ </picture>
405
+ </div>
406
+ <div class="usx-image usx-logo__variant usx-logo__variant--inverse">
407
+ <picture>
408
+ <source media="(min-width: 40em)" srcset="white_linear-w-symbol_left.png" />
409
+ <img src="white_symbol-only.png" alt="Agency Name" />
410
+ </picture>
411
+ </div>
412
+ </a>
389
413
  </div>
390
414
  </div>
391
415
  </div>
@@ -31,7 +31,7 @@
31
31
  {% else %}
32
32
  Image
33
33
  {% endif %}
34
- <figcaption class="usx-image--caption{% if hideCaption %} usa-sr-only{% endif %}">{{ caption }}</figcaption>
34
+ <figcaption class="usx-image--caption{% if hideCaption %} usa-sr-only{% endif %}" aria-hidden="{{ hideCaption|yesno:'true,false' }}">{{ caption }}</figcaption>
35
35
  </figure>
36
36
  {% else %}
37
37
  {% if href %}<a href="{{ href }}"
@@ -2,7 +2,6 @@ import React, { useState, ReactNode, HTMLAttributes } from 'react';
2
2
  import ClassNames from 'classnames';
3
3
  import Icon from '../icon/Icon';
4
4
  import Button from '../button/Button';
5
- import Tooltip from '../tooltip/Tooltip';
6
5
 
7
6
  // ── Sub-components ──────────────────────────────────────────────────────────
8
7
 
@@ -117,6 +116,7 @@ export default function Layout({
117
116
  ...props
118
117
  }: LayoutProps) {
119
118
  const [expanded, setExpanded] = useState(false);
119
+
120
120
  const classes = ClassNames(
121
121
  'usx-layout',
122
122
  { 'usx-expanded': expandable && expanded },
@@ -124,17 +124,18 @@ export default function Layout({
124
124
  );
125
125
 
126
126
  const expandButton = expandable ? (
127
-
128
- <Button
129
- variant="primary"
130
- ghost={true}
131
- className="usx-layout__expand-button"
132
- onClick={() => setExpanded((value) => !value)}
133
- >
127
+ <Button
128
+ variant="primary"
129
+ ghost={true}
130
+ type="button"
131
+ aria-label={expanded ? 'Contract' : 'Expand'}
132
+ aria-expanded={expanded}
133
+ className="usx-layout__expand-button"
134
+ onClick={() => setExpanded((value) => !value)}
135
+ >
134
136
  <Icon source="usx" name="expand" size={3} className="usx-layout__expand-icon usx-layout__expand-icon--expand" />
135
137
  <Icon source="usx" name="contract" size={3} className="usx-layout__expand-icon usx-layout__expand-icon--contract" />
136
138
  </Button>
137
-
138
139
  ) : null;
139
140
 
140
141
  return (
@@ -28,6 +28,16 @@
28
28
  "type": "string",
29
29
  "description": "Right sidebar content (grid variant only)"
30
30
  },
31
+ "expandLeftSidebar": {
32
+ "type": "boolean",
33
+ "default": false,
34
+ "description": "Removes the outer padding from the left sidebar on desktop."
35
+ },
36
+ "expandRightSidebar": {
37
+ "type": "boolean",
38
+ "default": false,
39
+ "description": "Removes the outer padding from the right sidebar on desktop."
40
+ },
31
41
  "expandable": {
32
42
  "type": "boolean",
33
43
  "description": "Adds a toggle button that grows the layout to a wider max-width via the usx-expanded class."
@@ -20,7 +20,7 @@
20
20
  {% elif variant == 'grid' %}
21
21
  <div class="usx-layout__grid-container">
22
22
  {% if leftSidebar %}
23
- <aside class="usx-layout__sidebar--left">
23
+ <aside class="usx-layout__sidebar--left{% if expandLeftSidebar %} usx-layout__sidebar--expanded{% endif %}">
24
24
  {{ leftSidebar|safe }}
25
25
  </aside>
26
26
  {% endif %}
@@ -29,7 +29,7 @@
29
29
  {% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
30
30
  </main>
31
31
  {% if rightSidebar %}
32
- <aside class="usx-layout__sidebar--right">
32
+ <aside class="usx-layout__sidebar--right{% if expandRightSidebar %} usx-layout__sidebar--expanded{% endif %}">
33
33
  {{ rightSidebar|safe }}
34
34
  </aside>
35
35
  {% endif %}
@@ -30,7 +30,8 @@
30
30
 
31
31
  <!-- Expandable Layout Example -->
32
32
  <div class="usx-layout">
33
- <button type="button" class="usx-layout__expand-button" aria-expanded="false" aria-label="Expand">
33
+ <div class="usx-layout__single-column">
34
+ <button type="button" class="usx-layout__expand-button" aria-expanded="false" aria-label="Expand" onclick="const expanded = this.closest('.usx-layout').classList.toggle('usx-expanded'); this.setAttribute('aria-expanded', expanded); this.setAttribute('aria-label', expanded ? 'Contract' : 'Expand');">
34
35
  <svg class="usa-icon usx-layout__expand-icon usx-layout__expand-icon--expand" aria-hidden="true" focusable="false" role="img">
35
36
  <use href="./img/usx-sprite.svg#expand"></use>
36
37
  </svg>
@@ -38,7 +39,6 @@
38
39
  <use href="./img/usx-sprite.svg#contract"></use>
39
40
  </svg>
40
41
  </button>
41
- <div class="usx-layout__single-column">
42
42
  <h1>Page Title</h1>
43
43
  <p>Use the expand button in the top-right corner to grow the layout to a wider max-width.</p>
44
44
  </div>
@@ -16,7 +16,7 @@ const Required: React.FC<RequiredProps> = ({
16
16
  const classes = ClassNames('usx-required', className);
17
17
  return (
18
18
  <>
19
- <abbr title={title} className={classes} {...props}>*</abbr>
19
+ <abbr title={title} className={classes} {...props}>*</abbr>{" "}
20
20
  {children ? children : ''}
21
21
  </>
22
22
  );
@@ -1,2 +1,2 @@
1
1
  {# Django template for Required #}
2
- <abbr title="{{ title|default:'Required' }}" class="usx-required {{ className|default:'' }}">*</abbr>{{ children|default:'' }}
2
+ <abbr title="{{ title|default:'Required' }}" class="usx-required {{ className|default:'' }}">*</abbr> {{ children|default:'' }}
@@ -19,17 +19,17 @@ const getDefaultStaticUrlPrefix = () => {
19
19
  const Spinner: React.FC<SpinnerProps> = ({
20
20
  size = 3,
21
21
  color = null,
22
- label = 'Loading...',
23
- omitLabel = false,
22
+ label = null,
23
+ screenReaderLabel = null,
24
24
  staticUrlPrefix = getDefaultStaticUrlPrefix(),
25
25
  className = '',
26
26
  ...props
27
27
  }) => {
28
28
  return (
29
- <span role="status" aria-live="polite" className={className} {...props}>
29
+ <span role="status" aria-live="polite" className={`usx-spinner ${className}`} {...props}>
30
30
  <svg
31
31
  className={
32
- 'usa-icon usx-spinner ' +
32
+ 'usa-icon ' +
33
33
  (size === 1 ? 'usx-spinner--size-1' : 'usa-icon--size-' + size) +
34
34
  (color ? ' text-' + color : '')
35
35
  }
@@ -38,7 +38,8 @@ const Spinner: React.FC<SpinnerProps> = ({
38
38
  >
39
39
  <use href={staticUrlPrefix + 'spinner'} />
40
40
  </svg>
41
- {!omitLabel && label && <span className="usa-sr-only">{label}</span>}
41
+ {screenReaderLabel && <span className="usa-sr-only">{screenReaderLabel}</span>}
42
+ {label && <span className="usa-label usx-label">{label}</span>}
42
43
  </span>
43
44
  );
44
45
  };
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "label": {
29
29
  "type": "string",
30
- "default": "Loading...",
31
- "description": "Screen-reader-only label text."
30
+ "default": null,
31
+ "description": "Visible label text displayed beside the spinner."
32
32
  },
33
- "omitLabel": {
34
- "type": "boolean",
35
- "default": false,
36
- "description": "Set to true to omit the sr-only label, e.g. when wrapped in a Tooltip."
33
+ "screenReaderLabel": {
34
+ "type": "string",
35
+ "default": null,
36
+ "description": "Optional screen-reader-only label text."
37
37
  },
38
38
  "className": {
39
39
  "type": "string",
@@ -1,8 +1,9 @@
1
1
  {% load static %}
2
2
  {# Django template for Spinner #}
3
- <span role="status" aria-live="polite" tabindex="0"{% if className %} class="{{ className }}"{% endif %}>
4
- <svg class="usa-icon usx-spinner {% if size == 1 %}usx-spinner--size-1{% else %}usa-icon--size-{{ size|default:3 }}{% endif %}{% if color %} text-{{ color }}{% endif %}" aria-hidden="true" focusable="false">
3
+ <span role="status" aria-live="polite" class="usx-spinner{% if className %} {{ className }}{% endif %}">
4
+ <svg class="usa-icon {% if size == 1 %}usx-spinner--size-1{% else %}usa-icon--size-{{ size|default:3 }}{% endif %}{% if color %} text-{{ color }}{% endif %}" aria-hidden="true" focusable="false">
5
5
  <use href="{% static 'img/usx-sprite.svg' %}#spinner"></use>
6
6
  </svg>
7
- {% if label and not omitLabel %}<span class="usa-sr-only">{{ label }}</span>{% endif %}
7
+ {% if screenReaderLabel %}<span class="usa-sr-only">{{ screenReaderLabel }}</span>{% endif %}
8
+ {% if label %}<span class="usa-label usx-label">{{ label }}</span>{% endif %}
8
9
  </span>