Skip to content

Commit 8cb4125

Browse files
authored
Merge pull request #5809 from uswds/jm-feature-doc-layout-order-setting
USWDS - Documentation page: Improve backwards compatibility with sidenav order
2 parents 7f67cad + ba608d1 commit 8cb4125

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

packages/templates/usa-documentation/includes/_usa-docs-inner.twig

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,31 @@
4040
]
4141
}%}
4242

43+
{% set desktop_sidenav_classes = "display-none desktop:display-block desktop:grid-col-3" %}
44+
45+
{# If true, revert to the old single sidenav behavior. #}
46+
{% if sidenav_reorder %}
47+
{% set desktop_sidenav_classes = "" %}
48+
{% endif %}
49+
4350
<div class="usa-section">
4451
<div class="grid-container">
4552
<div class="grid-row grid-gap">
46-
<div class="usa-layout-docs__sidenav display-none desktop:display-block desktop:grid-col-3">
47-
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
53+
<div class="usa-layout-docs__sidenav {{ desktop_sidenav_classes }}">
54+
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
4855
</div>
4956

5057
<main class="desktop:grid-col-9 usa-prose" id="main-content">
58+
{% if sidenav_reorder %}
59+
<style>
60+
.usa-layout-docs__sidenav {
61+
outline: 1px dashed orange;
62+
}
63+
</style>
64+
65+
Ensure <code>$theme-sidenav-reorder: true</code> in theme settings & in StorybookJS. The sidenav will be placed <em>after</em> main content and a compile warning should display.
66+
{% endif %}
67+
5168
<h1>Page heading (h1)</h1>
5269
<p class="usa-intro">The page heading communicates the main focus of the page. Make your page heading descriptive and keep it succinct.</p>
5370
<h2 id="section-heading-h2">Section heading (h2)</h2>
@@ -60,10 +77,12 @@
6077
<p>Read the full documentation on our side navigation on the component page.</p>
6178
</main>
6279
</div>
63-
80+
81+
{# Hide additional sidenav if we're using pre-3.8.0 behavior. #}
82+
{% if not sidenav_reorder %}
6483
<div class="usa-layout-docs__sidenav desktop:display-none">
65-
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
84+
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
6685
</div>
86+
{% endif %}
6787
</div>
6888
</div>
69-

packages/templates/usa-documentation/usa-docs.stories.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@ import Component from "./usa-docs.twig";
33

44
export default {
55
title: "Pages/Documentation Page",
6+
args: DefaultContent,
67
};
78

89
const Template = (args) => Component(args);
910

1011
export const DocumentationPage = Template.bind({});
11-
DocumentationPage.args = DefaultContent;
12+
13+
export const TestDocumentationReorder = Template.bind({});
14+
TestDocumentationReorder.argTypes = {
15+
sidenav_reorder: {
16+
control: { type: "boolean" },
17+
defaultValue: false,
18+
name: "Reorder with CSS",
19+
},
20+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
@use "uswds-core" as *;
22

3+
$sidenav-reorder-warning: "$theme-sidenav-reorder is enabled and has accessibility concerns. This behavior has a negative impact on users of assistive technologies.";
4+
35
.usa-layout-docs__sidenav {
46
padding-top: units(4);
57

68
@include at-media("desktop") {
79
padding-top: 0;
810
}
11+
12+
// Revert to >3.8.0 behavior and give a warning.
13+
@if $theme-sidenav-reorder {
14+
@warn $sidenav-reorder-warning;
15+
16+
&:first-of-type {
17+
@include grid-col(12);
18+
order: 2;
19+
20+
@include at-media("desktop") {
21+
@include grid-col(3);
22+
order: 0;
23+
}
24+
}
25+
}
926
}

packages/uswds-core/src/styles/settings/_settings-components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ $theme-search-min-width: 27ch !default;
172172
// Sidenav
173173
$theme-sidenav-current-border-width: 0.5 !default;
174174
$theme-sidenav-font-family: "ui" !default;
175+
$theme-sidenav-reorder: false !default;
175176

176177
// Site Alert
177178
$theme-site-alert-max-width: "desktop" !default;

0 commit comments

Comments
 (0)