-
Notifications
You must be signed in to change notification settings - Fork 4
Introduce a table pattern
#168
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 "wide" variant option to `Library.Example` to allow for more flexibility in example and demo layout. Remove extra "frame-i-ness" on in demo appearance to reduce visual noise.
cf51e40 to
d79f1f7
Compare
Codecov Report
@@ Coverage Diff @@
## main #168 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 149 149
Branches 51 51
=========================================
Hits 149 149 Continue to review full report at Codecov.
|
esanzgar
left a comment
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.
It looks good and behaves well.
Thanks for the hard work.
| className="hyp-u-layout-row--center hyp-u-border--bottom hyp-u-bg-color--grey-1" | ||
| style="position:sticky;top:0;min-height:44px;" |
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.
I wonder if having a .hyp-u-layout-table-header would help.
It could also include min-height: $touch-target-size.
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.
Good idea! Tell you what. I was thinking of implementing a simple Scrollbox container component in my next body of work. I will look into introducing a pattern that corresponds to "a header of the correct size to put in a scrollbox" along the lines of what you're suggesting here. 👍🏻
| <table className="hyp-table"> | ||
| <thead> | ||
| <tr> | ||
| <th scope="col" style="width:30%"> |
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.
I have never seen scope="col". (
TIL, according to MDN: If the scope attribute is not specified, or its value is not row, col, or rowgroup, or colgroup, then browsers automatically select the set of cells to which the header cell applies.)
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.
Ah! I also just TIL that particular detail. From the styling side, the table-layout: fixed rule in the SASS makes it so that the table and column width is derived from the first row in the table, making it possible to style the th widths and have that reliably apply to the whole table.
| className="hyp-scrollbox--with-header" | ||
| > | ||
| <table className="hyp-table"> | ||
| <thead> |
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.
thead has a min-height of touch $touch-target-size, isn't it?
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.
Technically, a height rule that behaves as a min-height, as min-height doesn't apply for elements with display: table-cell. But, yes, in concept.
d79f1f7 to
83c5d6d
Compare
This PR introduces a
tablepattern, and adjusts thescrollboxpattern to support it. It also (in a separate commit) makes a few adjustment toLibrary.ExampleandLibrary.Democomponent layouts to give more options in how examples and demos are styled, giving more flexibility that was useful for this work.This is part of #157
Following this will be a
Tablecomponent implementation on top of this pattern (this is already in progress). I may also opt to create a simpleScrollboxcontainer component to encapsulate some of thescrollboxpattern bits and bobs.Updates to
scrollboxpattern to supporttableThe recently-introduced
scrollboxpattern is a CSS implementation of an overflow container with scrollability-hinting when that scrollable content is overflowing:This PR contains a commit that adds some flexibility to the
scrollboxpattern such that it can accommodate sticky headers, which are used in our table implementation. This variant (scrollbox--with-header) offsets the top hint-shadow down by one touch-target unit (44px in our implementation):Without this affordance, tables will have bottom scroll-hint shadows, but not top ones, as those would be obscured by the sticky header background.
Aside about this positioning: This does require that our sticky headers used within such scrollboxes are one touch-target (44px) high. Which I grieved over slightly, but feel that the trade-off is reasonably OK. We at least have a common unit—that 44px touch minimum—to apply here. More importantly, heights might grow higher than the set
heightrule (e.g. text wrapping), but shouldn't get shorter. In the case that they grow higher, eh, no big deal, the top shadow will just be obscured (bottom shadow still works).The table pattern
The
tablepattern implementation here is based on the table stying from the LMS project. It has been simplified to remove non-table concerns, adjusted and commented. The contrast felt just a tad high on the headers on LMS, so I've lightened that a touch, while still leaving theis-selectedstyling not at all subtle.Partially-scrolled table inside of a
scrollbox--with-headercontainer:Adjustments to Library Example and Demo layouts
There's a commit on this branch that adds a little layout flexibility to the Examples and Demos such that they don't always need to be 50%-50%, which is limiting in some cases. This allowed me to create a full-width table example in this case. This is just appearance stuff.
Try it out
Pull this branch, run your local webserver (
make dev) and visit the Patterns: Containers page (for thescrollbox--with-headerpattern example) and the Patterns: Tables page