USWDS - Documentation page: Improve backwards compatibility with sidenav order#5809
Merged
thisisdano merged 6 commits intodevelopfrom Mar 11, 2024
Merged
Conversation
added 4 commits
March 8, 2024 10:50
Allows us to reuse content in all templates and set custom controls on test.
added 2 commits
March 8, 2024 13:34
mahoneycm
approved these changes
Mar 11, 2024
Contributor
mahoneycm
left a comment
There was a problem hiding this comment.
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
TRUEvia StorybookJS control. - New reorder setting in
_settings-components.scss. - New setting is
FALSEby default. - New setting reorders sidenav on
TRUEand 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
mejiaj
commented
Mar 11, 2024
Comment on lines
+58
to
+67
| {% 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 %} | ||
|
|
Contributor
Author
There was a problem hiding this comment.
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
thisisdano
approved these changes
Mar 11, 2024
Contributor
thisisdano
left a comment
There was a problem hiding this comment.
Very nice. Thanks for thinking this through!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduced a fallback for Documentation sidenav changes. A new setting
$theme-sidenav-reorderallows users to reorder the sidenav to avoid visual regressions.Caution
Setting
$theme-sidenav-reorder: truehas 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.0will 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: truein 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
desktopbreakpoint in_usa-layout-docs.scss:20is 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 CSSto test old behavior.Testing checklist
npm run build:html.TRUEvia StorybookJS control._settings-components.scss.FALSEby default.TRUEand provides a warning on compile.Todo