@solexllc/usx-react 0.1.7 → 0.2.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.
- package/dist/index.cjs +57 -20
- package/dist/index.js +57 -20
- package/package.json +4 -4
- package/src/components/accordion/Accordion.tsx +10 -5
- package/src/components/accordion/accordion.django.html +5 -5
- package/src/components/accordion/config.json +11 -1
- package/src/components/button/Button.tsx +1 -1
- package/src/components/button/button.django.html +3 -3
- package/src/components/button-group/ButtonGroup.tsx +8 -3
- package/src/components/button-group/button-group.django.html +1 -1
- package/src/components/button-group/config.json +7 -1
- package/src/components/card/Card.tsx +6 -5
- package/src/components/card/card.django.html +7 -5
- package/src/components/card/config.json +5 -1
- package/src/components/carousel/carousel.django.html +3 -3
- package/src/components/checkbox-group/CheckboxGroup.tsx +1 -1
- package/src/components/image/image.django.html +1 -1
- package/src/components/layout/Layout.tsx +40 -7
- package/src/components/layout/config.json +4 -0
- package/src/components/layout/layout.django.html +13 -0
- package/src/components/layout/layout.html +16 -0
- package/src/components/page/Page.tsx +6 -2
- package/src/components/required/Required.tsx +1 -1
- package/src/components/required/required.django.html +1 -1
- package/src/components/spinner/Spinner.tsx +6 -5
- package/src/components/spinner/config.json +6 -6
- package/src/components/spinner/spinner.django.html +4 -3
package/dist/index.cjs
CHANGED
|
@@ -75,15 +75,16 @@
|
|
|
75
75
|
id,
|
|
76
76
|
content,
|
|
77
77
|
expanded = false,
|
|
78
|
-
|
|
78
|
+
headingClassName,
|
|
79
|
+
contentClassName,
|
|
79
80
|
headingLevel = "h3",
|
|
80
81
|
handleToggle
|
|
81
82
|
}) {
|
|
82
|
-
const headingClasses = classNames("usa-accordion__heading",
|
|
83
|
+
const headingClasses = classNames("usa-accordion__heading", headingClassName);
|
|
83
84
|
const contentClasses = classNames(
|
|
84
85
|
"usa-accordion__content",
|
|
85
86
|
"usa-prose",
|
|
86
|
-
|
|
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
|
-
|
|
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 =
|
|
568
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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) =>
|
|
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, {
|
|
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
|
|
1274
|
+
legend,
|
|
1267
1275
|
required = false,
|
|
1268
1276
|
hint = null,
|
|
1269
1277
|
error = null,
|
|
@@ -2631,15 +2639,19 @@
|
|
|
2631
2639
|
}
|
|
2632
2640
|
);
|
|
2633
2641
|
}
|
|
2634
|
-
function SingleColumnLayout({ children, className = "", ...props }) {
|
|
2642
|
+
function SingleColumnLayout({ children, expandButton = null, className = "", ...props }) {
|
|
2635
2643
|
const classes = ["usx-layout__single-column", className].filter(Boolean).join(" ");
|
|
2636
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
2644
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, ...props, children: [
|
|
2645
|
+
expandButton,
|
|
2646
|
+
children
|
|
2647
|
+
] });
|
|
2637
2648
|
}
|
|
2638
2649
|
function GridLayout({
|
|
2639
2650
|
leftSidebar,
|
|
2640
2651
|
rightSidebar,
|
|
2641
2652
|
expandLeftSidebar,
|
|
2642
2653
|
expandRightSidebar,
|
|
2654
|
+
expandButton = null,
|
|
2643
2655
|
children,
|
|
2644
2656
|
className = "",
|
|
2645
2657
|
...props
|
|
@@ -2670,7 +2682,10 @@
|
|
|
2670
2682
|
);
|
|
2671
2683
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerClasses, ...props, children: [
|
|
2672
2684
|
leftSidebar && /* @__PURE__ */ jsxRuntime.jsx("aside", { className: leftSidebarClasses, children: leftSidebar }),
|
|
2673
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2685
|
+
/* @__PURE__ */ jsxRuntime.jsxs("main", { className: contentClasses, children: [
|
|
2686
|
+
expandButton,
|
|
2687
|
+
children
|
|
2688
|
+
] }),
|
|
2674
2689
|
rightSidebar && /* @__PURE__ */ jsxRuntime.jsx("aside", { className: rightSidebarClasses, children: rightSidebar })
|
|
2675
2690
|
] });
|
|
2676
2691
|
}
|
|
@@ -2682,23 +2697,43 @@
|
|
|
2682
2697
|
rightSidebar,
|
|
2683
2698
|
expandLeftSidebar,
|
|
2684
2699
|
expandRightSidebar,
|
|
2700
|
+
expandable = false,
|
|
2685
2701
|
className = "",
|
|
2686
2702
|
...props
|
|
2687
2703
|
}) {
|
|
2704
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
2688
2705
|
const classes = classNames(
|
|
2689
2706
|
"usx-layout",
|
|
2707
|
+
{ "usx-expanded": expandable && expanded },
|
|
2690
2708
|
className
|
|
2691
2709
|
);
|
|
2692
|
-
|
|
2710
|
+
const expandButton = expandable ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2711
|
+
Button,
|
|
2712
|
+
{
|
|
2713
|
+
variant: "primary",
|
|
2714
|
+
ghost: true,
|
|
2715
|
+
className: "usx-layout__expand-button",
|
|
2716
|
+
onClick: () => setExpanded((value) => !value),
|
|
2717
|
+
children: [
|
|
2718
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { source: "usx", name: "expand", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--expand" }),
|
|
2719
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { source: "usx", name: "contract", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--contract" })
|
|
2720
|
+
]
|
|
2721
|
+
}
|
|
2722
|
+
) : null;
|
|
2723
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes, ...props, children: variant === "single-column" ? /* @__PURE__ */ jsxRuntime.jsx(SingleColumnLayout, { expandButton, children: children || content }) : variant === "grid" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2693
2724
|
GridLayout,
|
|
2694
2725
|
{
|
|
2695
2726
|
leftSidebar,
|
|
2696
2727
|
rightSidebar,
|
|
2697
2728
|
expandLeftSidebar,
|
|
2698
2729
|
expandRightSidebar,
|
|
2730
|
+
expandButton,
|
|
2699
2731
|
children: children || content
|
|
2700
2732
|
}
|
|
2701
|
-
) :
|
|
2733
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2734
|
+
expandButton,
|
|
2735
|
+
children || content
|
|
2736
|
+
] }) });
|
|
2702
2737
|
}
|
|
2703
2738
|
function isItemObject(item) {
|
|
2704
2739
|
return item && typeof item === "object" && !Array.isArray(item) && !React.isValidElement(item);
|
|
@@ -3046,6 +3081,7 @@
|
|
|
3046
3081
|
id = void 0,
|
|
3047
3082
|
title = "Page title",
|
|
3048
3083
|
eyebrow = null,
|
|
3084
|
+
element = "main",
|
|
3049
3085
|
children = null,
|
|
3050
3086
|
content = null,
|
|
3051
3087
|
className = "",
|
|
@@ -3053,7 +3089,8 @@
|
|
|
3053
3089
|
}) {
|
|
3054
3090
|
const classes = ["usx-page", className].filter(Boolean).join(" ");
|
|
3055
3091
|
const pageContent = children || content;
|
|
3056
|
-
|
|
3092
|
+
const Element = element;
|
|
3093
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Element, { id, className: classes, ...props, children: [
|
|
3057
3094
|
/* @__PURE__ */ jsxRuntime.jsxs("h1", { className: "usx-page__title", children: [
|
|
3058
3095
|
eyebrow ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
|
|
3059
3096
|
title
|
package/dist/index.js
CHANGED
|
@@ -73,15 +73,16 @@ function AccordionItem({
|
|
|
73
73
|
id,
|
|
74
74
|
content,
|
|
75
75
|
expanded = false,
|
|
76
|
-
|
|
76
|
+
headingClassName,
|
|
77
|
+
contentClassName,
|
|
77
78
|
headingLevel = "h3",
|
|
78
79
|
handleToggle
|
|
79
80
|
}) {
|
|
80
|
-
const headingClasses = classNames("usa-accordion__heading",
|
|
81
|
+
const headingClasses = classNames("usa-accordion__heading", headingClassName);
|
|
81
82
|
const contentClasses = classNames(
|
|
82
83
|
"usa-accordion__content",
|
|
83
84
|
"usa-prose",
|
|
84
|
-
|
|
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
|
-
|
|
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 =
|
|
566
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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) =>
|
|
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, {
|
|
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
|
|
1272
|
+
legend,
|
|
1265
1273
|
required = false,
|
|
1266
1274
|
hint = null,
|
|
1267
1275
|
error = null,
|
|
@@ -2629,15 +2637,19 @@ function LanguageSelector({
|
|
|
2629
2637
|
}
|
|
2630
2638
|
);
|
|
2631
2639
|
}
|
|
2632
|
-
function SingleColumnLayout({ children, className = "", ...props }) {
|
|
2640
|
+
function SingleColumnLayout({ children, expandButton = null, className = "", ...props }) {
|
|
2633
2641
|
const classes = ["usx-layout__single-column", className].filter(Boolean).join(" ");
|
|
2634
|
-
return /* @__PURE__ */
|
|
2642
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, ...props, children: [
|
|
2643
|
+
expandButton,
|
|
2644
|
+
children
|
|
2645
|
+
] });
|
|
2635
2646
|
}
|
|
2636
2647
|
function GridLayout({
|
|
2637
2648
|
leftSidebar,
|
|
2638
2649
|
rightSidebar,
|
|
2639
2650
|
expandLeftSidebar,
|
|
2640
2651
|
expandRightSidebar,
|
|
2652
|
+
expandButton = null,
|
|
2641
2653
|
children,
|
|
2642
2654
|
className = "",
|
|
2643
2655
|
...props
|
|
@@ -2668,7 +2680,10 @@ function GridLayout({
|
|
|
2668
2680
|
);
|
|
2669
2681
|
return /* @__PURE__ */ jsxs("div", { className: containerClasses, ...props, children: [
|
|
2670
2682
|
leftSidebar && /* @__PURE__ */ jsx("aside", { className: leftSidebarClasses, children: leftSidebar }),
|
|
2671
|
-
/* @__PURE__ */
|
|
2683
|
+
/* @__PURE__ */ jsxs("main", { className: contentClasses, children: [
|
|
2684
|
+
expandButton,
|
|
2685
|
+
children
|
|
2686
|
+
] }),
|
|
2672
2687
|
rightSidebar && /* @__PURE__ */ jsx("aside", { className: rightSidebarClasses, children: rightSidebar })
|
|
2673
2688
|
] });
|
|
2674
2689
|
}
|
|
@@ -2680,23 +2695,43 @@ function Layout({
|
|
|
2680
2695
|
rightSidebar,
|
|
2681
2696
|
expandLeftSidebar,
|
|
2682
2697
|
expandRightSidebar,
|
|
2698
|
+
expandable = false,
|
|
2683
2699
|
className = "",
|
|
2684
2700
|
...props
|
|
2685
2701
|
}) {
|
|
2702
|
+
const [expanded, setExpanded] = useState(false);
|
|
2686
2703
|
const classes = classNames(
|
|
2687
2704
|
"usx-layout",
|
|
2705
|
+
{ "usx-expanded": expandable && expanded },
|
|
2688
2706
|
className
|
|
2689
2707
|
);
|
|
2690
|
-
|
|
2708
|
+
const expandButton = expandable ? /* @__PURE__ */ jsxs(
|
|
2709
|
+
Button,
|
|
2710
|
+
{
|
|
2711
|
+
variant: "primary",
|
|
2712
|
+
ghost: true,
|
|
2713
|
+
className: "usx-layout__expand-button",
|
|
2714
|
+
onClick: () => setExpanded((value) => !value),
|
|
2715
|
+
children: [
|
|
2716
|
+
/* @__PURE__ */ jsx(Icon, { source: "usx", name: "expand", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--expand" }),
|
|
2717
|
+
/* @__PURE__ */ jsx(Icon, { source: "usx", name: "contract", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--contract" })
|
|
2718
|
+
]
|
|
2719
|
+
}
|
|
2720
|
+
) : null;
|
|
2721
|
+
return /* @__PURE__ */ jsx("div", { className: classes, ...props, children: variant === "single-column" ? /* @__PURE__ */ jsx(SingleColumnLayout, { expandButton, children: children || content }) : variant === "grid" ? /* @__PURE__ */ jsx(
|
|
2691
2722
|
GridLayout,
|
|
2692
2723
|
{
|
|
2693
2724
|
leftSidebar,
|
|
2694
2725
|
rightSidebar,
|
|
2695
2726
|
expandLeftSidebar,
|
|
2696
2727
|
expandRightSidebar,
|
|
2728
|
+
expandButton,
|
|
2697
2729
|
children: children || content
|
|
2698
2730
|
}
|
|
2699
|
-
) :
|
|
2731
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2732
|
+
expandButton,
|
|
2733
|
+
children || content
|
|
2734
|
+
] }) });
|
|
2700
2735
|
}
|
|
2701
2736
|
function isItemObject(item) {
|
|
2702
2737
|
return item && typeof item === "object" && !Array.isArray(item) && !React.isValidElement(item);
|
|
@@ -3044,6 +3079,7 @@ function Page({
|
|
|
3044
3079
|
id = void 0,
|
|
3045
3080
|
title = "Page title",
|
|
3046
3081
|
eyebrow = null,
|
|
3082
|
+
element = "main",
|
|
3047
3083
|
children = null,
|
|
3048
3084
|
content = null,
|
|
3049
3085
|
className = "",
|
|
@@ -3051,7 +3087,8 @@ function Page({
|
|
|
3051
3087
|
}) {
|
|
3052
3088
|
const classes = ["usx-page", className].filter(Boolean).join(" ");
|
|
3053
3089
|
const pageContent = children || content;
|
|
3054
|
-
|
|
3090
|
+
const Element = element;
|
|
3091
|
+
return /* @__PURE__ */ jsxs(Element, { id, className: classes, ...props, children: [
|
|
3055
3092
|
/* @__PURE__ */ jsxs("h1", { className: "usx-page__title", children: [
|
|
3056
3093
|
eyebrow ? /* @__PURE__ */ jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
|
|
3057
3094
|
title
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solexllc/usx-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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.
|
|
29
|
-
"@solexllc/usx-theme": "0.
|
|
30
|
-
"@solexllc/usx-uswds-fixes": "0.1.
|
|
28
|
+
"@solexllc/usx": "0.2.0",
|
|
29
|
+
"@solexllc/usx-theme": "0.3.0",
|
|
30
|
+
"@solexllc/usx-uswds-fixes": "0.1.6",
|
|
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
|
-
|
|
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
|
-
|
|
30
|
+
headingClassName,
|
|
31
|
+
contentClassName,
|
|
30
32
|
headingLevel = 'h3',
|
|
31
33
|
handleToggle,
|
|
32
34
|
}: AccordionItemProps) {
|
|
33
|
-
const headingClasses = classnames('usa-accordion__heading',
|
|
35
|
+
const headingClasses = classnames('usa-accordion__heading', headingClassName)
|
|
34
36
|
const contentClasses = classnames(
|
|
35
37
|
'usa-accordion__content',
|
|
36
38
|
'usa-prose',
|
|
37
|
-
|
|
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
|
-
|
|
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 {{
|
|
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 {{
|
|
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 {{
|
|
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 {{
|
|
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.
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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?:
|
|
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=
|
|
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?:
|
|
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
|
|
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
|
|
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|
|
|
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
|
|
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
|
|
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"
|
|
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
|
|
31
|
+
legend,
|
|
32
32
|
required = false,
|
|
33
33
|
hint = null,
|
|
34
34
|
error = null,
|
|
@@ -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 }}"
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import React, { ReactNode, HTMLAttributes } from 'react';
|
|
1
|
+
import React, { useState, ReactNode, HTMLAttributes } from 'react';
|
|
2
2
|
import ClassNames from 'classnames';
|
|
3
|
+
import Icon from '../icon/Icon';
|
|
4
|
+
import Button from '../button/Button';
|
|
5
|
+
import Tooltip from '../tooltip/Tooltip';
|
|
3
6
|
|
|
4
7
|
// ── Sub-components ──────────────────────────────────────────────────────────
|
|
5
8
|
|
|
6
9
|
export interface SingleColumnLayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
10
|
children?: ReactNode;
|
|
11
|
+
expandButton?: ReactNode;
|
|
8
12
|
className?: string;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export function SingleColumnLayout({ children, className = '', ...props }: SingleColumnLayoutProps) {
|
|
15
|
+
export function SingleColumnLayout({ children, expandButton = null, className = '', ...props }: SingleColumnLayoutProps) {
|
|
12
16
|
const classes = ['usx-layout__single-column', className].filter(Boolean).join(' ');
|
|
13
17
|
return (
|
|
14
18
|
<div className={classes} {...props}>
|
|
19
|
+
{expandButton}
|
|
15
20
|
{children}
|
|
16
21
|
</div>
|
|
17
22
|
);
|
|
@@ -22,6 +27,7 @@ export type GridLayoutProps = {
|
|
|
22
27
|
rightSidebar?: ReactNode;
|
|
23
28
|
expandLeftSidebar?: boolean;
|
|
24
29
|
expandRightSidebar?: boolean;
|
|
30
|
+
expandButton?: ReactNode;
|
|
25
31
|
children?: ReactNode;
|
|
26
32
|
className?: string;
|
|
27
33
|
} & HTMLAttributes<HTMLDivElement>;
|
|
@@ -31,14 +37,15 @@ export function GridLayout({
|
|
|
31
37
|
rightSidebar,
|
|
32
38
|
expandLeftSidebar,
|
|
33
39
|
expandRightSidebar,
|
|
40
|
+
expandButton = null,
|
|
34
41
|
children,
|
|
35
42
|
className = '',
|
|
36
43
|
...props
|
|
37
44
|
}: GridLayoutProps) {
|
|
38
45
|
const contentModifier = (
|
|
39
46
|
rightSidebar && !leftSidebar ? 'left'
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
: leftSidebar && !rightSidebar ? 'right'
|
|
48
|
+
: null
|
|
42
49
|
);
|
|
43
50
|
|
|
44
51
|
const contentClasses = ClassNames(
|
|
@@ -70,7 +77,10 @@ export function GridLayout({
|
|
|
70
77
|
{leftSidebar && (
|
|
71
78
|
<aside className={leftSidebarClasses}>{leftSidebar}</aside>
|
|
72
79
|
)}
|
|
73
|
-
<main className={contentClasses}>
|
|
80
|
+
<main className={contentClasses}>
|
|
81
|
+
{expandButton}
|
|
82
|
+
{children}
|
|
83
|
+
</main>
|
|
74
84
|
{rightSidebar && (
|
|
75
85
|
<aside className={rightSidebarClasses}>{rightSidebar}</aside>
|
|
76
86
|
)}
|
|
@@ -89,6 +99,8 @@ export type LayoutProps = {
|
|
|
89
99
|
rightSidebar?: ReactNode;
|
|
90
100
|
expandLeftSidebar?: boolean;
|
|
91
101
|
expandRightSidebar?: boolean;
|
|
102
|
+
/** Adds a toggle button that grows the layout to a wider max-width via the `usx-expanded` class. */
|
|
103
|
+
expandable?: boolean;
|
|
92
104
|
className?: string;
|
|
93
105
|
} & HTMLAttributes<HTMLDivElement>;
|
|
94
106
|
|
|
@@ -100,18 +112,35 @@ export default function Layout({
|
|
|
100
112
|
rightSidebar,
|
|
101
113
|
expandLeftSidebar,
|
|
102
114
|
expandRightSidebar,
|
|
115
|
+
expandable = false,
|
|
103
116
|
className = '',
|
|
104
117
|
...props
|
|
105
118
|
}: LayoutProps) {
|
|
119
|
+
const [expanded, setExpanded] = useState(false);
|
|
106
120
|
const classes = ClassNames(
|
|
107
121
|
'usx-layout',
|
|
122
|
+
{ 'usx-expanded': expandable && expanded },
|
|
108
123
|
className,
|
|
109
124
|
);
|
|
110
125
|
|
|
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
|
+
>
|
|
134
|
+
<Icon source="usx" name="expand" size={3} className="usx-layout__expand-icon usx-layout__expand-icon--expand" />
|
|
135
|
+
<Icon source="usx" name="contract" size={3} className="usx-layout__expand-icon usx-layout__expand-icon--contract" />
|
|
136
|
+
</Button>
|
|
137
|
+
|
|
138
|
+
) : null;
|
|
139
|
+
|
|
111
140
|
return (
|
|
112
141
|
<div className={classes} {...props}>
|
|
113
142
|
{variant === 'single-column' ? (
|
|
114
|
-
<SingleColumnLayout>
|
|
143
|
+
<SingleColumnLayout expandButton={expandButton}>
|
|
115
144
|
{children || content}
|
|
116
145
|
</SingleColumnLayout>
|
|
117
146
|
) : variant === 'grid' ? (
|
|
@@ -120,11 +149,15 @@ export default function Layout({
|
|
|
120
149
|
rightSidebar={rightSidebar}
|
|
121
150
|
expandLeftSidebar={expandLeftSidebar}
|
|
122
151
|
expandRightSidebar={expandRightSidebar}
|
|
152
|
+
expandButton={expandButton}
|
|
123
153
|
>
|
|
124
154
|
{children || content}
|
|
125
155
|
</GridLayout>
|
|
126
156
|
) : (
|
|
127
|
-
|
|
157
|
+
<>
|
|
158
|
+
{expandButton}
|
|
159
|
+
{children || content}
|
|
160
|
+
</>
|
|
128
161
|
)}
|
|
129
162
|
</div>
|
|
130
163
|
);
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"type": "string",
|
|
29
29
|
"description": "Right sidebar content (grid variant only)"
|
|
30
30
|
},
|
|
31
|
+
"expandable": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Adds a toggle button that grows the layout to a wider max-width via the usx-expanded class."
|
|
34
|
+
},
|
|
31
35
|
"className": {
|
|
32
36
|
"type": "string",
|
|
33
37
|
"description": "Additional CSS classes"
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
{% load components %}
|
|
1
2
|
{# Django template for Layout #}
|
|
2
3
|
{# Supports variant: 'single-column' (default), 'grid' #}
|
|
3
4
|
{# For grid: content, leftSidebar, rightSidebar #}
|
|
5
|
+
{% fragment as expandButton %}
|
|
6
|
+
{% if expandable %}
|
|
7
|
+
{% html_attrs aria_expanded="false" aria_label="Expand" onclick="const layout = this.closest('.usx-layout'); const expanded = layout.classList.toggle('usx-expanded'); this.setAttribute('aria-expanded', expanded); this.setAttribute('aria-label', expanded ? 'Contract' : 'Expand');" as expandAttributes %}
|
|
8
|
+
{% button variant="primary" ghost=True type="button" className="usx-layout__expand-button" extraAttributes=expandAttributes %}
|
|
9
|
+
{% icon source='usx' name='expand' size=3 className='usx-layout__expand-icon usx-layout__expand-icon--expand' %}{% endicon %}
|
|
10
|
+
{% icon source='usx' name='contract' size=3 className='usx-layout__expand-icon usx-layout__expand-icon--contract' %}{% endicon %}
|
|
11
|
+
{% endbutton %}
|
|
12
|
+
{% endif %}
|
|
13
|
+
{% endfragment %}
|
|
4
14
|
<div class="usx-layout{% if className %} {{ className }}{% endif %}">
|
|
5
15
|
{% if variant == 'single-column' %}
|
|
6
16
|
<div class="usx-layout__single-column">
|
|
17
|
+
{{ expandButton }}
|
|
7
18
|
{% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
|
|
8
19
|
</div>
|
|
9
20
|
{% elif variant == 'grid' %}
|
|
@@ -14,6 +25,7 @@
|
|
|
14
25
|
</aside>
|
|
15
26
|
{% endif %}
|
|
16
27
|
<main class="usx-layout__content{% if rightSidebar and not leftSidebar %} usx-layout__content--left{% elif leftSidebar and not rightSidebar %} usx-layout__content--right{% endif %}">
|
|
28
|
+
{{ expandButton }}
|
|
17
29
|
{% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
|
|
18
30
|
</main>
|
|
19
31
|
{% if rightSidebar %}
|
|
@@ -23,6 +35,7 @@
|
|
|
23
35
|
{% endif %}
|
|
24
36
|
</div>
|
|
25
37
|
{% else %}
|
|
38
|
+
{{ expandButton }}
|
|
26
39
|
{% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
|
|
27
40
|
{% endif %}
|
|
28
41
|
</div>
|
|
@@ -27,3 +27,19 @@
|
|
|
27
27
|
</main>
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
|
+
|
|
31
|
+
<!-- Expandable Layout Example -->
|
|
32
|
+
<div class="usx-layout">
|
|
33
|
+
<button type="button" class="usx-layout__expand-button" aria-expanded="false" aria-label="Expand">
|
|
34
|
+
<svg class="usa-icon usx-layout__expand-icon usx-layout__expand-icon--expand" aria-hidden="true" focusable="false" role="img">
|
|
35
|
+
<use href="./img/usx-sprite.svg#expand"></use>
|
|
36
|
+
</svg>
|
|
37
|
+
<svg class="usa-icon usx-layout__expand-icon usx-layout__expand-icon--contract" aria-hidden="true" focusable="false" role="img">
|
|
38
|
+
<use href="./img/usx-sprite.svg#contract"></use>
|
|
39
|
+
</svg>
|
|
40
|
+
</button>
|
|
41
|
+
<div class="usx-layout__single-column">
|
|
42
|
+
<h1>Page Title</h1>
|
|
43
|
+
<p>Use the expand button in the top-right corner to grow the layout to a wider max-width.</p>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
export interface PageProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'content'> {
|
|
4
4
|
title?: React.ReactNode;
|
|
5
5
|
eyebrow?: React.ReactNode;
|
|
6
|
+
element?: React.ElementType;
|
|
6
7
|
content?: React.ReactNode;
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -10,6 +11,7 @@ export default function Page({
|
|
|
10
11
|
id = undefined,
|
|
11
12
|
title = 'Page title',
|
|
12
13
|
eyebrow = null,
|
|
14
|
+
element = 'main',
|
|
13
15
|
children = null,
|
|
14
16
|
content = null,
|
|
15
17
|
className = '',
|
|
@@ -18,13 +20,15 @@ export default function Page({
|
|
|
18
20
|
const classes = ['usx-page', className].filter(Boolean).join(' ');
|
|
19
21
|
const pageContent = children || content;
|
|
20
22
|
|
|
23
|
+
const Element = element;
|
|
24
|
+
|
|
21
25
|
return (
|
|
22
|
-
<
|
|
26
|
+
<Element id={id} className={classes} {...props}>
|
|
23
27
|
<h1 className="usx-page__title">
|
|
24
28
|
{eyebrow ? <span className="usx-eyebrow">{eyebrow}</span> : null}
|
|
25
29
|
{title}
|
|
26
30
|
</h1>
|
|
27
31
|
<div className="usx-page__content">{pageContent}</div>
|
|
28
|
-
</
|
|
32
|
+
</Element>
|
|
29
33
|
);
|
|
30
34
|
}
|
|
@@ -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 =
|
|
23
|
-
|
|
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
|
|
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
|
-
{
|
|
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":
|
|
31
|
-
"description": "
|
|
30
|
+
"default": null,
|
|
31
|
+
"description": "Visible label text displayed beside the spinner."
|
|
32
32
|
},
|
|
33
|
-
"
|
|
34
|
-
"type": "
|
|
35
|
-
"default":
|
|
36
|
-
"description": "
|
|
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"
|
|
4
|
-
<svg class="usa-icon
|
|
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
|
|
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>
|