-
Notifications
You must be signed in to change notification settings - Fork 2
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
Introduce a table
pattern
#168
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import Library from '../Library'; | ||
|
||
// "Fixture" for example table contents | ||
function ExampleTBody() { | ||
return ( | ||
<tbody> | ||
<tr> | ||
<td>Alphanumeric Balloons</td> | ||
<td>Champagne Delusions</td> | ||
</tr> | ||
<tr> | ||
<td>Elephantine Fry-ups</td> | ||
<td>Gargantuan Hiccups</td> | ||
</tr> | ||
<tr className="is-selected"> | ||
<td>Illicit Jugglers</td> | ||
<td>Katydid Lozenges Meringue</td> | ||
</tr> | ||
<tr> | ||
<td>Alphanumeric Balloons</td> | ||
<td>Champagne Delusions</td> | ||
</tr> | ||
<tr> | ||
<td>Elephantine Fry-ups</td> | ||
<td>Gargantuan Hiccups</td> | ||
</tr> | ||
<tr> | ||
<td>Illicit Jugglers</td> | ||
<td>Katydid Lozenges Moebius</td> | ||
</tr> | ||
<tr> | ||
<td>Elephantine Fry-ups</td> | ||
<td>Gargantuan Hiccups</td> | ||
</tr> | ||
<tr> | ||
<td>Illicit Jugglers</td> | ||
<td>Katydid Lozenges Meringue</td> | ||
</tr> | ||
<tr> | ||
<td>Alphanumeric Balloons</td> | ||
<td>Champagne Delusions</td> | ||
</tr> | ||
</tbody> | ||
); | ||
} | ||
|
||
export default function TablePatterns() { | ||
return ( | ||
<Library.Page title="Tables"> | ||
<p> | ||
These <code>table</code> patterns support a basic table layout that | ||
adapts to available space. They are intended for simpler tabular | ||
display: maximum 2 or possibly 3 columns. Remember that{' '} | ||
<code>table</code> content needs to be usable in tight and narrow | ||
spaces. | ||
</p> | ||
<Library.Pattern title="Table"> | ||
<Library.Example title="Basic table" variant="wide"> | ||
<p> | ||
By default, a <code>table</code> will fill available horizontal | ||
space, and will use whatever height is needed to render its rows.{' '} | ||
<code>tr.is-selected</code> styles a row as selected. | ||
</p> | ||
|
||
<Library.Demo withSource> | ||
<table className="hyp-table"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Column A</th> | ||
<th scope="col">Column B</th> | ||
</tr> | ||
</thead> | ||
<ExampleTBody /> | ||
</table> | ||
</Library.Demo> | ||
</Library.Example> | ||
|
||
<Library.Example title="Adjusting column widths"> | ||
<p> | ||
Table column widths may be adjusted by styling <code>thead th</code>{' '} | ||
elements. In this example, the column widths are set to 30% and 70%. | ||
</p> | ||
<Library.Demo withSource> | ||
<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 commentThe reason will be displayed to describe this comment to others. Learn more. I have never seen There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
Column A | ||
</th> | ||
<th scope="col" style="width:70%"> | ||
Column B | ||
</th> | ||
</tr> | ||
</thead> | ||
<ExampleTBody /> | ||
</table> | ||
</Library.Demo> | ||
</Library.Example> | ||
|
||
<Library.Example title="Constraining with a scrollbox"> | ||
<p> | ||
In this example, the <code>table</code> is constrained within a{' '} | ||
<code>scrollbox</code> with a <code>max-height</code>. | ||
</p> | ||
<Library.Demo withSource> | ||
<div | ||
style="max-height:250px" | ||
className="hyp-scrollbox--with-header" | ||
> | ||
<table className="hyp-table"> | ||
<thead> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, a |
||
<tr> | ||
<th scope="col">Column A</th> | ||
<th scope="col">Column B</th> | ||
</tr> | ||
</thead> | ||
<ExampleTBody /> | ||
</table> | ||
</div> | ||
</Library.Demo> | ||
</Library.Example> | ||
</Library.Pattern> | ||
</Library.Page> | ||
); | ||
} |
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. 👍🏻