-
Notifications
You must be signed in to change notification settings - Fork 1k
USWDS - Table: Add sticky headers #5420
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
Conversation
Add sample styles to show what would be required for border-collapse: separate
…ky-table-header
- Done to improve consistency in control presentation

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.
@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 %} |

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.
Updated in 02034a7
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.
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
@@ -213,6 +214,7 @@ $theme-table-sorted-header-background-color: "accent-cool-light" !default; | |||
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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. |
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.
Question on new offset setting. Code looks good, thank you.
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.
NICE
Summary
New table variant. Created the
.usa-table--sticky-header
variant 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-header
variant that gives the table header sticky positioning.New variant
.usa-table--sticky-header
New settings
$theme-table-background-color
default
uses the body background color.$theme-table-sticky-top-offset
Testing and review
To test in Storybook: