@solexllc/usx-react 0.1.6 → 0.1.8
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 +59 -34
- package/dist/index.js +60 -35
- package/package.json +4 -4
- package/src/components/identifier/Identifier.tsx +26 -40
- package/src/components/identifier/config.json +6 -6
- package/src/components/identifier/identifier.django.html +9 -13
- package/src/components/identifier/identifier.html +10 -10
- 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/dist/index.cjs
CHANGED
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
}
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
|
-
const shapeClassMap
|
|
214
|
+
const shapeClassMap = {
|
|
215
215
|
circle: "usx-circle",
|
|
216
216
|
"rounded-sm": "usx-rounded-sm",
|
|
217
217
|
"rounded-md": "usx-rounded-md",
|
|
@@ -239,12 +239,12 @@
|
|
|
239
239
|
);
|
|
240
240
|
const imgClasses = classNames(
|
|
241
241
|
"usx-avatar__img",
|
|
242
|
-
shape ? shapeClassMap
|
|
242
|
+
shape ? shapeClassMap[shape] : null,
|
|
243
243
|
imageClassName
|
|
244
244
|
);
|
|
245
245
|
const contentClasses = classNames(
|
|
246
246
|
"usx-avatar__content",
|
|
247
|
-
shape ? shapeClassMap
|
|
247
|
+
shape ? shapeClassMap[shape] : "usx-circle",
|
|
248
248
|
contentClassName
|
|
249
249
|
);
|
|
250
250
|
const avatarContent = isInitialsVariant ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: contentClasses, children: value }) : isIconVariant ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: contentClasses, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: value, alt: alt || `${value} icon` }) }) : /* @__PURE__ */ jsxRuntime.jsx("img", { className: imgClasses, src: src || void 0, alt: alt || void 0, role: "img", ...props });
|
|
@@ -2343,13 +2343,6 @@
|
|
|
2343
2343
|
] })
|
|
2344
2344
|
] }, index)) });
|
|
2345
2345
|
}
|
|
2346
|
-
const shapeClassMap = {
|
|
2347
|
-
circle: "usx-circle",
|
|
2348
|
-
"rounded-sm": "usx-rounded-sm",
|
|
2349
|
-
"rounded-md": "usx-rounded-md",
|
|
2350
|
-
"rounded-lg": "usx-rounded-lg",
|
|
2351
|
-
"rounded-xl": "usx-rounded-xl"
|
|
2352
|
-
};
|
|
2353
2346
|
const defaultRequiredLinks = {
|
|
2354
2347
|
en: [
|
|
2355
2348
|
"About <Parent shortname>",
|
|
@@ -2399,12 +2392,18 @@
|
|
|
2399
2392
|
}
|
|
2400
2393
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2401
2394
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "An " }),
|
|
2402
|
-
"official website of
|
|
2395
|
+
"official website of",
|
|
2403
2396
|
" ",
|
|
2404
|
-
parentAgencies.map((agency, index) =>
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2397
|
+
parentAgencies.map((agency, index) => {
|
|
2398
|
+
const isLast = index === parentAgencies.length - 1;
|
|
2399
|
+
const prefix = index === 0 ? "" : isLast ? " and " : ", ";
|
|
2400
|
+
const article = agency.useThe === false ? "" : "the ";
|
|
2401
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
2402
|
+
prefix,
|
|
2403
|
+
article,
|
|
2404
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: agency.href || "", children: agency.name })
|
|
2405
|
+
] }, `${agency.name}-${index}`);
|
|
2406
|
+
}),
|
|
2408
2407
|
taxpayerDisclaimer ? ". Produced and published at taxpayer expense." : ""
|
|
2409
2408
|
] });
|
|
2410
2409
|
}
|
|
@@ -2412,7 +2411,7 @@
|
|
|
2412
2411
|
domain = "domain.gov",
|
|
2413
2412
|
language = "en",
|
|
2414
2413
|
parentAgencies = [],
|
|
2415
|
-
|
|
2414
|
+
avatarProps = [],
|
|
2416
2415
|
logoShape = null,
|
|
2417
2416
|
requiredLinks,
|
|
2418
2417
|
taxpayerDisclaimer = false,
|
|
@@ -2430,7 +2429,7 @@
|
|
|
2430
2429
|
const usaGov = defaultUsaGov[language] || defaultUsaGov.en;
|
|
2431
2430
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, children: [
|
|
2432
2431
|
/* @__PURE__ */ jsxRuntime.jsx("section", { className: "usa-identifier__section usa-identifier__section--masthead", "aria-label": labels.masthead, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usa-identifier__container", children: [
|
|
2433
|
-
|
|
2432
|
+
avatarProps.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2434
2433
|
"div",
|
|
2435
2434
|
{
|
|
2436
2435
|
className: classNames(
|
|
@@ -2438,19 +2437,16 @@
|
|
|
2438
2437
|
"usx-avatar-group",
|
|
2439
2438
|
overlapAvatars && "usa-avatar-group--overlap"
|
|
2440
2439
|
),
|
|
2441
|
-
children:
|
|
2442
|
-
|
|
2440
|
+
children: avatarProps.map((avatar, index) => /* @__PURE__ */ React.createElement(
|
|
2441
|
+
Avatar,
|
|
2443
2442
|
{
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
)
|
|
2449
|
-
src: logo.src,
|
|
2450
|
-
alt: logo.alt,
|
|
2451
|
-
role: "img"
|
|
2443
|
+
...avatar,
|
|
2444
|
+
key: `${avatar.alt}-${index}`,
|
|
2445
|
+
shape: avatar.shape || logoShape,
|
|
2446
|
+
className: classNames("usa-identifier__logo", avatar.className),
|
|
2447
|
+
imageClassName: classNames("usa-identifier__logo-img", avatar.imageClassName)
|
|
2452
2448
|
}
|
|
2453
|
-
)
|
|
2449
|
+
))
|
|
2454
2450
|
}
|
|
2455
2451
|
) : null,
|
|
2456
2452
|
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "usa-identifier__identity", "aria-label": labels.description, children: [
|
|
@@ -2635,15 +2631,19 @@
|
|
|
2635
2631
|
}
|
|
2636
2632
|
);
|
|
2637
2633
|
}
|
|
2638
|
-
function SingleColumnLayout({ children, className = "", ...props }) {
|
|
2634
|
+
function SingleColumnLayout({ children, expandButton = null, className = "", ...props }) {
|
|
2639
2635
|
const classes = ["usx-layout__single-column", className].filter(Boolean).join(" ");
|
|
2640
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
2636
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, ...props, children: [
|
|
2637
|
+
expandButton,
|
|
2638
|
+
children
|
|
2639
|
+
] });
|
|
2641
2640
|
}
|
|
2642
2641
|
function GridLayout({
|
|
2643
2642
|
leftSidebar,
|
|
2644
2643
|
rightSidebar,
|
|
2645
2644
|
expandLeftSidebar,
|
|
2646
2645
|
expandRightSidebar,
|
|
2646
|
+
expandButton = null,
|
|
2647
2647
|
children,
|
|
2648
2648
|
className = "",
|
|
2649
2649
|
...props
|
|
@@ -2674,7 +2674,10 @@
|
|
|
2674
2674
|
);
|
|
2675
2675
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerClasses, ...props, children: [
|
|
2676
2676
|
leftSidebar && /* @__PURE__ */ jsxRuntime.jsx("aside", { className: leftSidebarClasses, children: leftSidebar }),
|
|
2677
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2677
|
+
/* @__PURE__ */ jsxRuntime.jsxs("main", { className: contentClasses, children: [
|
|
2678
|
+
expandButton,
|
|
2679
|
+
children
|
|
2680
|
+
] }),
|
|
2678
2681
|
rightSidebar && /* @__PURE__ */ jsxRuntime.jsx("aside", { className: rightSidebarClasses, children: rightSidebar })
|
|
2679
2682
|
] });
|
|
2680
2683
|
}
|
|
@@ -2686,23 +2689,43 @@
|
|
|
2686
2689
|
rightSidebar,
|
|
2687
2690
|
expandLeftSidebar,
|
|
2688
2691
|
expandRightSidebar,
|
|
2692
|
+
expandable = false,
|
|
2689
2693
|
className = "",
|
|
2690
2694
|
...props
|
|
2691
2695
|
}) {
|
|
2696
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
2692
2697
|
const classes = classNames(
|
|
2693
2698
|
"usx-layout",
|
|
2699
|
+
{ "usx-expanded": expandable && expanded },
|
|
2694
2700
|
className
|
|
2695
2701
|
);
|
|
2696
|
-
|
|
2702
|
+
const expandButton = expandable ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2703
|
+
Button,
|
|
2704
|
+
{
|
|
2705
|
+
variant: "primary",
|
|
2706
|
+
ghost: true,
|
|
2707
|
+
className: "usx-layout__expand-button",
|
|
2708
|
+
onClick: () => setExpanded((value) => !value),
|
|
2709
|
+
children: [
|
|
2710
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { source: "usx", name: "expand", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--expand" }),
|
|
2711
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { source: "usx", name: "contract", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--contract" })
|
|
2712
|
+
]
|
|
2713
|
+
}
|
|
2714
|
+
) : null;
|
|
2715
|
+
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(
|
|
2697
2716
|
GridLayout,
|
|
2698
2717
|
{
|
|
2699
2718
|
leftSidebar,
|
|
2700
2719
|
rightSidebar,
|
|
2701
2720
|
expandLeftSidebar,
|
|
2702
2721
|
expandRightSidebar,
|
|
2722
|
+
expandButton,
|
|
2703
2723
|
children: children || content
|
|
2704
2724
|
}
|
|
2705
|
-
) :
|
|
2725
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2726
|
+
expandButton,
|
|
2727
|
+
children || content
|
|
2728
|
+
] }) });
|
|
2706
2729
|
}
|
|
2707
2730
|
function isItemObject(item) {
|
|
2708
2731
|
return item && typeof item === "object" && !Array.isArray(item) && !React.isValidElement(item);
|
|
@@ -3050,6 +3073,7 @@
|
|
|
3050
3073
|
id = void 0,
|
|
3051
3074
|
title = "Page title",
|
|
3052
3075
|
eyebrow = null,
|
|
3076
|
+
element = "main",
|
|
3053
3077
|
children = null,
|
|
3054
3078
|
content = null,
|
|
3055
3079
|
className = "",
|
|
@@ -3057,7 +3081,8 @@
|
|
|
3057
3081
|
}) {
|
|
3058
3082
|
const classes = ["usx-page", className].filter(Boolean).join(" ");
|
|
3059
3083
|
const pageContent = children || content;
|
|
3060
|
-
|
|
3084
|
+
const Element = element;
|
|
3085
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Element, { id, className: classes, ...props, children: [
|
|
3061
3086
|
/* @__PURE__ */ jsxRuntime.jsxs("h1", { className: "usx-page__title", children: [
|
|
3062
3087
|
eyebrow ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
|
|
3063
3088
|
title
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState, useRef, useId, createContext, useContext, useEffect, useCallback, useMemo } from "react";
|
|
2
|
+
import React, { useState, useRef, createElement, useId, createContext, useContext, useEffect, useCallback, useMemo } from "react";
|
|
3
3
|
function getDefaultExportFromCjs(x) {
|
|
4
4
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
5
5
|
}
|
|
@@ -209,7 +209,7 @@ function Icon({
|
|
|
209
209
|
}
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
|
-
const shapeClassMap
|
|
212
|
+
const shapeClassMap = {
|
|
213
213
|
circle: "usx-circle",
|
|
214
214
|
"rounded-sm": "usx-rounded-sm",
|
|
215
215
|
"rounded-md": "usx-rounded-md",
|
|
@@ -237,12 +237,12 @@ function Avatar({
|
|
|
237
237
|
);
|
|
238
238
|
const imgClasses = classNames(
|
|
239
239
|
"usx-avatar__img",
|
|
240
|
-
shape ? shapeClassMap
|
|
240
|
+
shape ? shapeClassMap[shape] : null,
|
|
241
241
|
imageClassName
|
|
242
242
|
);
|
|
243
243
|
const contentClasses = classNames(
|
|
244
244
|
"usx-avatar__content",
|
|
245
|
-
shape ? shapeClassMap
|
|
245
|
+
shape ? shapeClassMap[shape] : "usx-circle",
|
|
246
246
|
contentClassName
|
|
247
247
|
);
|
|
248
248
|
const avatarContent = isInitialsVariant ? /* @__PURE__ */ jsx("span", { className: contentClasses, children: value }) : isIconVariant ? /* @__PURE__ */ jsx("span", { className: contentClasses, children: /* @__PURE__ */ jsx(Icon, { name: value, alt: alt || `${value} icon` }) }) : /* @__PURE__ */ jsx("img", { className: imgClasses, src: src || void 0, alt: alt || void 0, role: "img", ...props });
|
|
@@ -2341,13 +2341,6 @@ function IconList({ items = [], primary = false, size = null, className = "", ..
|
|
|
2341
2341
|
] })
|
|
2342
2342
|
] }, index)) });
|
|
2343
2343
|
}
|
|
2344
|
-
const shapeClassMap = {
|
|
2345
|
-
circle: "usx-circle",
|
|
2346
|
-
"rounded-sm": "usx-rounded-sm",
|
|
2347
|
-
"rounded-md": "usx-rounded-md",
|
|
2348
|
-
"rounded-lg": "usx-rounded-lg",
|
|
2349
|
-
"rounded-xl": "usx-rounded-xl"
|
|
2350
|
-
};
|
|
2351
2344
|
const defaultRequiredLinks = {
|
|
2352
2345
|
en: [
|
|
2353
2346
|
"About <Parent shortname>",
|
|
@@ -2397,12 +2390,18 @@ function renderDisclaimer({ language, parentAgencies, taxpayerDisclaimer }) {
|
|
|
2397
2390
|
}
|
|
2398
2391
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2399
2392
|
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "An " }),
|
|
2400
|
-
"official website of
|
|
2393
|
+
"official website of",
|
|
2401
2394
|
" ",
|
|
2402
|
-
parentAgencies.map((agency, index) =>
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2395
|
+
parentAgencies.map((agency, index) => {
|
|
2396
|
+
const isLast = index === parentAgencies.length - 1;
|
|
2397
|
+
const prefix = index === 0 ? "" : isLast ? " and " : ", ";
|
|
2398
|
+
const article = agency.useThe === false ? "" : "the ";
|
|
2399
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
2400
|
+
prefix,
|
|
2401
|
+
article,
|
|
2402
|
+
/* @__PURE__ */ jsx("a", { href: agency.href || "", children: agency.name })
|
|
2403
|
+
] }, `${agency.name}-${index}`);
|
|
2404
|
+
}),
|
|
2406
2405
|
taxpayerDisclaimer ? ". Produced and published at taxpayer expense." : ""
|
|
2407
2406
|
] });
|
|
2408
2407
|
}
|
|
@@ -2410,7 +2409,7 @@ function Identifier({
|
|
|
2410
2409
|
domain = "domain.gov",
|
|
2411
2410
|
language = "en",
|
|
2412
2411
|
parentAgencies = [],
|
|
2413
|
-
|
|
2412
|
+
avatarProps = [],
|
|
2414
2413
|
logoShape = null,
|
|
2415
2414
|
requiredLinks,
|
|
2416
2415
|
taxpayerDisclaimer = false,
|
|
@@ -2428,7 +2427,7 @@ function Identifier({
|
|
|
2428
2427
|
const usaGov = defaultUsaGov[language] || defaultUsaGov.en;
|
|
2429
2428
|
return /* @__PURE__ */ jsxs("div", { className: classes, children: [
|
|
2430
2429
|
/* @__PURE__ */ jsx("section", { className: "usa-identifier__section usa-identifier__section--masthead", "aria-label": labels.masthead, children: /* @__PURE__ */ jsxs("div", { className: "usa-identifier__container", children: [
|
|
2431
|
-
|
|
2430
|
+
avatarProps.length > 0 ? /* @__PURE__ */ jsx(
|
|
2432
2431
|
"div",
|
|
2433
2432
|
{
|
|
2434
2433
|
className: classNames(
|
|
@@ -2436,19 +2435,16 @@ function Identifier({
|
|
|
2436
2435
|
"usx-avatar-group",
|
|
2437
2436
|
overlapAvatars && "usa-avatar-group--overlap"
|
|
2438
2437
|
),
|
|
2439
|
-
children:
|
|
2440
|
-
|
|
2438
|
+
children: avatarProps.map((avatar, index) => /* @__PURE__ */ createElement(
|
|
2439
|
+
Avatar,
|
|
2441
2440
|
{
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
)
|
|
2447
|
-
src: logo.src,
|
|
2448
|
-
alt: logo.alt,
|
|
2449
|
-
role: "img"
|
|
2441
|
+
...avatar,
|
|
2442
|
+
key: `${avatar.alt}-${index}`,
|
|
2443
|
+
shape: avatar.shape || logoShape,
|
|
2444
|
+
className: classNames("usa-identifier__logo", avatar.className),
|
|
2445
|
+
imageClassName: classNames("usa-identifier__logo-img", avatar.imageClassName)
|
|
2450
2446
|
}
|
|
2451
|
-
)
|
|
2447
|
+
))
|
|
2452
2448
|
}
|
|
2453
2449
|
) : null,
|
|
2454
2450
|
/* @__PURE__ */ jsxs("section", { className: "usa-identifier__identity", "aria-label": labels.description, children: [
|
|
@@ -2633,15 +2629,19 @@ function LanguageSelector({
|
|
|
2633
2629
|
}
|
|
2634
2630
|
);
|
|
2635
2631
|
}
|
|
2636
|
-
function SingleColumnLayout({ children, className = "", ...props }) {
|
|
2632
|
+
function SingleColumnLayout({ children, expandButton = null, className = "", ...props }) {
|
|
2637
2633
|
const classes = ["usx-layout__single-column", className].filter(Boolean).join(" ");
|
|
2638
|
-
return /* @__PURE__ */
|
|
2634
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, ...props, children: [
|
|
2635
|
+
expandButton,
|
|
2636
|
+
children
|
|
2637
|
+
] });
|
|
2639
2638
|
}
|
|
2640
2639
|
function GridLayout({
|
|
2641
2640
|
leftSidebar,
|
|
2642
2641
|
rightSidebar,
|
|
2643
2642
|
expandLeftSidebar,
|
|
2644
2643
|
expandRightSidebar,
|
|
2644
|
+
expandButton = null,
|
|
2645
2645
|
children,
|
|
2646
2646
|
className = "",
|
|
2647
2647
|
...props
|
|
@@ -2672,7 +2672,10 @@ function GridLayout({
|
|
|
2672
2672
|
);
|
|
2673
2673
|
return /* @__PURE__ */ jsxs("div", { className: containerClasses, ...props, children: [
|
|
2674
2674
|
leftSidebar && /* @__PURE__ */ jsx("aside", { className: leftSidebarClasses, children: leftSidebar }),
|
|
2675
|
-
/* @__PURE__ */
|
|
2675
|
+
/* @__PURE__ */ jsxs("main", { className: contentClasses, children: [
|
|
2676
|
+
expandButton,
|
|
2677
|
+
children
|
|
2678
|
+
] }),
|
|
2676
2679
|
rightSidebar && /* @__PURE__ */ jsx("aside", { className: rightSidebarClasses, children: rightSidebar })
|
|
2677
2680
|
] });
|
|
2678
2681
|
}
|
|
@@ -2684,23 +2687,43 @@ function Layout({
|
|
|
2684
2687
|
rightSidebar,
|
|
2685
2688
|
expandLeftSidebar,
|
|
2686
2689
|
expandRightSidebar,
|
|
2690
|
+
expandable = false,
|
|
2687
2691
|
className = "",
|
|
2688
2692
|
...props
|
|
2689
2693
|
}) {
|
|
2694
|
+
const [expanded, setExpanded] = useState(false);
|
|
2690
2695
|
const classes = classNames(
|
|
2691
2696
|
"usx-layout",
|
|
2697
|
+
{ "usx-expanded": expandable && expanded },
|
|
2692
2698
|
className
|
|
2693
2699
|
);
|
|
2694
|
-
|
|
2700
|
+
const expandButton = expandable ? /* @__PURE__ */ jsxs(
|
|
2701
|
+
Button,
|
|
2702
|
+
{
|
|
2703
|
+
variant: "primary",
|
|
2704
|
+
ghost: true,
|
|
2705
|
+
className: "usx-layout__expand-button",
|
|
2706
|
+
onClick: () => setExpanded((value) => !value),
|
|
2707
|
+
children: [
|
|
2708
|
+
/* @__PURE__ */ jsx(Icon, { source: "usx", name: "expand", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--expand" }),
|
|
2709
|
+
/* @__PURE__ */ jsx(Icon, { source: "usx", name: "contract", size: 3, className: "usx-layout__expand-icon usx-layout__expand-icon--contract" })
|
|
2710
|
+
]
|
|
2711
|
+
}
|
|
2712
|
+
) : null;
|
|
2713
|
+
return /* @__PURE__ */ jsx("div", { className: classes, ...props, children: variant === "single-column" ? /* @__PURE__ */ jsx(SingleColumnLayout, { expandButton, children: children || content }) : variant === "grid" ? /* @__PURE__ */ jsx(
|
|
2695
2714
|
GridLayout,
|
|
2696
2715
|
{
|
|
2697
2716
|
leftSidebar,
|
|
2698
2717
|
rightSidebar,
|
|
2699
2718
|
expandLeftSidebar,
|
|
2700
2719
|
expandRightSidebar,
|
|
2720
|
+
expandButton,
|
|
2701
2721
|
children: children || content
|
|
2702
2722
|
}
|
|
2703
|
-
) :
|
|
2723
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2724
|
+
expandButton,
|
|
2725
|
+
children || content
|
|
2726
|
+
] }) });
|
|
2704
2727
|
}
|
|
2705
2728
|
function isItemObject(item) {
|
|
2706
2729
|
return item && typeof item === "object" && !Array.isArray(item) && !React.isValidElement(item);
|
|
@@ -3048,6 +3071,7 @@ function Page({
|
|
|
3048
3071
|
id = void 0,
|
|
3049
3072
|
title = "Page title",
|
|
3050
3073
|
eyebrow = null,
|
|
3074
|
+
element = "main",
|
|
3051
3075
|
children = null,
|
|
3052
3076
|
content = null,
|
|
3053
3077
|
className = "",
|
|
@@ -3055,7 +3079,8 @@ function Page({
|
|
|
3055
3079
|
}) {
|
|
3056
3080
|
const classes = ["usx-page", className].filter(Boolean).join(" ");
|
|
3057
3081
|
const pageContent = children || content;
|
|
3058
|
-
|
|
3082
|
+
const Element = element;
|
|
3083
|
+
return /* @__PURE__ */ jsxs(Element, { id, className: classes, ...props, children: [
|
|
3059
3084
|
/* @__PURE__ */ jsxs("h1", { className: "usx-page__title", children: [
|
|
3060
3085
|
eyebrow ? /* @__PURE__ */ jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
|
|
3061
3086
|
title
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solexllc/usx-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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.
|
|
29
|
-
"@solexllc/usx-theme": "0.2.
|
|
30
|
-
"@solexllc/usx-uswds-fixes": "0.1.
|
|
28
|
+
"@solexllc/usx": "0.1.8",
|
|
29
|
+
"@solexllc/usx-theme": "0.2.3",
|
|
30
|
+
"@solexllc/usx-uswds-fixes": "0.1.5",
|
|
31
31
|
"classnames": "^2.5.1",
|
|
32
32
|
"prop-types": "^15.8.1"
|
|
33
33
|
},
|
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
|
|
4
|
-
const shapeClassMap = {
|
|
5
|
-
circle: 'usx-circle',
|
|
6
|
-
'rounded-sm': 'usx-rounded-sm',
|
|
7
|
-
'rounded-md': 'usx-rounded-md',
|
|
8
|
-
'rounded-lg': 'usx-rounded-lg',
|
|
9
|
-
'rounded-xl': 'usx-rounded-xl',
|
|
10
|
-
};
|
|
3
|
+
import Avatar, { AvatarProps } from '../avatar/Avatar';
|
|
11
4
|
|
|
12
5
|
interface Agency {
|
|
13
6
|
name: string;
|
|
14
7
|
href?: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
interface Logo {
|
|
18
|
-
href?: string;
|
|
19
|
-
src: string;
|
|
20
|
-
alt: string;
|
|
21
|
-
shape?: null | 'circle' | 'rounded-sm' | 'rounded-md' | 'rounded-lg' | 'rounded-xl';
|
|
22
|
-
imageClassName?: string;
|
|
8
|
+
/** Whether "the" precedes the name in the English disclaimer, e.g. "the Department of...". Default true. */
|
|
9
|
+
useThe?: boolean;
|
|
23
10
|
}
|
|
24
11
|
|
|
25
12
|
interface RequiredLink {
|
|
@@ -33,8 +20,8 @@ export interface IdentifierProps {
|
|
|
33
20
|
domain?: string;
|
|
34
21
|
language?: 'en' | 'es';
|
|
35
22
|
parentAgencies?: Agency[];
|
|
36
|
-
|
|
37
|
-
logoShape?:
|
|
23
|
+
avatarProps?: AvatarProps[];
|
|
24
|
+
logoShape?: AvatarProps['shape'];
|
|
38
25
|
requiredLinks?: RequiredLinks;
|
|
39
26
|
taxpayerDisclaimer?: boolean;
|
|
40
27
|
overlapAvatars?: boolean;
|
|
@@ -95,13 +82,17 @@ function renderDisclaimer({ language, parentAgencies, taxpayerDisclaimer }: { la
|
|
|
95
82
|
}
|
|
96
83
|
return (
|
|
97
84
|
<>
|
|
98
|
-
<span aria-hidden="true">An </span>official website of
|
|
99
|
-
{parentAgencies.map((agency, index) =>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
85
|
+
<span aria-hidden="true">An </span>official website of{' '}
|
|
86
|
+
{parentAgencies.map((agency, index) => {
|
|
87
|
+
const isLast = index === parentAgencies.length - 1;
|
|
88
|
+
const prefix = index === 0 ? '' : isLast ? ' and ' : ', ';
|
|
89
|
+
const article = agency.useThe === false ? '' : 'the ';
|
|
90
|
+
return (
|
|
91
|
+
<React.Fragment key={`${agency.name}-${index}`}>
|
|
92
|
+
{prefix}{article}<a href={agency.href || ''}>{agency.name}</a>
|
|
93
|
+
</React.Fragment>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
105
96
|
{taxpayerDisclaimer ? '. Produced and published at taxpayer expense.' : ''}
|
|
106
97
|
</>
|
|
107
98
|
);
|
|
@@ -111,7 +102,7 @@ export default function Identifier({
|
|
|
111
102
|
domain = 'domain.gov',
|
|
112
103
|
language = 'en',
|
|
113
104
|
parentAgencies = [],
|
|
114
|
-
|
|
105
|
+
avatarProps = [],
|
|
115
106
|
logoShape = null,
|
|
116
107
|
requiredLinks,
|
|
117
108
|
taxpayerDisclaimer = false,
|
|
@@ -133,7 +124,7 @@ export default function Identifier({
|
|
|
133
124
|
<div className={classes}>
|
|
134
125
|
<section className="usa-identifier__section usa-identifier__section--masthead" aria-label={labels.masthead}>
|
|
135
126
|
<div className="usa-identifier__container">
|
|
136
|
-
{
|
|
127
|
+
{avatarProps.length > 0 ? (
|
|
137
128
|
<div
|
|
138
129
|
className={classNames(
|
|
139
130
|
'usa-identifier__logos',
|
|
@@ -141,19 +132,14 @@ export default function Identifier({
|
|
|
141
132
|
overlapAvatars && 'usa-avatar-group--overlap',
|
|
142
133
|
)}
|
|
143
134
|
>
|
|
144
|
-
{
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
src={logo.src}
|
|
153
|
-
alt={logo.alt}
|
|
154
|
-
role="img"
|
|
155
|
-
/>
|
|
156
|
-
</a>
|
|
135
|
+
{avatarProps.map((avatar, index) => (
|
|
136
|
+
<Avatar
|
|
137
|
+
{...avatar}
|
|
138
|
+
key={`${avatar.alt}-${index}`}
|
|
139
|
+
shape={avatar.shape || logoShape}
|
|
140
|
+
className={classNames('usa-identifier__logo', avatar.className)}
|
|
141
|
+
imageClassName={classNames('usa-identifier__logo-img', avatar.imageClassName)}
|
|
142
|
+
/>
|
|
157
143
|
))}
|
|
158
144
|
</div>
|
|
159
145
|
) : null}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"href": ""
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"
|
|
14
|
+
"avatarProps": [
|
|
15
15
|
{
|
|
16
16
|
"href": "",
|
|
17
17
|
"src": "./lady_liberty.png",
|
|
@@ -72,18 +72,18 @@
|
|
|
72
72
|
"description": "Parent agency.",
|
|
73
73
|
"properties": {
|
|
74
74
|
"name": { "type": "string", "description": "Agency name." },
|
|
75
|
-
"href": { "type": "string", "description": "Link to the agency's site." }
|
|
75
|
+
"href": { "type": "string", "description": "Link to the agency's site." },
|
|
76
|
+
"useThe": { "type": "boolean", "description": "Whether \"the\" precedes the name in the English disclaimer, e.g. \"the Department of...\". Default true. Has no effect on the Spanish disclaimer." }
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
|
-
"
|
|
80
|
+
"avatarProps": {
|
|
80
81
|
"type": "array",
|
|
81
|
-
"description": "
|
|
82
|
+
"description": "Props for Avatar components rendered in the identifier masthead.",
|
|
82
83
|
"items": {
|
|
83
84
|
"type": "object",
|
|
84
|
-
"description": "
|
|
85
|
+
"description": "Avatar props, including image, initials, and icon variants.",
|
|
85
86
|
"component": "avatar",
|
|
86
|
-
"omit": ["variant", "value", "tooltip", "className", "contentClassName"],
|
|
87
87
|
"properties": {
|
|
88
88
|
"shape": {
|
|
89
89
|
"type": "select",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{# Django template for Identifier #}
|
|
2
|
+
{% load components %}
|
|
2
3
|
|
|
3
4
|
<div class="usa-identifier usx-identifier{% if className %} {{ className }}{% endif %}">
|
|
4
5
|
<section
|
|
@@ -6,17 +7,12 @@
|
|
|
6
7
|
aria-label="{% if language == 'es' %}Identificador de la agencia,{% else %}Agency identifier,{% endif %}"
|
|
7
8
|
>
|
|
8
9
|
<div class="usa-identifier__container">
|
|
9
|
-
{% if
|
|
10
|
+
{% if avatarProps %}
|
|
10
11
|
<div class="usa-identifier__logos usx-avatar-group{% if overlapAvatars %} usa-avatar-group--overlap{% endif %}">
|
|
11
|
-
{% for
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
src="{{ logo.src }}"
|
|
16
|
-
alt="{{ logo.alt }}"
|
|
17
|
-
role="img"
|
|
18
|
-
/>
|
|
19
|
-
</a>
|
|
12
|
+
{% for item in avatarProps %}
|
|
13
|
+
{% with avatarClass=item.className|default:'' imageClass=item.imageClassName|default:'' defaultShape=logoShape|default:'' %}
|
|
14
|
+
{% avatar href=item.href src=item.src alt=item.alt variant=item.variant|default:'image' value=item.value shape=item.shape|default:defaultShape tooltip=item.tooltip className='usa-identifier__logo '|add:avatarClass imageClassName='usa-identifier__logo-img '|add:imageClass contentClassName=item.contentClassName %}{% endavatar %}
|
|
15
|
+
{% endwith %}
|
|
20
16
|
{% endfor %}
|
|
21
17
|
</div>
|
|
22
18
|
{% endif %}
|
|
@@ -35,10 +31,10 @@
|
|
|
35
31
|
{% endfor %}
|
|
36
32
|
{% if taxpayerDisclaimer %} . Producido y publicado con dinero de los contribuyentes de impuestos.{% endif %}
|
|
37
33
|
{% else %}
|
|
38
|
-
<span aria-hidden="true">An </span>official website of
|
|
34
|
+
<span aria-hidden="true">An </span>official website of
|
|
39
35
|
{% for agency in parentAgencies %}
|
|
40
|
-
{% if not forloop.first %}{% if forloop.last %} and
|
|
41
|
-
<a href="{{ agency.href|default:'' }}">{{ agency.name }}</a>
|
|
36
|
+
{% if not forloop.first %}{% if forloop.last %} and{% else %},{% endif %}{% endif %}
|
|
37
|
+
{% if agency.useThe|default_bool:True %} the{% endif %} <a href="{{ agency.href|default:'' }}">{{ agency.name }}</a>
|
|
42
38
|
{% endfor %}
|
|
43
39
|
{% if taxpayerDisclaimer %} . Produced and published at taxpayer expense.{% endif %}
|
|
44
40
|
{% endif %}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<div class="usa-identifier__logos usx-avatar-group">
|
|
10
10
|
<a href="" class="usa-identifier__logo usx-avatar"
|
|
11
11
|
><img
|
|
12
|
-
class="usa-identifier__logo-img"
|
|
12
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
13
13
|
src="./lady_liberty.png"
|
|
14
14
|
alt="Statue of Liberty"
|
|
15
15
|
role="img"
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
<div class="usa-identifier__logos usx-avatar-group">
|
|
100
100
|
<a href="javascript:void(0)" class="usa-identifier__logo usx-avatar"
|
|
101
101
|
><img
|
|
102
|
-
class="usa-identifier__logo-img"
|
|
102
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
103
103
|
src="./lady_liberty.png"
|
|
104
104
|
alt="Statue of Liberty"
|
|
105
105
|
role="img"
|
|
@@ -190,14 +190,14 @@
|
|
|
190
190
|
<div class="usa-identifier__logos usx-avatar-group">
|
|
191
191
|
<a href="javascript:void(0)" class="usa-identifier__logo usx-avatar"
|
|
192
192
|
><img
|
|
193
|
-
class="usa-identifier__logo-img"
|
|
193
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
194
194
|
src="./george_washington.png"
|
|
195
195
|
alt="George Washington"
|
|
196
196
|
role="img"
|
|
197
197
|
/> </a
|
|
198
198
|
><a href="javascript:void(0);" class="usa-identifier__logo usx-avatar"
|
|
199
199
|
><img
|
|
200
|
-
class="usa-identifier__logo-img"
|
|
200
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
201
201
|
src="./thomas_jefferson.png"
|
|
202
202
|
alt="Thomas Jefferson"
|
|
203
203
|
role="img"
|
|
@@ -288,14 +288,14 @@
|
|
|
288
288
|
<div class="usa-identifier__logos usx-avatar-group">
|
|
289
289
|
<a href="javascript:void(0)" class="usa-identifier__logo usx-avatar"
|
|
290
290
|
><img
|
|
291
|
-
class="usa-identifier__logo-img"
|
|
291
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
292
292
|
src="./george_washington.png"
|
|
293
293
|
alt="George Washington"
|
|
294
294
|
role="img"
|
|
295
295
|
/> </a
|
|
296
296
|
><a href="javascript:void(0);" class="usa-identifier__logo usx-avatar"
|
|
297
297
|
><img
|
|
298
|
-
class="usa-identifier__logo-img"
|
|
298
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
299
299
|
src="./thomas_jefferson.png"
|
|
300
300
|
alt="Thomas Jefferson"
|
|
301
301
|
role="img"
|
|
@@ -387,14 +387,14 @@
|
|
|
387
387
|
<div class="usa-identifier__logos usx-avatar-group usa-avatar-group--overlap">
|
|
388
388
|
<a href="javascript:void(0)" class="usa-identifier__logo usx-avatar"
|
|
389
389
|
><img
|
|
390
|
-
class="usa-identifier__logo-img usx-circle"
|
|
390
|
+
class="usx-avatar__img usa-identifier__logo-img usx-circle"
|
|
391
391
|
src="./george_washington.png"
|
|
392
392
|
alt="George Washington"
|
|
393
393
|
role="img"
|
|
394
394
|
/> </a
|
|
395
395
|
><a href="javascript:void(0);" class="usa-identifier__logo usx-avatar"
|
|
396
396
|
><img
|
|
397
|
-
class="usa-identifier__logo-img usx-circle"
|
|
397
|
+
class="usx-avatar__img usa-identifier__logo-img usx-circle"
|
|
398
398
|
src="./thomas_jefferson.png"
|
|
399
399
|
alt="Thomas Jefferson"
|
|
400
400
|
role="img"
|
|
@@ -566,7 +566,7 @@
|
|
|
566
566
|
<div class="usa-identifier__logos usx-avatar-group">
|
|
567
567
|
<a href="javascript:void(0)" class="usa-identifier__logo usx-avatar"
|
|
568
568
|
><img
|
|
569
|
-
class="usa-identifier__logo-img"
|
|
569
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
570
570
|
src="./lady_liberty.png"
|
|
571
571
|
alt="Statue of Liberty"
|
|
572
572
|
role="img"
|
|
@@ -657,7 +657,7 @@
|
|
|
657
657
|
<div class="usa-identifier__logos usx-avatar-group">
|
|
658
658
|
<a href="javascript:void(0)" class="usa-identifier__logo usx-avatar"
|
|
659
659
|
><img
|
|
660
|
-
class="usa-identifier__logo-img"
|
|
660
|
+
class="usx-avatar__img usa-identifier__logo-img"
|
|
661
661
|
src="./lady_liberty.png"
|
|
662
662
|
alt="Statue of Liberty"
|
|
663
663
|
role="img"
|
|
@@ -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
|
}
|