@solexllc/usx-react 0.1.1 → 0.1.2
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
CHANGED
|
@@ -3145,19 +3145,35 @@
|
|
|
3145
3145
|
}
|
|
3146
3146
|
) });
|
|
3147
3147
|
}
|
|
3148
|
+
const externalIndicator = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3149
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "usa-sr-only", children: "External." }),
|
|
3150
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "launch", size: 1, className: "margin-left-05" })
|
|
3151
|
+
] });
|
|
3148
3152
|
function PrimaryNav({
|
|
3149
3153
|
navSections,
|
|
3150
3154
|
megamenu,
|
|
3151
3155
|
showSecondary = false,
|
|
3152
3156
|
secondaryLinks = [],
|
|
3153
3157
|
searchProps = null,
|
|
3158
|
+
utilityContent = null,
|
|
3154
3159
|
headerId = "header",
|
|
3155
3160
|
renderSearchDirectly = false
|
|
3156
3161
|
}) {
|
|
3157
3162
|
const navClasses = classNames("usa-nav__primary", "usa-accordion");
|
|
3158
3163
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3159
3164
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "usa-nav__close", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close" }) }),
|
|
3160
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */ jsxRuntime.
|
|
3165
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3166
|
+
"a",
|
|
3167
|
+
{
|
|
3168
|
+
href: section.href,
|
|
3169
|
+
className: "usa-nav__link",
|
|
3170
|
+
"aria-label": section.ariaLabel,
|
|
3171
|
+
children: [
|
|
3172
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: section.title }),
|
|
3173
|
+
section.external && externalIndicator
|
|
3174
|
+
]
|
|
3175
|
+
}
|
|
3176
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3161
3177
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3162
3178
|
"button",
|
|
3163
3179
|
{
|
|
@@ -3176,12 +3192,45 @@
|
|
|
3176
3192
|
const startIndex = colIndex * linksPerColumn;
|
|
3177
3193
|
const endIndex = Math.min(startIndex + linksPerColumn, links.length);
|
|
3178
3194
|
const columnLinks = links.slice(startIndex, endIndex);
|
|
3179
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.
|
|
3195
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3196
|
+
"a",
|
|
3197
|
+
{
|
|
3198
|
+
href: link.href,
|
|
3199
|
+
"aria-label": link.ariaLabel,
|
|
3200
|
+
children: [
|
|
3201
|
+
link.text,
|
|
3202
|
+
link.external && externalIndicator
|
|
3203
|
+
]
|
|
3204
|
+
}
|
|
3205
|
+
) }, linkIndex)) }) }, colIndex);
|
|
3180
3206
|
});
|
|
3181
|
-
})() }) }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.
|
|
3207
|
+
})() }) }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3208
|
+
"a",
|
|
3209
|
+
{
|
|
3210
|
+
href: link.href,
|
|
3211
|
+
"aria-label": link.ariaLabel,
|
|
3212
|
+
children: [
|
|
3213
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }),
|
|
3214
|
+
link.external && externalIndicator
|
|
3215
|
+
]
|
|
3216
|
+
}
|
|
3217
|
+
) }, linkIndex)) }))
|
|
3182
3218
|
] }) }, index)) }),
|
|
3183
|
-
showSecondary && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.
|
|
3184
|
-
|
|
3219
|
+
showSecondary && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3220
|
+
"a",
|
|
3221
|
+
{
|
|
3222
|
+
href: link.href,
|
|
3223
|
+
"aria-label": link.ariaLabel,
|
|
3224
|
+
children: [
|
|
3225
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }),
|
|
3226
|
+
link.external && externalIndicator
|
|
3227
|
+
]
|
|
3228
|
+
}
|
|
3229
|
+
) }, index)) }) }),
|
|
3230
|
+
renderSearchDirectly && (utilityContent || searchProps) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-nav__utility", children: [
|
|
3231
|
+
utilityContent,
|
|
3232
|
+
searchProps && /* @__PURE__ */ jsxRuntime.jsx(Search, { ...searchProps })
|
|
3233
|
+
] })
|
|
3185
3234
|
] });
|
|
3186
3235
|
}
|
|
3187
3236
|
function Header({
|
|
@@ -3196,6 +3245,8 @@
|
|
|
3196
3245
|
useMenuIcon = false,
|
|
3197
3246
|
stickyNav = false,
|
|
3198
3247
|
className = "",
|
|
3248
|
+
utilityContent = null,
|
|
3249
|
+
navEndContent = null,
|
|
3199
3250
|
...props
|
|
3200
3251
|
}) {
|
|
3201
3252
|
const headerClasses = classNames(
|
|
@@ -3229,9 +3280,23 @@
|
|
|
3229
3280
|
}
|
|
3230
3281
|
),
|
|
3231
3282
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usa-nav__secondary", children: [
|
|
3232
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.
|
|
3233
|
-
|
|
3234
|
-
|
|
3283
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3284
|
+
"a",
|
|
3285
|
+
{
|
|
3286
|
+
href: link.href,
|
|
3287
|
+
"aria-label": link.ariaLabel,
|
|
3288
|
+
children: [
|
|
3289
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }),
|
|
3290
|
+
link.external && externalIndicator
|
|
3291
|
+
]
|
|
3292
|
+
}
|
|
3293
|
+
) }, index)) }),
|
|
3294
|
+
(utilityContent || searchProps) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-nav__utility", children: [
|
|
3295
|
+
utilityContent,
|
|
3296
|
+
searchProps && /* @__PURE__ */ jsxRuntime.jsx(Search, { ...searchProps })
|
|
3297
|
+
] })
|
|
3298
|
+
] }),
|
|
3299
|
+
navEndContent && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-nav__end-slot", children: navEndContent })
|
|
3235
3300
|
] }) })
|
|
3236
3301
|
] });
|
|
3237
3302
|
}
|
|
@@ -3245,6 +3310,7 @@
|
|
|
3245
3310
|
showSecondary: false,
|
|
3246
3311
|
secondaryLinks,
|
|
3247
3312
|
searchProps,
|
|
3313
|
+
utilityContent,
|
|
3248
3314
|
headerId: id,
|
|
3249
3315
|
renderSearchDirectly: true
|
|
3250
3316
|
}
|
|
@@ -5764,7 +5830,7 @@
|
|
|
5764
5830
|
"button",
|
|
5765
5831
|
{
|
|
5766
5832
|
type: "button",
|
|
5767
|
-
className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
|
|
5833
|
+
className: "usa-button usx-button usx-button--ghost text-muted usx-theme-picker__trigger",
|
|
5768
5834
|
"aria-label": label,
|
|
5769
5835
|
onClick: () => setOpen(true),
|
|
5770
5836
|
children: /* @__PURE__ */ jsxRuntime.jsx(PaletteIcon, {})
|
package/dist/index.js
CHANGED
|
@@ -3143,19 +3143,35 @@ function Search({
|
|
|
3143
3143
|
}
|
|
3144
3144
|
) });
|
|
3145
3145
|
}
|
|
3146
|
+
const externalIndicator = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3147
|
+
/* @__PURE__ */ jsx("span", { className: "usa-sr-only", children: "External." }),
|
|
3148
|
+
/* @__PURE__ */ jsx(Icon, { name: "launch", size: 1, className: "margin-left-05" })
|
|
3149
|
+
] });
|
|
3146
3150
|
function PrimaryNav({
|
|
3147
3151
|
navSections,
|
|
3148
3152
|
megamenu,
|
|
3149
3153
|
showSecondary = false,
|
|
3150
3154
|
secondaryLinks = [],
|
|
3151
3155
|
searchProps = null,
|
|
3156
|
+
utilityContent = null,
|
|
3152
3157
|
headerId = "header",
|
|
3153
3158
|
renderSearchDirectly = false
|
|
3154
3159
|
}) {
|
|
3155
3160
|
const navClasses = classNames("usa-nav__primary", "usa-accordion");
|
|
3156
3161
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3157
3162
|
/* @__PURE__ */ jsx("button", { type: "button", className: "usa-nav__close", children: /* @__PURE__ */ jsx(Icon, { name: "close" }) }),
|
|
3158
|
-
/* @__PURE__ */ jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */
|
|
3163
|
+
/* @__PURE__ */ jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */ jsxs(
|
|
3164
|
+
"a",
|
|
3165
|
+
{
|
|
3166
|
+
href: section.href,
|
|
3167
|
+
className: "usa-nav__link",
|
|
3168
|
+
"aria-label": section.ariaLabel,
|
|
3169
|
+
children: [
|
|
3170
|
+
/* @__PURE__ */ jsx("span", { children: section.title }),
|
|
3171
|
+
section.external && externalIndicator
|
|
3172
|
+
]
|
|
3173
|
+
}
|
|
3174
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3159
3175
|
/* @__PURE__ */ jsx(
|
|
3160
3176
|
"button",
|
|
3161
3177
|
{
|
|
@@ -3174,12 +3190,45 @@ function PrimaryNav({
|
|
|
3174
3190
|
const startIndex = colIndex * linksPerColumn;
|
|
3175
3191
|
const endIndex = Math.min(startIndex + linksPerColumn, links.length);
|
|
3176
3192
|
const columnLinks = links.slice(startIndex, endIndex);
|
|
3177
|
-
return /* @__PURE__ */ jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */
|
|
3193
|
+
return /* @__PURE__ */ jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxs(
|
|
3194
|
+
"a",
|
|
3195
|
+
{
|
|
3196
|
+
href: link.href,
|
|
3197
|
+
"aria-label": link.ariaLabel,
|
|
3198
|
+
children: [
|
|
3199
|
+
link.text,
|
|
3200
|
+
link.external && externalIndicator
|
|
3201
|
+
]
|
|
3202
|
+
}
|
|
3203
|
+
) }, linkIndex)) }) }, colIndex);
|
|
3178
3204
|
});
|
|
3179
|
-
})() }) }) : /* @__PURE__ */ jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */
|
|
3205
|
+
})() }) }) : /* @__PURE__ */ jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxs(
|
|
3206
|
+
"a",
|
|
3207
|
+
{
|
|
3208
|
+
href: link.href,
|
|
3209
|
+
"aria-label": link.ariaLabel,
|
|
3210
|
+
children: [
|
|
3211
|
+
/* @__PURE__ */ jsx("span", { children: link.text }),
|
|
3212
|
+
link.external && externalIndicator
|
|
3213
|
+
]
|
|
3214
|
+
}
|
|
3215
|
+
) }, linkIndex)) }))
|
|
3180
3216
|
] }) }, index)) }),
|
|
3181
|
-
showSecondary && /* @__PURE__ */ jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */
|
|
3182
|
-
|
|
3217
|
+
showSecondary && /* @__PURE__ */ jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxs(
|
|
3218
|
+
"a",
|
|
3219
|
+
{
|
|
3220
|
+
href: link.href,
|
|
3221
|
+
"aria-label": link.ariaLabel,
|
|
3222
|
+
children: [
|
|
3223
|
+
/* @__PURE__ */ jsx("span", { children: link.text }),
|
|
3224
|
+
link.external && externalIndicator
|
|
3225
|
+
]
|
|
3226
|
+
}
|
|
3227
|
+
) }, index)) }) }),
|
|
3228
|
+
renderSearchDirectly && (utilityContent || searchProps) && /* @__PURE__ */ jsxs("div", { className: "usx-nav__utility", children: [
|
|
3229
|
+
utilityContent,
|
|
3230
|
+
searchProps && /* @__PURE__ */ jsx(Search, { ...searchProps })
|
|
3231
|
+
] })
|
|
3183
3232
|
] });
|
|
3184
3233
|
}
|
|
3185
3234
|
function Header({
|
|
@@ -3194,6 +3243,8 @@ function Header({
|
|
|
3194
3243
|
useMenuIcon = false,
|
|
3195
3244
|
stickyNav = false,
|
|
3196
3245
|
className = "",
|
|
3246
|
+
utilityContent = null,
|
|
3247
|
+
navEndContent = null,
|
|
3197
3248
|
...props
|
|
3198
3249
|
}) {
|
|
3199
3250
|
const headerClasses = classNames(
|
|
@@ -3227,9 +3278,23 @@ function Header({
|
|
|
3227
3278
|
}
|
|
3228
3279
|
),
|
|
3229
3280
|
/* @__PURE__ */ jsxs("div", { className: "usa-nav__secondary", children: [
|
|
3230
|
-
/* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */
|
|
3231
|
-
|
|
3232
|
-
|
|
3281
|
+
/* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxs(
|
|
3282
|
+
"a",
|
|
3283
|
+
{
|
|
3284
|
+
href: link.href,
|
|
3285
|
+
"aria-label": link.ariaLabel,
|
|
3286
|
+
children: [
|
|
3287
|
+
/* @__PURE__ */ jsx("span", { children: link.text }),
|
|
3288
|
+
link.external && externalIndicator
|
|
3289
|
+
]
|
|
3290
|
+
}
|
|
3291
|
+
) }, index)) }),
|
|
3292
|
+
(utilityContent || searchProps) && /* @__PURE__ */ jsxs("div", { className: "usx-nav__utility", children: [
|
|
3293
|
+
utilityContent,
|
|
3294
|
+
searchProps && /* @__PURE__ */ jsx(Search, { ...searchProps })
|
|
3295
|
+
] })
|
|
3296
|
+
] }),
|
|
3297
|
+
navEndContent && /* @__PURE__ */ jsx("div", { className: "usx-nav__end-slot", children: navEndContent })
|
|
3233
3298
|
] }) })
|
|
3234
3299
|
] });
|
|
3235
3300
|
}
|
|
@@ -3243,6 +3308,7 @@ function Header({
|
|
|
3243
3308
|
showSecondary: false,
|
|
3244
3309
|
secondaryLinks,
|
|
3245
3310
|
searchProps,
|
|
3311
|
+
utilityContent,
|
|
3246
3312
|
headerId: id,
|
|
3247
3313
|
renderSearchDirectly: true
|
|
3248
3314
|
}
|
|
@@ -5762,7 +5828,7 @@ function ThemePicker({
|
|
|
5762
5828
|
"button",
|
|
5763
5829
|
{
|
|
5764
5830
|
type: "button",
|
|
5765
|
-
className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
|
|
5831
|
+
className: "usa-button usx-button usx-button--ghost text-muted usx-theme-picker__trigger",
|
|
5766
5832
|
"aria-label": label,
|
|
5767
5833
|
onClick: () => setOpen(true),
|
|
5768
5834
|
children: /* @__PURE__ */ jsx(PaletteIcon, {})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solexllc/usx-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React component library for USX.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@solexllc/usx": "0.1.
|
|
28
|
+
"@solexllc/usx": "0.1.2",
|
|
29
29
|
"@solexllc/usx-theme": "0.1.1",
|
|
30
30
|
"@solexllc/usx-uswds-fixes": "0.1.1",
|
|
31
31
|
"classnames": "^2.5.1",
|
|
@@ -4,10 +4,18 @@ import Icon from '../icon/Icon';
|
|
|
4
4
|
import Search, { SearchProps } from '../search/Search';
|
|
5
5
|
import Branding, { BrandingProps } from './Branding';
|
|
6
6
|
|
|
7
|
+
const externalIndicator = (
|
|
8
|
+
<>
|
|
9
|
+
<span className="usa-sr-only">External.</span>
|
|
10
|
+
<Icon name="launch" size={1} className="margin-left-05" />
|
|
11
|
+
</>
|
|
12
|
+
);
|
|
13
|
+
|
|
7
14
|
export interface HeaderNavLink {
|
|
8
15
|
text: string;
|
|
9
16
|
href: string;
|
|
10
17
|
ariaLabel?: string;
|
|
18
|
+
external?: boolean;
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export interface HeaderNavSection {
|
|
@@ -15,6 +23,7 @@ export interface HeaderNavSection {
|
|
|
15
23
|
links?: HeaderNavLink[];
|
|
16
24
|
href?: string;
|
|
17
25
|
ariaLabel?: string;
|
|
26
|
+
external?: boolean;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
interface PrimaryNavProps {
|
|
@@ -23,6 +32,7 @@ interface PrimaryNavProps {
|
|
|
23
32
|
showSecondary?: boolean;
|
|
24
33
|
secondaryLinks?: HeaderNavLink[];
|
|
25
34
|
searchProps?: SearchProps | null;
|
|
35
|
+
utilityContent?: React.ReactNode;
|
|
26
36
|
headerId?: string;
|
|
27
37
|
renderSearchDirectly?: boolean;
|
|
28
38
|
}
|
|
@@ -33,6 +43,7 @@ function PrimaryNav({
|
|
|
33
43
|
showSecondary = false,
|
|
34
44
|
secondaryLinks = [],
|
|
35
45
|
searchProps = null,
|
|
46
|
+
utilityContent = null,
|
|
36
47
|
headerId = 'header',
|
|
37
48
|
renderSearchDirectly = false,
|
|
38
49
|
}: PrimaryNavProps) {
|
|
@@ -47,8 +58,13 @@ function PrimaryNav({
|
|
|
47
58
|
{navSections.map((section, index) => (
|
|
48
59
|
<li key={index} className="usa-nav__primary-item">
|
|
49
60
|
{section.href ? (
|
|
50
|
-
<a
|
|
61
|
+
<a
|
|
62
|
+
href={section.href}
|
|
63
|
+
className="usa-nav__link"
|
|
64
|
+
aria-label={section.ariaLabel}
|
|
65
|
+
>
|
|
51
66
|
<span>{section.title}</span>
|
|
67
|
+
{section.external && externalIndicator}
|
|
52
68
|
</a>
|
|
53
69
|
) : (
|
|
54
70
|
<>
|
|
@@ -77,8 +93,12 @@ function PrimaryNav({
|
|
|
77
93
|
<ul className="usa-nav__submenu-list">
|
|
78
94
|
{columnLinks.map((link, linkIndex) => (
|
|
79
95
|
<li key={linkIndex} className="usa-nav__submenu-item">
|
|
80
|
-
<a
|
|
96
|
+
<a
|
|
97
|
+
href={link.href}
|
|
98
|
+
aria-label={link.ariaLabel}
|
|
99
|
+
>
|
|
81
100
|
{link.text}
|
|
101
|
+
{link.external && externalIndicator}
|
|
82
102
|
</a>
|
|
83
103
|
</li>
|
|
84
104
|
))}
|
|
@@ -93,8 +113,12 @@ function PrimaryNav({
|
|
|
93
113
|
<ul id={`${headerId}-nav-section-${index}`} className="usa-nav__submenu" hidden={true}>
|
|
94
114
|
{section.links!.map((link, linkIndex) => (
|
|
95
115
|
<li key={linkIndex} className="usa-nav__submenu-item">
|
|
96
|
-
<a
|
|
116
|
+
<a
|
|
117
|
+
href={link.href}
|
|
118
|
+
aria-label={link.ariaLabel}
|
|
119
|
+
>
|
|
97
120
|
<span>{link.text}</span>
|
|
121
|
+
{link.external && externalIndicator}
|
|
98
122
|
</a>
|
|
99
123
|
</li>
|
|
100
124
|
))}
|
|
@@ -111,15 +135,24 @@ function PrimaryNav({
|
|
|
111
135
|
<ul className="usa-nav__secondary-links">
|
|
112
136
|
{secondaryLinks.map((link, index) => (
|
|
113
137
|
<li key={index} className="usa-nav__secondary-item">
|
|
114
|
-
<a
|
|
138
|
+
<a
|
|
139
|
+
href={link.href}
|
|
140
|
+
aria-label={link.ariaLabel}
|
|
141
|
+
>
|
|
115
142
|
<span>{link.text}</span>
|
|
143
|
+
{link.external && externalIndicator}
|
|
116
144
|
</a>
|
|
117
145
|
</li>
|
|
118
146
|
))}
|
|
119
147
|
</ul>
|
|
120
148
|
</div>
|
|
121
149
|
)}
|
|
122
|
-
{renderSearchDirectly && searchProps &&
|
|
150
|
+
{renderSearchDirectly && (utilityContent || searchProps) && (
|
|
151
|
+
<div className="usx-nav__utility">
|
|
152
|
+
{utilityContent}
|
|
153
|
+
{searchProps && <Search {...searchProps} />}
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
123
156
|
</>
|
|
124
157
|
);
|
|
125
158
|
}
|
|
@@ -136,6 +169,10 @@ export interface HeaderProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
136
169
|
useMenuIcon?: boolean;
|
|
137
170
|
stickyNav?: boolean;
|
|
138
171
|
className?: string;
|
|
172
|
+
/** Rendered inline, to the left of the search box (in both header variants). */
|
|
173
|
+
utilityContent?: React.ReactNode;
|
|
174
|
+
/** Rendered right-justified, in line with the primary nav links (extended header only). */
|
|
175
|
+
navEndContent?: React.ReactNode;
|
|
139
176
|
}
|
|
140
177
|
|
|
141
178
|
export default function Header({
|
|
@@ -150,6 +187,8 @@ export default function Header({
|
|
|
150
187
|
useMenuIcon = false,
|
|
151
188
|
stickyNav = false,
|
|
152
189
|
className = '',
|
|
190
|
+
utilityContent = null,
|
|
191
|
+
navEndContent = null,
|
|
153
192
|
...props
|
|
154
193
|
}: HeaderProps) {
|
|
155
194
|
const headerClasses = ClassNames(
|
|
@@ -194,14 +233,24 @@ export default function Header({
|
|
|
194
233
|
<ul className="usa-nav__secondary-links">
|
|
195
234
|
{secondaryLinks.map((link, index) => (
|
|
196
235
|
<li key={index} className="usa-nav__secondary-item">
|
|
197
|
-
<a
|
|
236
|
+
<a
|
|
237
|
+
href={link.href}
|
|
238
|
+
aria-label={link.ariaLabel}
|
|
239
|
+
>
|
|
198
240
|
<span>{link.text}</span>
|
|
241
|
+
{link.external && externalIndicator}
|
|
199
242
|
</a>
|
|
200
243
|
</li>
|
|
201
244
|
))}
|
|
202
245
|
</ul>
|
|
203
|
-
{searchProps &&
|
|
246
|
+
{(utilityContent || searchProps) && (
|
|
247
|
+
<div className="usx-nav__utility">
|
|
248
|
+
{utilityContent}
|
|
249
|
+
{searchProps && <Search {...searchProps} />}
|
|
250
|
+
</div>
|
|
251
|
+
)}
|
|
204
252
|
</div>
|
|
253
|
+
{navEndContent && <div className="usx-nav__end-slot">{navEndContent}</div>}
|
|
205
254
|
</div>
|
|
206
255
|
</nav>
|
|
207
256
|
</>
|
|
@@ -219,6 +268,7 @@ export default function Header({
|
|
|
219
268
|
showSecondary={false}
|
|
220
269
|
secondaryLinks={secondaryLinks}
|
|
221
270
|
searchProps={searchProps}
|
|
271
|
+
utilityContent={utilityContent}
|
|
222
272
|
headerId={id}
|
|
223
273
|
renderSearchDirectly={true}
|
|
224
274
|
/>
|
|
@@ -53,6 +53,14 @@
|
|
|
53
53
|
"className": {
|
|
54
54
|
"type": "string",
|
|
55
55
|
"description": "Additional classes"
|
|
56
|
+
},
|
|
57
|
+
"utilityContent": {
|
|
58
|
+
"type": "slot",
|
|
59
|
+
"description": "Rendered inline, to the left of the search box (in both header variants)."
|
|
60
|
+
},
|
|
61
|
+
"navEndContent": {
|
|
62
|
+
"type": "slot",
|
|
63
|
+
"description": "Rendered right-justified, in line with the primary nav links (extended header only)."
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
}
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
</em>
|
|
57
57
|
{% endif %}
|
|
58
58
|
</div>
|
|
59
|
-
<button type="button" class="usa-menu-btn">
|
|
59
|
+
<button type="button" class="usa-menu-btn align-center">
|
|
60
60
|
{% if useMenuIcon %}
|
|
61
61
|
{% icon name='menu' size=3 %}{% endicon %}
|
|
62
62
|
{% else %}
|
|
@@ -65,130 +65,144 @@
|
|
|
65
65
|
</button>
|
|
66
66
|
</div>
|
|
67
67
|
|
|
68
|
-
{% if extended %}
|
|
69
|
-
<nav aria-label="Primary navigation" class="usa-nav usx-nav">
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{% if section.
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
</
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</
|
|
68
|
+
{% if not extended %}
|
|
69
|
+
<nav aria-label="Primary navigation" class="usa-nav usx-nav{% if stickyNav %} usx-nav--sticky{% endif %}">
|
|
70
|
+
<button type="button" class="usa-nav__close">
|
|
71
|
+
{% icon name='close' %}{% endicon %}
|
|
72
|
+
</button>
|
|
73
|
+
<ul class="usa-nav__primary usa-accordion">
|
|
74
|
+
{% for section in navSections %}
|
|
75
|
+
<li class="usa-nav__primary-item">
|
|
76
|
+
{% if section.href %}
|
|
77
|
+
<a href="{{ section.href }}" class="usa-nav__link" {% if section.ariaLabel %}aria-label="{{ section.ariaLabel }}"{% endif %}>
|
|
78
|
+
<span>{{ section.title }}</span>
|
|
79
|
+
{% if section.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
|
|
80
|
+
</a>
|
|
81
|
+
{% else %}
|
|
82
|
+
<button type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" aria-controls="{{ id }}-nav-section-{{ forloop.counter0 }}">
|
|
83
|
+
<span>{{ section.title }}</span>
|
|
84
|
+
</button>
|
|
85
|
+
{% if section.links %}
|
|
86
|
+
{% if megamenu %}
|
|
87
|
+
<div id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu usa-megamenu" hidden="hidden">
|
|
88
|
+
<div class="grid-row grid-gap-4">
|
|
89
|
+
<div class="usa-col">
|
|
90
|
+
<ul class="usa-nav__submenu-list">
|
|
91
|
+
{% for link in section.links %}
|
|
92
|
+
<li class="usa-nav__submenu-item">
|
|
93
|
+
<a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
|
|
94
|
+
{{ link.text }}
|
|
95
|
+
{% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
|
|
96
|
+
</a>
|
|
97
|
+
</li>
|
|
98
|
+
{% endfor %}
|
|
99
|
+
</ul>
|
|
100
100
|
</div>
|
|
101
101
|
</div>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
</div>
|
|
103
|
+
{% else %}
|
|
104
|
+
<ul id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu" hidden="hidden">
|
|
105
|
+
{% for link in section.links %}
|
|
106
|
+
<li class="usa-nav__submenu-item">
|
|
107
|
+
<a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
|
|
108
|
+
<span>{{ link.text }}</span>
|
|
109
|
+
{% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
|
|
110
|
+
</a>
|
|
111
|
+
</li>
|
|
112
|
+
{% endfor %}
|
|
113
|
+
</ul>
|
|
113
114
|
{% endif %}
|
|
114
115
|
{% endif %}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
<a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
|
|
123
|
-
<span>{{ link.text }}</span>
|
|
124
|
-
</a>
|
|
125
|
-
</li>
|
|
126
|
-
{% endfor %}
|
|
127
|
-
</ul>
|
|
116
|
+
{% endif %}
|
|
117
|
+
</li>
|
|
118
|
+
{% endfor %}
|
|
119
|
+
</ul>
|
|
120
|
+
{% if utilityContent or searchProps %}
|
|
121
|
+
<div class="usx-nav__utility">
|
|
122
|
+
{% if utilityContent %}{{ utilityContent|safe }}{% endif %}
|
|
128
123
|
{% if searchProps %}
|
|
129
124
|
{% search id=searchProps.id ariaLabel=searchProps.ariaLabel searchKey=searchProps.searchKey label=searchProps.label icon=searchProps.icon iconOnly=searchProps.iconOnly buttonVariant=searchProps.buttonVariant big=searchProps.big action=searchProps.action placeholder=searchProps.placeholder defaultValue=searchProps.defaultValue onSubmit=searchProps.onSubmit className=searchProps.className|default:'' %}{% endsearch %}
|
|
130
125
|
{% endif %}
|
|
131
126
|
</div>
|
|
132
|
-
|
|
127
|
+
{% endif %}
|
|
133
128
|
</nav>
|
|
134
|
-
{%
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{%
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
129
|
+
{% endif %}
|
|
130
|
+
{% if not extended %}</div>{% endif %}
|
|
131
|
+
</header>
|
|
132
|
+
{% if extended %}
|
|
133
|
+
<nav aria-label="Primary navigation" class="usa-nav usx-nav{% if stickyNav %} usx-nav--sticky{% endif %}">
|
|
134
|
+
<div class="usa-nav__inner">
|
|
135
|
+
<button type="button" class="usa-nav__close">
|
|
136
|
+
{% icon name='close' %}{% endicon %}
|
|
137
|
+
</button>
|
|
138
|
+
<ul class="usa-nav__primary usa-accordion">
|
|
139
|
+
{% for section in navSections %}
|
|
140
|
+
<li class="usa-nav__primary-item">
|
|
141
|
+
{% if section.href %}
|
|
142
|
+
<a href="{{ section.href }}" class="usa-nav__link" {% if section.ariaLabel %}aria-label="{{ section.ariaLabel }}"{% endif %}>
|
|
143
|
+
<span>{{ section.title }}</span>
|
|
144
|
+
{% if section.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
|
|
145
|
+
</a>
|
|
146
|
+
{% else %}
|
|
147
|
+
<button type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" aria-controls="{{ id }}-nav-section-{{ forloop.counter0 }}">
|
|
148
|
+
<span>{{ section.title }}</span>
|
|
149
|
+
</button>
|
|
150
|
+
{% if section.links %}
|
|
151
|
+
{% if megamenu %}
|
|
152
|
+
<div id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu usa-megamenu" hidden="hidden">
|
|
153
|
+
<div class="grid-row grid-gap-4">
|
|
154
|
+
<div class="usa-col">
|
|
155
|
+
<ul class="usa-nav__submenu-list">
|
|
156
|
+
{% for link in section.links %}
|
|
157
|
+
<li class="usa-nav__submenu-item">
|
|
158
|
+
<a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
|
|
159
|
+
{{ link.text }}
|
|
160
|
+
{% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
|
|
161
|
+
</a>
|
|
162
|
+
</li>
|
|
163
|
+
{% endfor %}
|
|
164
|
+
</ul>
|
|
166
165
|
</div>
|
|
167
166
|
</div>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
</
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
167
|
+
</div>
|
|
168
|
+
{% else %}
|
|
169
|
+
<ul id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu" hidden="hidden">
|
|
170
|
+
{% for link in section.links %}
|
|
171
|
+
<li class="usa-nav__submenu-item">
|
|
172
|
+
<a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
|
|
173
|
+
<span>{{ link.text }}</span>
|
|
174
|
+
{% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
|
|
175
|
+
</a>
|
|
176
|
+
</li>
|
|
177
|
+
{% endfor %}
|
|
178
|
+
</ul>
|
|
179
179
|
{% endif %}
|
|
180
180
|
{% endif %}
|
|
181
|
+
{% endif %}
|
|
182
|
+
</li>
|
|
183
|
+
{% endfor %}
|
|
184
|
+
</ul>
|
|
185
|
+
<div class="usa-nav__secondary">
|
|
186
|
+
<ul class="usa-nav__secondary-links">
|
|
187
|
+
{% for link in secondaryLinks %}
|
|
188
|
+
<li class="usa-nav__secondary-item">
|
|
189
|
+
<a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
|
|
190
|
+
<span>{{ link.text }}</span>
|
|
191
|
+
{% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
|
|
192
|
+
</a>
|
|
181
193
|
</li>
|
|
182
194
|
{% endfor %}
|
|
183
195
|
</ul>
|
|
184
|
-
{% if searchProps %}
|
|
185
|
-
|
|
196
|
+
{% if utilityContent or searchProps %}
|
|
197
|
+
<div class="usx-nav__utility">
|
|
198
|
+
{% if utilityContent %}{{ utilityContent|safe }}{% endif %}
|
|
199
|
+
{% if searchProps %}
|
|
200
|
+
{% search id=searchProps.id ariaLabel=searchProps.ariaLabel searchKey=searchProps.searchKey label=searchProps.label icon=searchProps.icon iconOnly=searchProps.iconOnly buttonVariant=searchProps.buttonVariant big=searchProps.big action=searchProps.action placeholder=searchProps.placeholder defaultValue=searchProps.defaultValue onSubmit=searchProps.onSubmit className=searchProps.className|default:'' %}{% endsearch %}
|
|
201
|
+
{% endif %}
|
|
202
|
+
</div>
|
|
186
203
|
{% endif %}
|
|
187
|
-
</
|
|
204
|
+
</div>
|
|
205
|
+
{% if navEndContent %}<div class="usx-nav__end-slot">{{ navEndContent|safe }}</div>{% endif %}
|
|
188
206
|
</div>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
{% if not extended %}
|
|
192
|
-
</div>
|
|
193
|
-
{% endif %}
|
|
194
|
-
</header>
|
|
207
|
+
</nav>
|
|
208
|
+
{% endif %}
|
|
@@ -86,7 +86,7 @@ export default function ThemePicker({
|
|
|
86
86
|
) : (
|
|
87
87
|
<button
|
|
88
88
|
type="button"
|
|
89
|
-
className="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
|
|
89
|
+
className="usa-button usx-button usx-button--ghost text-muted usx-theme-picker__trigger"
|
|
90
90
|
aria-label={label}
|
|
91
91
|
onClick={() => setOpen(true)}
|
|
92
92
|
>
|