Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions packages/templates/usa-documentation/includes/_usa-docs-inner.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,31 @@
]
}%}

{% set desktop_sidenav_classes = "display-none desktop:display-block desktop:grid-col-3" %}

{# If true, revert to the old single sidenav behavior. #}
{% if sidenav_reorder %}
{% set desktop_sidenav_classes = "" %}
{% endif %}

<div class="usa-section">
<div class="grid-container">
<div class="grid-row grid-gap">
<div class="usa-layout-docs__sidenav display-none desktop:display-block desktop:grid-col-3">
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
<div class="usa-layout-docs__sidenav {{ desktop_sidenav_classes }}">
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
</div>

<main class="desktop:grid-col-9 usa-prose" id="main-content">
{% if sidenav_reorder %}
<style>
.usa-layout-docs__sidenav {
outline: 1px dashed orange;
}
</style>

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.
{% endif %}

Comment on lines +58 to +67
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't display in final HTML build because it's controlled by the StorybookJS control in usa-docs.stories.js.

TestDocumentationReorder.argTypes = {
sidenav_reorder: {
control: { type: "boolean" },
defaultValue: false,
name: "Reorder with CSS",
},
};

<h1>Page heading (h1)</h1>
<p class="usa-intro">The page heading communicates the main focus of the page. Make your page heading descriptive and keep it succinct.</p>
<h2 id="section-heading-h2">Section heading (h2)</h2>
Expand All @@ -60,10 +77,12 @@
<p>Read the full documentation on our side navigation on the component page.</p>
</main>
</div>


{# Hide additional sidenav if we're using pre-3.8.0 behavior. #}
{% if not sidenav_reorder %}
<div class="usa-layout-docs__sidenav desktop:display-none">
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
{% include "@components/usa-sidenav/src/usa-sidenav.twig" with sidenav_settings %}
</div>
{% endif %}
</div>
</div>

11 changes: 10 additions & 1 deletion packages/templates/usa-documentation/usa-docs.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ import Component from "./usa-docs.twig";

export default {
title: "Pages/Documentation Page",
args: DefaultContent,
};

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

export const DocumentationPage = Template.bind({});
DocumentationPage.args = DefaultContent;

export const TestDocumentationReorder = Template.bind({});
TestDocumentationReorder.argTypes = {
sidenav_reorder: {
control: { type: "boolean" },
defaultValue: false,
name: "Reorder with CSS",
},
};
17 changes: 17 additions & 0 deletions packages/usa-layout-docs/src/styles/_usa-layout-docs.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
@use "uswds-core" as *;

$sidenav-reorder-warning: "$theme-sidenav-reorder is enabled and has accessibility concerns. This behavior has a negative impact on users of assistive technologies.";

.usa-layout-docs__sidenav {
padding-top: units(4);

@include at-media("desktop") {
padding-top: 0;
}

// Revert to >3.8.0 behavior and give a warning.
@if $theme-sidenav-reorder {
@warn $sidenav-reorder-warning;

&:first-of-type {
@include grid-col(12);
order: 2;

@include at-media("desktop") {
@include grid-col(3);
order: 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ $theme-search-min-width: 27ch !default;
// Sidenav
$theme-sidenav-current-border-width: 0.5 !default;
$theme-sidenav-font-family: "ui" !default;
$theme-sidenav-reorder: false !default;

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