USWDS - Table: Add sticky headers#5420
Conversation
Add sample styles to show what would be required for border-collapse: separate
…ky-table-header
- Done to improve consistency in control presentation
amyleadem
left a comment
There was a problem hiding this comment.
@mejiaj I believe I have addressed all your comments related to USWDS code. I am going to look into the guidance in USWDS-Site - Changelog: add entry and doc updates for sticky table headers to make sure it addresses this comment. Let me know if you need anything else.
| {% if stickyHeader %} | ||
| {% set bodyLoopCount = 0..6 %} | ||
| {% else %} | ||
| {% set bodyLoopCount = 0..0 %} | ||
| {% endif %} |
mejiaj
left a comment
There was a problem hiding this comment.
Thanks @amyleadem, two more minor comments. One for improving clarity in settings and another for making the template class easier to update.
packages/usa-table/src/usa-table--sortable/usa-table--sortable.twig
Outdated
Show resolved
Hide resolved
| $theme-table-sorted-background-color: "accent-cool-lighter" !default; | ||
| $theme-table-sorted-stripe-background-color: "blue-cool-10v" !default; | ||
| $theme-table-sorted-icon-color: default !default; | ||
| $theme-table-sticky-top-offset: -1px !default; |
There was a problem hiding this comment.
Small concern here is this is similar to the current hero setting where it's not very flexible or re-usable.
Not a blocker for this work.
There was a problem hiding this comment.
Yeah, the setting is fairly limited, but I am not sure if there is a way around it. I would imagine a lot of projects will need to write some custom style rules for the top offset.
There was a problem hiding this comment.
@amyleadem does this setting accept units too or only pixels? Do we have any guidance for this?
|
@mejiaj I believe I've addressed your concerns. Let me know if you have any questions. |
Summary
New table variant. Created the
.usa-table--sticky-headervariant to allow sticky positioning on table headers.Caution
Sticky headers are not compatible with the scrollable and stacked table variants.
Thanks to @etanb for originating this work in PR #5074.
Breaking change
This is not a breaking change.
Related issue
Closes #5077
Related pull requests
Changelog and documentation PR
Preview link
Problem statement
For very long tables, it can be difficult to remember the associated header content. Creating the option to have table headers stick to the top of the page as the user scrolls would help keep tabular data in context.
Solution
This change creates a
.usa-table--sticky-headervariant that gives the table header sticky positioning.New variant
.usa-table--sticky-headerNew settings
$theme-table-background-colordefaultuses the body background color.$theme-table-sticky-top-offsetTesting and review
To test in Storybook: