USWDS - Footer: Use :where()
on all grid layout classes defined component styles
#5749
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
Resolves style specificity issues between
usa-footer
andusa-grid-layout
. This resolves visual regressions potentially caused by #5289.Breaking change
This is not a breaking change.
Related issue
Closes #5676
Changelog → pending
Related pull requests
Grid dependency removed in #5289
Preview link
Footer →
Demo repo →
Demo footer →
Warning
By default, the test repo and preview are using
3.7.1
. To see fix in affect, install this branch as USWDSnpm install @uswds/uswds "https://github.com/uswds/uswds/tree/cm-footer-grid-where-hotfix" --save
Problem statement
Layout grid styles defined in footer have higher specificity than other layout-grid styles. As a result, updated layout grid utility classes in footer markup do not affect layout as expected.
Solution
Use
:where()
to negate specificity in nested grid classes.Testing and review
The demo repo below showcases how footer-defined grid styles have specificity over standard grid classes when both are imported to a project and then instructs the user to install this branch to resolve the issue.
3.7.1
footer
andgrid-layout
<li>
style changesnpm install @uswds/uswds "https://github.com/uswds/uswds/tree/cm-footer-grid-where-hotfix" --save
Testing checklist
_usa-footer.scss
$theme-layout-grid-use-important: true
is not required for desired layout-grid styles:where()
is needed on each grid classFurther consideration
I tested some of the options offered by sass:meta to test for the inclusion of the layout grid package. Since the grid classes are always included in our sass package, I was unable to use the functions to check for the existence of layout grid (They always return true).
We should consider if there are other ways to check for the inclusion of the package on the project level.
From @mejiaj in #5675