@solexllc/usx-react 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -0
- package/dist/index.cjs +5 -2
- package/dist/index.js +5 -2
- package/package.json +4 -4
- package/src/components/code/Code.tsx +3 -2
- package/src/components/code/code.django.html +1 -1
- package/src/components/code/code.html +43 -0
- package/src/components/code/config.json +6 -1
- package/src/components/footer/footer.django.html +8 -8
- package/src/components/footer/footer.html +45 -21
- package/src/components/layout/Layout.tsx +10 -9
- package/src/components/layout/config.json +10 -0
- package/src/components/layout/layout.django.html +2 -2
- package/src/components/layout/layout.html +2 -2
package/README.md
CHANGED
|
@@ -33,6 +33,99 @@ at the repo root for the full, up-to-date list of implemented components.
|
|
|
33
33
|
|
|
34
34
|
## Token usage
|
|
35
35
|
|
|
36
|
+
### Responsive Layout
|
|
37
|
+
|
|
38
|
+
`.usx-layout` owns the responsive outer padding: 12px (1.5 units)
|
|
39
|
+
below desktop and 32px (4 units) at desktop. `SingleColumnLayout` and the grid's
|
|
40
|
+
main content have no padding. The left sidebar has 32px of right padding, and
|
|
41
|
+
the right sidebar has 32px of left padding, keeping the inner gap large at
|
|
42
|
+
every width where sidebars are visible. These gaps are included in the sidebar
|
|
43
|
+
widths. Expanded sidebars extend into the outer gutter without removing the
|
|
44
|
+
inner gap. CSS container queries show supplied sidebars when
|
|
45
|
+
their combined widths fit alongside the minimum main-column width, capped by
|
|
46
|
+
the normal content maximum. Both sidebars appear together when both are supplied.
|
|
47
|
+
This works for expandable and non-expandable layouts and does not change when
|
|
48
|
+
expansion is toggled. Each sidebar adds 16rem outside
|
|
49
|
+
the configured 64rem content maximum. The unpadded main-column cap subtracts
|
|
50
|
+
twice the current outer gutter from that maximum, preserving the previous
|
|
51
|
+
readable width. The same subtraction applies to the expanded maximum.
|
|
52
|
+
A grid without sidebars matches the
|
|
53
|
+
single-column layout at every width. Expansion changes the content maximum to
|
|
54
|
+
100rem without changing gutters or sidebar visibility.
|
|
55
|
+
|
|
56
|
+
The main content, rather than the combined content-and-sidebar group, centers
|
|
57
|
+
when there is enough space on both sides. With default widths, all variants
|
|
58
|
+
align at 96rem of outer width (64rem configured content width plus room for a
|
|
59
|
+
16rem sidebar on either side).
|
|
60
|
+
Before that point, visible columns fill the available width until they reach
|
|
61
|
+
their caps; absent sidebars do not reserve tracks. A one-sidebar layout may
|
|
62
|
+
remain off-center while there is insufficient space to center its capped main
|
|
63
|
+
column without overlapping the sidebar. Expanded content aligns at 132rem of
|
|
64
|
+
outer width.
|
|
65
|
+
|
|
66
|
+
With the themed stylesheet and generated theme CSS loaded, these runtime tokens
|
|
67
|
+
can be set on a layout or an ancestor:
|
|
68
|
+
|
|
69
|
+
| Token | Default |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `--usx-layout-gutter-mobile` | `0.75rem` |
|
|
72
|
+
| `--usx-layout-gutter` | `2rem` |
|
|
73
|
+
|
|
74
|
+
The desktop gutter token also supplies the fixed inner sidebar gap. Widths and
|
|
75
|
+
their container-query thresholds are configured together at Sass compile time:
|
|
76
|
+
|
|
77
|
+
| Sass variable | Default |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `$usx-layout-max-width` | `64rem` |
|
|
80
|
+
| `$usx-layout-expanded-max-width` | `100rem` |
|
|
81
|
+
| `$usx-layout-sidebar-width` | `16rem` |
|
|
82
|
+
| `$usx-layout-content-min-width` | `32rem` |
|
|
83
|
+
|
|
84
|
+
The minimum main-column width is unpadded content space. Set it to match
|
|
85
|
+
the reading or control space your content needs. Default sidebar thresholds
|
|
86
|
+
are 48rem with one sidebar and 64rem with both. A narrow theme with 12rem
|
|
87
|
+
sidebars needs 44rem with one and 56rem with both. Measurements use the parent
|
|
88
|
+
layout's content-box width after outer padding, not the viewport, so embedded
|
|
89
|
+
layouts behave the same way. With default 16px root text and gutter values,
|
|
90
|
+
sidebars appear at outer widths of 792px (one) and 1088px (both).
|
|
91
|
+
Use nonnegative length values; percentage widths are not supported for these
|
|
92
|
+
grid sizing tokens. Sidebar detection uses CSS `:has()` with direct children.
|
|
93
|
+
Hidden sidebar content is also unavailable to assistive technology: provide
|
|
94
|
+
essential navigation or actions elsewhere on small screens.
|
|
95
|
+
|
|
96
|
+
For a static Sass build, configure the matching `$usx-layout-*` variables before
|
|
97
|
+
loading component styles. Existing `$max-layout-width` and `$max-sidebar-width`
|
|
98
|
+
remain the static defaults when the new width settings are unset. Runtime gutter
|
|
99
|
+
hooks take precedence in the themed build. `$usx-layout-breakpoint` defaults to
|
|
100
|
+
`$breakpoint-desktop` (1024px) and accepts a CSS length such as `880px`.
|
|
101
|
+
It controls the outer gutters, not sidebar visibility. Configure it at
|
|
102
|
+
compile time, since CSS custom properties cannot set media-query thresholds.
|
|
103
|
+
|
|
104
|
+
CSS container queries show the expand/contract button only when the two widths
|
|
105
|
+
differ by more than one pixel, accounting for visible sidebar tracks. React
|
|
106
|
+
only manages the expanded state; there are no JavaScript size measurements.
|
|
107
|
+
The expanded state is preserved when resizing temporarily removes the difference.
|
|
108
|
+
Django and static HTML use the same sizing and visibility rules.
|
|
109
|
+
|
|
110
|
+
The `layout.sizing()` mixin accepts `$gutter-mobile` and `$gutter` lengths
|
|
111
|
+
(defaults: 12px and 32px). It uses these for static padding and subtracts them
|
|
112
|
+
from the expansion thresholds at the corresponding viewport breakpoint.
|
|
113
|
+
For custom gutters, pass the same lengths used by your runtime gutter tokens
|
|
114
|
+
or static Sass overrides. CSS size queries cannot read custom properties, so
|
|
115
|
+
changing runtime gutters alone does not update the compiled button threshold.
|
|
116
|
+
The compact comparison uses `$gutter-mobile: 1rem` and `$gutter: 2.5rem`.
|
|
117
|
+
|
|
118
|
+
The custom grid does not require `grid-row`, `grid-col`, or `grid-gap`. USWDS's
|
|
119
|
+
site-margin settings still control its own containers; align those settings
|
|
120
|
+
with the USX gutter values when mixing both container types. Do not add a
|
|
121
|
+
second padded `grid-container` around Layout unless nested gutters are intended.
|
|
122
|
+
|
|
123
|
+
Layout stories use fullscreen previews. `ResponsiveComparison` and
|
|
124
|
+
`ThemedComparison` cover no, left, right, and both sidebars. When checking
|
|
125
|
+
expansion, expand at desktop width and resize without reloading the story.
|
|
126
|
+
|
|
127
|
+
### Component Tokens
|
|
128
|
+
|
|
36
129
|
Component `.scss` files consume design token variables published by
|
|
37
130
|
`@solexllc/usx-theme` (for example `$usx-color-primary`, `$usx-spacing-md`,
|
|
38
131
|
`$usx-radius-md`). These compile to `var(--usx-*, <default>)` by default, so
|
package/dist/index.cjs
CHANGED
|
@@ -1349,14 +1349,14 @@
|
|
|
1349
1349
|
document.body.removeChild(ta);
|
|
1350
1350
|
}
|
|
1351
1351
|
}
|
|
1352
|
-
function Code({ lines = [], copyText = null, className = "" }) {
|
|
1352
|
+
function Code({ lines = [], allowHtml = false, copyText = null, className = "" }) {
|
|
1353
1353
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames("usx-mockup-code", className), children: [
|
|
1354
1354
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-mockup-code__content", children: lines.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1355
1355
|
"pre",
|
|
1356
1356
|
{
|
|
1357
1357
|
...line.prefix != null ? { "data-prefix": line.prefix } : {},
|
|
1358
1358
|
className: line.className || void 0,
|
|
1359
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("code", { dangerouslySetInnerHTML: { __html: line.code } })
|
|
1359
|
+
children: allowHtml ? /* @__PURE__ */ jsxRuntime.jsx("code", { dangerouslySetInnerHTML: { __html: line.code } }) : /* @__PURE__ */ jsxRuntime.jsx("code", { children: line.code })
|
|
1360
1360
|
},
|
|
1361
1361
|
i
|
|
1362
1362
|
)) }),
|
|
@@ -2712,6 +2712,9 @@
|
|
|
2712
2712
|
{
|
|
2713
2713
|
variant: "primary",
|
|
2714
2714
|
ghost: true,
|
|
2715
|
+
type: "button",
|
|
2716
|
+
"aria-label": expanded ? "Contract" : "Expand",
|
|
2717
|
+
"aria-expanded": expanded,
|
|
2715
2718
|
className: "usx-layout__expand-button",
|
|
2716
2719
|
onClick: () => setExpanded((value) => !value),
|
|
2717
2720
|
children: [
|
package/dist/index.js
CHANGED
|
@@ -1347,14 +1347,14 @@ function usxCopy(text) {
|
|
|
1347
1347
|
document.body.removeChild(ta);
|
|
1348
1348
|
}
|
|
1349
1349
|
}
|
|
1350
|
-
function Code({ lines = [], copyText = null, className = "" }) {
|
|
1350
|
+
function Code({ lines = [], allowHtml = false, copyText = null, className = "" }) {
|
|
1351
1351
|
return /* @__PURE__ */ jsxs("div", { className: classNames("usx-mockup-code", className), children: [
|
|
1352
1352
|
/* @__PURE__ */ jsx("div", { className: "usx-mockup-code__content", children: lines.map((line, i) => /* @__PURE__ */ jsx(
|
|
1353
1353
|
"pre",
|
|
1354
1354
|
{
|
|
1355
1355
|
...line.prefix != null ? { "data-prefix": line.prefix } : {},
|
|
1356
1356
|
className: line.className || void 0,
|
|
1357
|
-
children: /* @__PURE__ */ jsx("code", { dangerouslySetInnerHTML: { __html: line.code } })
|
|
1357
|
+
children: allowHtml ? /* @__PURE__ */ jsx("code", { dangerouslySetInnerHTML: { __html: line.code } }) : /* @__PURE__ */ jsx("code", { children: line.code })
|
|
1358
1358
|
},
|
|
1359
1359
|
i
|
|
1360
1360
|
)) }),
|
|
@@ -2710,6 +2710,9 @@ function Layout({
|
|
|
2710
2710
|
{
|
|
2711
2711
|
variant: "primary",
|
|
2712
2712
|
ghost: true,
|
|
2713
|
+
type: "button",
|
|
2714
|
+
"aria-label": expanded ? "Contract" : "Expand",
|
|
2715
|
+
"aria-expanded": expanded,
|
|
2713
2716
|
className: "usx-layout__expand-button",
|
|
2714
2717
|
onClick: () => setExpanded((value) => !value),
|
|
2715
2718
|
children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solexllc/usx-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React component library for USX.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@solexllc/usx": "0.
|
|
29
|
-
"@solexllc/usx-theme": "0.
|
|
30
|
-
"@solexllc/usx-uswds-fixes": "0.1.
|
|
28
|
+
"@solexllc/usx": "0.3.0",
|
|
29
|
+
"@solexllc/usx-theme": "0.4.0",
|
|
30
|
+
"@solexllc/usx-uswds-fixes": "0.1.8",
|
|
31
31
|
"classnames": "^2.5.1",
|
|
32
32
|
"prop-types": "^15.8.1"
|
|
33
33
|
},
|
|
@@ -24,11 +24,12 @@ export interface CodeLine {
|
|
|
24
24
|
|
|
25
25
|
export interface CodeProps {
|
|
26
26
|
lines?: CodeLine[];
|
|
27
|
+
allowHtml?: boolean;
|
|
27
28
|
copyText?: string | null;
|
|
28
29
|
className?: string;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export default function Code({ lines = [], copyText = null, className = '' }: CodeProps) {
|
|
32
|
+
export default function Code({ lines = [], allowHtml = false, copyText = null, className = '' }: CodeProps) {
|
|
32
33
|
return (
|
|
33
34
|
<div className={ClassNames('usx-mockup-code', className)}>
|
|
34
35
|
<div className="usx-mockup-code__content">
|
|
@@ -38,7 +39,7 @@ export default function Code({ lines = [], copyText = null, className = '' }: Co
|
|
|
38
39
|
{...(line.prefix != null ? { 'data-prefix': line.prefix } : {})}
|
|
39
40
|
className={line.className || undefined}
|
|
40
41
|
>
|
|
41
|
-
<code dangerouslySetInnerHTML={{ __html: line.code }} />
|
|
42
|
+
{allowHtml ? <code dangerouslySetInnerHTML={{ __html: line.code }} /> : <code>{line.code}</code>}
|
|
42
43
|
</pre>
|
|
43
44
|
))}
|
|
44
45
|
</div>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{% for line in lines %}
|
|
5
5
|
<pre
|
|
6
6
|
{% if line.prefix %} data-prefix="{{ line.prefix }}"{% endif %}{% if line.className %} class="{{ line.className }}"{% endif %}
|
|
7
|
-
><code>{{ line.code|safe }}</code></pre>
|
|
7
|
+
><code>{% if allowHtml %}{{ line.code|safe }}{% else %}{{ line.code|force_escape }}{% endif %}</code></pre>
|
|
8
8
|
{% endfor %}
|
|
9
9
|
</div>
|
|
10
10
|
{% if copyText %}
|
|
@@ -32,6 +32,49 @@
|
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
34
34
|
|
|
35
|
+
<h3 class="site-preview-heading">HTML Markup as Literal Text</h3>
|
|
36
|
+
<div class="usx-mockup-code">
|
|
37
|
+
<div class="usx-mockup-code__content">
|
|
38
|
+
<pre data-prefix="1"><code><section aria-label="Account & settings"></code></pre>
|
|
39
|
+
<pre data-prefix="2"><code> <h2>Contact information</h2></code></pre>
|
|
40
|
+
<pre data-prefix="3"><code> <p>Use &lt;Page&gt; to define the page.</p></code></pre>
|
|
41
|
+
<pre data-prefix="4"><code></section></code></pre>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<h3 class="site-preview-heading">React Markup as Literal Text</h3>
|
|
46
|
+
<div class="usx-mockup-code">
|
|
47
|
+
<div class="usx-mockup-code__content">
|
|
48
|
+
<pre data-prefix="1"><code><Layout></code></pre>
|
|
49
|
+
<pre data-prefix="2"><code> <Page title="Account" tabIndex={-1}></code></pre>
|
|
50
|
+
<pre data-prefix="3"><code> <Section title="Contact information"></code></pre>
|
|
51
|
+
<pre data-prefix="4"><code> <ContactDetails user={currentUser} /></code></pre>
|
|
52
|
+
<pre data-prefix="5"><code> </Section></code></pre>
|
|
53
|
+
<pre data-prefix="6"><code> </Page></code></pre>
|
|
54
|
+
<pre data-prefix="7"><code></Layout></code></pre>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<h3 class="site-preview-heading">React Markup with an HTML Fragment</h3>
|
|
59
|
+
<div class="usx-mockup-code">
|
|
60
|
+
<div class="usx-mockup-code__content">
|
|
61
|
+
<pre data-prefix="1"><code><Layout></code></pre>
|
|
62
|
+
<pre data-prefix="2"><code> <Page title="<strong>Account</strong>" tabIndex={-1}></code></pre>
|
|
63
|
+
<pre data-prefix="3"><code> <Section title="Contact information"></code></pre>
|
|
64
|
+
<pre data-prefix="4"><code> <ContactDetails user={currentUser} /></code></pre>
|
|
65
|
+
<pre data-prefix="5"><code> </Section></code></pre>
|
|
66
|
+
<pre data-prefix="6"><code> </Page></code></pre>
|
|
67
|
+
<pre data-prefix="7"><code></Layout></code></pre>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<h3 class="site-preview-heading">Rendered HTML Fragment</h3>
|
|
72
|
+
<div class="usx-mockup-code">
|
|
73
|
+
<div class="usx-mockup-code__content">
|
|
74
|
+
<pre data-prefix=">"><code>This <em>line</em> has <strong>HTML fragments</strong></code></pre>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
35
78
|
<h3 class="site-preview-heading">Without Prefix</h3>
|
|
36
79
|
<div class="usx-mockup-code">
|
|
37
80
|
<div class="usx-mockup-code__content">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"properties": {
|
|
16
16
|
"code": {
|
|
17
17
|
"type": "string",
|
|
18
|
-
"description": "
|
|
18
|
+
"description": "Literal line content, including HTML or JSX source. Interpreted as trusted HTML only when allowHtml is true."
|
|
19
19
|
},
|
|
20
20
|
"prefix": {
|
|
21
21
|
"type": "string",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
+
"allowHtml": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"default": false,
|
|
34
|
+
"description": "Render line content as HTML instead of literal text. Only enable for trusted HTML; content is not sanitized. Leave false when documenting HTML or React markup."
|
|
35
|
+
},
|
|
31
36
|
"copyText": {
|
|
32
37
|
"type": "string",
|
|
33
38
|
"description": "Text to copy when the copy button is clicked. If provided, shows the copy button."
|
|
@@ -154,10 +154,10 @@
|
|
|
154
154
|
{% if branding %}
|
|
155
155
|
<div class="usa-logo usx-logo usa-footer__logo grid-row grid-gap-2 usx-footer__logo">
|
|
156
156
|
{% if branding.logo %}
|
|
157
|
-
{% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-logo__image">{% endif %}
|
|
158
|
-
|
|
159
|
-
{% if branding.logoInverse %}
|
|
160
|
-
{% if brandingUrl %}</a>{% endif %}
|
|
157
|
+
{% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-image usx-logo__image">{% else %}<div class="usx-image usx-logo__image">{% endif %}
|
|
158
|
+
{% image src=branding.logo alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant' %}{% endimage %}
|
|
159
|
+
{% if branding.logoInverse %}{% image src=branding.logoInverse alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant usx-logo__variant--inverse' %}{% endimage %}{% endif %}
|
|
160
|
+
{% if brandingUrl %}</a>{% else %}</div>{% endif %}
|
|
161
161
|
{% else %}
|
|
162
162
|
<em class="usa-logo__text">
|
|
163
163
|
{% if branding.symbol %}
|
|
@@ -181,10 +181,10 @@
|
|
|
181
181
|
{% if branding %}
|
|
182
182
|
<div class="usa-logo usx-logo usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2 usx-footer__logo">
|
|
183
183
|
{% if branding.logo %}
|
|
184
|
-
{% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-logo__image">{% endif %}
|
|
185
|
-
|
|
186
|
-
{% if branding.logoInverse %}
|
|
187
|
-
{% if brandingUrl %}</a>{% endif %}
|
|
184
|
+
{% if brandingUrl %}<a href="{{ brandingUrl }}" class="usx-image usx-logo__image">{% else %}<div class="usx-image usx-logo__image">{% endif %}
|
|
185
|
+
{% image src=branding.logo alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant' %}{% endimage %}
|
|
186
|
+
{% if branding.logoInverse %}{% image src=branding.logoInverse alt=branding.alt|default:branding.title|default:'' className='usx-logo__variant usx-logo__variant--inverse' %}{% endimage %}{% endif %}
|
|
187
|
+
{% if brandingUrl %}</a>{% else %}</div>{% endif %}
|
|
188
188
|
{% else %}
|
|
189
189
|
<em class="usa-logo__text">
|
|
190
190
|
{% if branding.symbol %}
|
|
@@ -127,14 +127,22 @@
|
|
|
127
127
|
<div class="grid-container">
|
|
128
128
|
<div class="grid-row grid-gap">
|
|
129
129
|
<div
|
|
130
|
-
class="usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
|
|
130
|
+
class="usa-logo usx-logo usa-footer__logo usx-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
|
|
131
131
|
>
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
<a href="/" class="usx-image usx-logo__image">
|
|
133
|
+
<div class="usx-image usx-logo__variant">
|
|
134
|
+
<picture>
|
|
135
|
+
<source media="(min-width: 40em)" srcset="linear-w-symbol_left.svg" />
|
|
136
|
+
<img src="symbol-only.svg" alt="Agency Name" />
|
|
137
|
+
</picture>
|
|
138
|
+
</div>
|
|
139
|
+
<div class="usx-image usx-logo__variant usx-logo__variant--inverse">
|
|
140
|
+
<picture>
|
|
141
|
+
<source media="(min-width: 40em)" srcset="white_linear-w-symbol_left.png" />
|
|
142
|
+
<img src="white_symbol-only.png" alt="Agency Name" />
|
|
143
|
+
</picture>
|
|
144
|
+
</div>
|
|
145
|
+
</a>
|
|
138
146
|
</div>
|
|
139
147
|
<div class="usa-footer__contact-links mobile-lg:grid-col-6">
|
|
140
148
|
<div class="usa-footer__social-links grid-row grid-gap-1">
|
|
@@ -242,14 +250,22 @@
|
|
|
242
250
|
<div class="grid-container">
|
|
243
251
|
<div class="grid-row grid-gap">
|
|
244
252
|
<div
|
|
245
|
-
class="usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
|
|
253
|
+
class="usa-logo usx-logo usa-footer__logo usx-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2"
|
|
246
254
|
>
|
|
247
|
-
<
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
255
|
+
<a href="/" class="usx-image usx-logo__image">
|
|
256
|
+
<div class="usx-image usx-logo__variant">
|
|
257
|
+
<picture>
|
|
258
|
+
<source media="(min-width: 40em)" srcset="linear-w-symbol_left.svg" />
|
|
259
|
+
<img src="symbol-only.svg" alt="Agency Name" />
|
|
260
|
+
</picture>
|
|
261
|
+
</div>
|
|
262
|
+
<div class="usx-image usx-logo__variant usx-logo__variant--inverse">
|
|
263
|
+
<picture>
|
|
264
|
+
<source media="(min-width: 40em)" srcset="white_linear-w-symbol_left.png" />
|
|
265
|
+
<img src="white_symbol-only.png" alt="Agency Name" />
|
|
266
|
+
</picture>
|
|
267
|
+
</div>
|
|
268
|
+
</a>
|
|
253
269
|
</div>
|
|
254
270
|
<div class="usa-footer__contact-links mobile-lg:grid-col-6">
|
|
255
271
|
<div class="usa-footer__social-links grid-row grid-gap-1">
|
|
@@ -379,13 +395,21 @@
|
|
|
379
395
|
</div>
|
|
380
396
|
<div class="usa-footer__secondary-section">
|
|
381
397
|
<div class="grid-container">
|
|
382
|
-
<div class="usa-footer__logo grid-row grid-gap-2">
|
|
383
|
-
<
|
|
384
|
-
<
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
398
|
+
<div class="usa-logo usx-logo usa-footer__logo usx-footer__logo grid-row grid-gap-2">
|
|
399
|
+
<a href="/" class="usx-image usx-logo__image">
|
|
400
|
+
<div class="usx-image usx-logo__variant">
|
|
401
|
+
<picture>
|
|
402
|
+
<source media="(min-width: 40em)" srcset="linear-w-symbol_left.svg" />
|
|
403
|
+
<img src="symbol-only.svg" alt="Agency Name" />
|
|
404
|
+
</picture>
|
|
405
|
+
</div>
|
|
406
|
+
<div class="usx-image usx-logo__variant usx-logo__variant--inverse">
|
|
407
|
+
<picture>
|
|
408
|
+
<source media="(min-width: 40em)" srcset="white_linear-w-symbol_left.png" />
|
|
409
|
+
<img src="white_symbol-only.png" alt="Agency Name" />
|
|
410
|
+
</picture>
|
|
411
|
+
</div>
|
|
412
|
+
</a>
|
|
389
413
|
</div>
|
|
390
414
|
</div>
|
|
391
415
|
</div>
|
|
@@ -2,7 +2,6 @@ import React, { useState, ReactNode, HTMLAttributes } from 'react';
|
|
|
2
2
|
import ClassNames from 'classnames';
|
|
3
3
|
import Icon from '../icon/Icon';
|
|
4
4
|
import Button from '../button/Button';
|
|
5
|
-
import Tooltip from '../tooltip/Tooltip';
|
|
6
5
|
|
|
7
6
|
// ── Sub-components ──────────────────────────────────────────────────────────
|
|
8
7
|
|
|
@@ -117,6 +116,7 @@ export default function Layout({
|
|
|
117
116
|
...props
|
|
118
117
|
}: LayoutProps) {
|
|
119
118
|
const [expanded, setExpanded] = useState(false);
|
|
119
|
+
|
|
120
120
|
const classes = ClassNames(
|
|
121
121
|
'usx-layout',
|
|
122
122
|
{ 'usx-expanded': expandable && expanded },
|
|
@@ -124,17 +124,18 @@ export default function Layout({
|
|
|
124
124
|
);
|
|
125
125
|
|
|
126
126
|
const expandButton = expandable ? (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
<Button
|
|
128
|
+
variant="primary"
|
|
129
|
+
ghost={true}
|
|
130
|
+
type="button"
|
|
131
|
+
aria-label={expanded ? 'Contract' : 'Expand'}
|
|
132
|
+
aria-expanded={expanded}
|
|
133
|
+
className="usx-layout__expand-button"
|
|
134
|
+
onClick={() => setExpanded((value) => !value)}
|
|
135
|
+
>
|
|
134
136
|
<Icon source="usx" name="expand" size={3} className="usx-layout__expand-icon usx-layout__expand-icon--expand" />
|
|
135
137
|
<Icon source="usx" name="contract" size={3} className="usx-layout__expand-icon usx-layout__expand-icon--contract" />
|
|
136
138
|
</Button>
|
|
137
|
-
|
|
138
139
|
) : null;
|
|
139
140
|
|
|
140
141
|
return (
|
|
@@ -28,6 +28,16 @@
|
|
|
28
28
|
"type": "string",
|
|
29
29
|
"description": "Right sidebar content (grid variant only)"
|
|
30
30
|
},
|
|
31
|
+
"expandLeftSidebar": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"default": false,
|
|
34
|
+
"description": "Removes the outer padding from the left sidebar on desktop."
|
|
35
|
+
},
|
|
36
|
+
"expandRightSidebar": {
|
|
37
|
+
"type": "boolean",
|
|
38
|
+
"default": false,
|
|
39
|
+
"description": "Removes the outer padding from the right sidebar on desktop."
|
|
40
|
+
},
|
|
31
41
|
"expandable": {
|
|
32
42
|
"type": "boolean",
|
|
33
43
|
"description": "Adds a toggle button that grows the layout to a wider max-width via the usx-expanded class."
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
{% elif variant == 'grid' %}
|
|
21
21
|
<div class="usx-layout__grid-container">
|
|
22
22
|
{% if leftSidebar %}
|
|
23
|
-
<aside class="usx-layout__sidebar--left">
|
|
23
|
+
<aside class="usx-layout__sidebar--left{% if expandLeftSidebar %} usx-layout__sidebar--expanded{% endif %}">
|
|
24
24
|
{{ leftSidebar|safe }}
|
|
25
25
|
</aside>
|
|
26
26
|
{% endif %}
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
{% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
|
|
30
30
|
</main>
|
|
31
31
|
{% if rightSidebar %}
|
|
32
|
-
<aside class="usx-layout__sidebar--right">
|
|
32
|
+
<aside class="usx-layout__sidebar--right{% if expandRightSidebar %} usx-layout__sidebar--expanded{% endif %}">
|
|
33
33
|
{{ rightSidebar|safe }}
|
|
34
34
|
</aside>
|
|
35
35
|
{% endif %}
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
<!-- Expandable Layout Example -->
|
|
32
32
|
<div class="usx-layout">
|
|
33
|
-
<
|
|
33
|
+
<div class="usx-layout__single-column">
|
|
34
|
+
<button type="button" class="usx-layout__expand-button" aria-expanded="false" aria-label="Expand" onclick="const expanded = this.closest('.usx-layout').classList.toggle('usx-expanded'); this.setAttribute('aria-expanded', expanded); this.setAttribute('aria-label', expanded ? 'Contract' : 'Expand');">
|
|
34
35
|
<svg class="usa-icon usx-layout__expand-icon usx-layout__expand-icon--expand" aria-hidden="true" focusable="false" role="img">
|
|
35
36
|
<use href="./img/usx-sprite.svg#expand"></use>
|
|
36
37
|
</svg>
|
|
@@ -38,7 +39,6 @@
|
|
|
38
39
|
<use href="./img/usx-sprite.svg#contract"></use>
|
|
39
40
|
</svg>
|
|
40
41
|
</button>
|
|
41
|
-
<div class="usx-layout__single-column">
|
|
42
42
|
<h1>Page Title</h1>
|
|
43
43
|
<p>Use the expand button in the top-right corner to grow the layout to a wider max-width.</p>
|
|
44
44
|
</div>
|