New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USWDS - Documentation page: Improve backwards compatibility with sidenav order #5809
Conversation
Allows us to reuse content in all templates and set custom controls on test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving this fix! Adds great flexibility to our users.
Testing checklist
- Zero regressions in HTML output -
npm run build:html
. - Documentation page by default has two sidenavs that toggle display based on breakpoint.
- Inspecting markup shows nav elements before
main
- Inspecting markup shows nav elements before
- Documentation page test can revert to old behavior on
TRUE
via StorybookJS control. - New reorder setting in
_settings-components.scss
. - New setting is
FALSE
by default. - New setting reorders sidenav on
TRUE
and provides a warning on compile. - Installing and testing on sandbox works as expected
- Warning on compile
- Sidenav displays correctly using old markup and new setting
{% 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 %} | ||
|
There was a problem hiding this comment.
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
.
uswds/packages/templates/usa-documentation/usa-docs.stories.js
Lines 14 to 20 in ba608d1
TestDocumentationReorder.argTypes = { | |
sidenav_reorder: { | |
control: { type: "boolean" }, | |
defaultValue: false, | |
name: "Reorder with CSS", | |
}, | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. Thanks for thinking this through!
Summary
Introduced a fallback for Documentation sidenav changes. A new setting
$theme-sidenav-reorder
allows users to reorder the sidenav to avoid visual regressions.Caution
Setting
$theme-sidenav-reorder: true
has a negative impact on users of assistive technologies.Breaking change
This is not a breaking change.
Related issue
Closes #5807.
Related pull requests
Changelog entry added to uswds/uswds-site#2495.
Preview link
Preview link: Test Documentation Reorder ⋅ Storybook
Problem statement
Without a fallback, users who update to
3.8.0
will have to update all their templates to follow new guidance. This new setting allows for incremental adoption towards this new recommendation.Solution
This pull request adds a new component theme setting for those who are unable to make that change right now. You can do that by setting
$theme-sidenav-reorder: true
in theme settings.This will give you a warning on compile and suggesting the new recommendation above.
New recommendation from #5794
#5794 introduced a potentially breaking change that requires a markup update. We recommend including a duplicate sidenav and toggling visibility based on breakpoints.
Include a duplicate sidenav and ensure the utility classes are correct. The example below shows a before/after.
Approach
Possible limitations
The
desktop
breakpoint in_usa-layout-docs.scss:20
is fixed and users don't have an easy way of overriding this.uswds/packages/usa-layout-docs/src/styles/_usa-layout-docs.scss
Lines 20 to 23 in 17600ba
Major changes
$theme-sidenav-reorder: false !default
.Testing and review
There's a new test story that allow you to toggle and compare behaviors. Toggle
Reorder with CSS
to test old behavior.Testing checklist
npm run build:html
.TRUE
via StorybookJS control._settings-components.scss
.FALSE
by default.TRUE
and provides a warning on compile.Todo