Skip to content
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

feat(rh-table): add rh-table #1197

Merged
merged 85 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
de6d75a
feat: rh-table init; add base lightdom styling
eyevana Apr 28, 2023
bb098b7
feat: add desktop hover effect
eyevana May 1, 2023
7ee21f0
refactor: use pointer events to add mobile styling
eyevana May 1, 2023
10bdf50
chore: commit WIP
eyevana Aug 12, 2023
4fd97b0
style: active focus disabled
eyevana Aug 12, 2023
a85c3f8
feat: add full screen button
eyevana Sep 1, 2023
8c90d44
style: add focus outline
eyevana Sep 1, 2023
c96e235
feat: an full screen dialog
eyevana Sep 1, 2023
d1091a4
style: add max height
eyevana Sep 1, 2023
9dc739f
feat: move slotted content in and out of dialog
eyevana Sep 6, 2023
f4d14f4
feat: sorting WIP
eyevana Sep 12, 2023
2475e09
feat: refine sorting
eyevana Sep 13, 2023
6c6663b
feat: add disclaimer
eyevana Sep 14, 2023
b050036
fix: add missing import
eyevana Sep 14, 2023
28db7c0
feat: add caption title
eyevana Sep 14, 2023
c752ac2
style: table overflow
eyevana Sep 16, 2023
9e38227
feat: add overflow example
eyevana Sep 16, 2023
02d4ac5
chore: clean up
eyevana Sep 16, 2023
1c06479
feat: incorporate Steven's suggestions
eyevana Sep 16, 2023
26e6898
feat: create sort button element
eyevana Sep 18, 2023
e266bbd
fix: set aria-sort on header
eyevana Sep 18, 2023
04b3423
Merge branch 'main' into feat/rh-table
eyevana Sep 18, 2023
804dfe9
chore: clean up
eyevana Sep 19, 2023
3a55929
feat: add aria-label to sort button
eyevana Sep 20, 2023
5604e6d
style: adjust margin under caption
eyevana Sep 20, 2023
4604237
refactor: slot name change
eyevana Sep 20, 2023
832f41b
feat: link table with summary
eyevana Sep 20, 2023
2896469
docs: create table kitchen sink demo
eyevana Sep 20, 2023
d63418a
test: add initial instatiation and a11y coverage
eyevana Sep 20, 2023
917d228
fix: tweak mobile styles
eyevana Sep 26, 2023
b293608
chore: clean up demo
eyevana Sep 26, 2023
c8f1931
refactor: create provate token names
eyevana Sep 26, 2023
078874f
refactor: tweaks to match wires
eyevana Sep 26, 2023
4fcd9ea
refactor: use tokens
eyevana Sep 26, 2023
8cc7a44
tests: add sorting coverage
eyevana Oct 2, 2023
a3a5ed3
Merge branch 'main' into feat/rh-table
eyevana Oct 3, 2023
4689127
test: no sort on default prevented
eyevana Oct 3, 2023
e5b5e49
docs: stub basic docs
eyevana Oct 3, 2023
b57b984
fix: lint error
eyevana Oct 3, 2023
5cf1aba
fix: min-width on mobile
eyevana Oct 3, 2023
3339dca
style: sort icons should match text
eyevana Oct 3, 2023
3de0d83
fix: no longer using :has
eyevana Oct 3, 2023
00ee18e
fix: check for summary before adding aria-describedby
eyevana Oct 4, 2023
182afc3
docs: fix typo
eyevana Oct 4, 2023
46467dc
docs: add new CSS part JSDoc
eyevana Oct 4, 2023
a3bdcf1
refactor: use composed event
eyevana Oct 4, 2023
de368b7
refactor: remove uneccessary export
eyevana Oct 4, 2023
dfb4488
docs: add changeset
eyevana Oct 5, 2023
efe6cb3
docs: add overview
eyevana Oct 6, 2023
e14ff4f
docs: add style docs
eyevana Oct 6, 2023
b5bd811
docs: add guidelines and a11y
eyevana Oct 7, 2023
2429aca
docs: add code usage docs
eyevana Oct 7, 2023
2bf80ea
docs: add summary and missing images
eyevana Oct 9, 2023
c60b2c0
fix: src name
eyevana Oct 9, 2023
151ba98
docs: clean up code guidance
eyevana Oct 9, 2023
c2453fd
docs: update summary in README
eyevana Oct 9, 2023
6e20f27
Merge branch 'main' into feat/rh-table
eyevana Oct 9, 2023
13cb2fc
refactor: remove slash from col elements
eyevana Oct 11, 2023
af09920
refactor: remove slash from col elements
eyevana Oct 11, 2023
fa39ebb
refactor: update log verbiage
eyevana Oct 11, 2023
bdf1855
fix: typo
eyevana Oct 11, 2023
40b9022
refactor: remove slash from col elements
eyevana Oct 11, 2023
c88a982
refactor: reorder private static fields
eyevana Oct 11, 2023
555cf25
feat: run init tasks on connected and slot change
eyevana Oct 11, 2023
a10066c
docs: update README
eyevana Oct 11, 2023
3f71ec8
docs: break up demo
eyevana Oct 11, 2023
72028b2
docs: clean up and fix width bug
eyevana Oct 11, 2023
198180d
style: add full width to rh-table
eyevana Oct 11, 2023
ce03bed
Merge branch 'main' into feat/rh-table
eyevana Oct 11, 2023
5ec5d25
refactor: remove slash from col elements
eyevana Oct 12, 2023
f464f0d
refactor: toggle classList
eyevana Oct 12, 2023
1b56e96
refactor: remove trailing slash from col element
eyevana Oct 12, 2023
069c4c7
refactor: remove trailing slash from col elements
eyevana Oct 12, 2023
7421de5
refactor: rename variable
eyevana Oct 12, 2023
bbf20aa
fix: prevent default only after previous checks pass
eyevana Oct 12, 2023
c8d7c8e
docs: add JSDoc to rh-sort-button
eyevana Oct 12, 2023
ab00cae
refactor: remove container div
eyevana Oct 12, 2023
aa3928b
fix: mobile styles
eyevana Oct 12, 2023
cb616ba
fix: cell spacing
eyevana Oct 12, 2023
01ab3b4
Merge branch 'main' into feat/rh-table
eyevana Oct 12, 2023
560952a
fix: syntax typos
eyevana Oct 16, 2023
5816767
refactor: rename CSS vars
eyevana Oct 16, 2023
e488ae7
docs: breakout layout examples into separate demos
eyevana Oct 16, 2023
b6deade
Merge branch 'main' into feat/rh-table
eyevana Oct 16, 2023
9dc0dad
Merge branch 'main' into feat/rh-table
brianferry Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .changeset/healthy-emus-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
'@rhds/elements': minor
---

✨ Added `<rh-table>`.

A table is a container for displaying information. It allows a user to scan, examine, and compare large amounts of data.

```html
<rh-table>
<table>
<caption>
Concerts
</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th scope="col" data-label="Date">Date</th>
<th scope="col" data-label="Event">Event<rh-sort-button></rh-sort-button></th>
<th scope="col" data-label="Venue">Venue<rh-sort-button></rh-sort-button></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Date">12 February</td>
<td data-label="Event">Waltz with Strauss</td>
<td data-label="Venue">Main Hall</td>
</tr>
<tr>
<td data-label="Date">24 March</td>
<td data-label="Event">The Obelisks</td>
<td data-label="Venue">West Wing</td>
</tr>
<tr>
<td data-label="Date">14 April</td>
<td data-label="Event">The What</td>
<td data-label="Venue">Main Hall</td>
</tr>
</tbody>
</table>
<small slot="summary">Dates and venues subject to change.</small>
</rh-table>
```
2 changes: 2 additions & 0 deletions docs/_data/relatedItems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ rh-subnav:
- rh-navigation
- rh-navigation-secondary
- skip-navigation
rh-table:
- rh-code-block
rh-tabs:
- rh-jump-links
- rh-pagination
Expand Down
2 changes: 2 additions & 0 deletions docs/elements/elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- /assets/cem.css
- /assets/packages/@rhds/elements/elements/rh-subnav/rh-subnav-lightdom.css
- /assets/packages/@rhds/elements/elements/rh-pagination/rh-pagination-lightdom.css
- /assets/packages/@rhds/elements/elements/rh-table/rh-table-lightdom.css
eleventyComputed:
title: "{{ doc.pageTitle }} | {{ doc.slug | deslugify }}"
importElements:
Expand All @@ -18,6 +19,7 @@
- rh-footer
- rh-subnav
- rh-code-block
- rh-table
- "{{ doc.tagName }}"
---

Expand Down
4 changes: 4 additions & 0 deletions docs/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ body.page-docs rh-cta a[href^="http"]::after {
white-space: nowrap; /* fix orphan issue on the Feedback shortcode's contact us link */
}

:is(rh-table) th {
font-size: unset;
}

rh-playground pre {
max-height: 785px;
}
151 changes: 151 additions & 0 deletions elements/rh-table/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Table

A table is a container for displaying information. It allows a user to scan, examine, and compare large amounts of data.
eyevana marked this conversation as resolved.
Show resolved Hide resolved

## Usage

### Title

Specify the title of the table using a `caption` element.

```html
<rh-table>
<table>
<caption>
Concerts
</caption>
<!-- ...table data -->
</table>
</rh-table>
```

### Column highlighting

To enable column highlighting, the `table` element must also include a `col` element for each column in the table, typically wrapped with a `colgroup`.

```html
<rh-table>
<table>
<caption>
Concerts
</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<!-- ...table with three columns -->
</table>
</rh-table>
```

### Sorting

To enable sorting on a column, add an `rh-sort-button` as the last child of the `th` cell.

```html
<rh-table>
<table>
<caption>
Concerts
</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th scope="col" data-label="Date">Date</th>
<th scope="col" data-label="Event">Event<rh-sort-button></rh-sort-button></th>
<th scope="col" data-label="Venue">Venue<rh-sort-button></rh-sort-button></th>
</tr>
</thead>
<!-- ...table data sortable by Event and Venue -->
</table>
</rh-table>
```

### Summary

Additional information about the data in the table should be slotted into the `summary` slot after the `table` element.

```html
<rh-table>
<table>
<caption>
Concerts
</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th scope="col" data-label="Date">Date</th>
<th scope="col" data-label="Event">Event<rh-sort-button></rh-sort-button></th>
<th scope="col" data-label="Venue">Venue<rh-sort-button></rh-sort-button></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Date">12 February</td>
<td data-label="Event">Waltz with Strauss</td>
<td data-label="Venue">Main Hall</td>
</tr>
<tr>
<td data-label="Date">24 March</td>
<td data-label="Event">The Obelisks</td>
<td data-label="Venue">West Wing</td>
</tr>
<tr>
<td data-label="Date">14 April</td>
<td data-label="Event">The What</td>
<td data-label="Venue">Main Hall</td>
</tr>
</tbody>
</table>
<small slot="summary">Dates and venues subject to change.</small>
</rh-table>
```

## Example

<rh-table>
<table>
<caption>
Concerts
</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th scope="col" data-label="Date">Date</th>
<th scope="col" data-label="Event">Event<rh-sort-button></rh-sort-button></th>
<th scope="col" data-label="Venue">Venue<rh-sort-button></rh-sort-button></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Date">12 February</td>
<td data-label="Event">Waltz with Strauss</td>
<td data-label="Venue">Main Hall</td>
</tr>
<tr>
<td data-label="Date">24 March</td>
<td data-label="Event">The Obelisks</td>
<td data-label="Venue">West Wing</td>
</tr>
<tr>
<td data-label="Date">14 April</td>
<td data-label="Event">The What</td>
<td data-label="Venue">Main Hall</td>
</tr>
</tbody>
</table>
<small slot="summary">Dates and venues subject to change.</small>
</rh-table>
11 changes: 11 additions & 0 deletions elements/rh-table/demo/demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

h2, p {
margin-top: var(--rh-space-5xl, 80px);
text-align: center;
}
131 changes: 131 additions & 0 deletions elements/rh-table/demo/different-layouts.html
eyevana marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<link rel="stylesheet" href="demo.css">
eyevana marked this conversation as resolved.
Show resolved Hide resolved
<link rel="stylesheet" href="../rh-table-lightdom.css">

<p>The following examples taken from: <a href="https://www.w3.org/WAI/tutorials/tables">https://www.w3.org/WAI/tutorials/tables</a>.</p>
<section>
<h2>Row headers</h2>
<rh-table>
<table>
<col>
<col>
<col>
<thead>
<tr>
<th sortable scope="col" data-label="Date">Date</th>
<th sortable scope="col" data-label="Event">Event</th>
<th sortable scope="col" data-label="Venue">Venue</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Date">12 February</td>
<td data-label="Event">
<a href="">Waltz with Strauss</a>
</td>
<td data-label="Venue">Main Hall</td>
</tr>
<tr>
<td data-label="Date">24 March</td>
<td data-label="Event">The Obelisks</td>
<td data-label="Venue">West Wing</td>
</tr>
<tr>
<td data-label="Date">14 April</td>
<td data-label="Event">The What</td>
<td data-label="Venue">Main Hall</td>
</tr>
</tbody>
</table>
</rh-table>
</section>
<section>
<h2>Column headers</h2>
<p>
<strong>Note: </strong>Tables with no <code>thead</code> will not stack on mobile.</p>
<rh-table>
<table>
<tbody>
<tr>
<th scope="row">Date</th>
<td>12 February</td>
<td>24 March</td>
<td>14 April</td>
</tr>
<tr>
<th scope="row">Event</th>
<td>Waltz with Strauss</td>
<td>The Obelisks</td>
<td>The What</td>
</tr>
<tr>
<th scope="row">Venue</th>
<td>Main Hall</td>
<td>West Wing</td>
<td>Main Hall</td>
</tr>
</tbody>
</table>
</rh-table>
</section>
<section>
<h2>Row and column headers</h2>
<rh-table>
<table>
<caption>Delivery slots:</caption>
<col>
<col>
<col>
<col>
<col>
<col>
<thead>
<tr>
<td></td>
<th sortable scope="col" data-label="Monday">Monday</th>
<th sortable scope="col" data-label="Tuesday">Tuesday</th>
<th sortable scope="col" data-label="Wednesday">Wednesday</th>
<th sortable scope="col" data-label="Thursday">Thursday</th>
<th sortable scope="col" data-label="Friday">Friday</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">09:00 – 11:00</th>
<td data-label="Monday">Closed</td>
<td data-label="Tuesday">Open</td>
<td data-label="Wednesday">Open</td>
<td data-label="Thursday">Closed</td>
<td data-label="Friday">Closed</td>
</tr>
<tr>
<th scope="row">11:00 – 13:00</th>
<td data-label="Monday">Open</td>
<td data-label="Tuesday">Open</td>
<td data-label="Wednesday">Closed</td>
<td data-label="Thursday">Closed</td>
<td data-label="Friday">Closed</td>
</tr>
<tr>
<th cope="row">13:00 – 15:00</th>
<td data-label="Monday">Open</td>
<td data-label="Tuesday">Open</td>
<td data-label="Wednesday">Open</td>
<td data-label="Thursday">Closed</td>
<td data-label="Friday">Closed</td>
</tr>
<tr>
<th scope="row">15:00 – 17:00</th>
<td data-label="Monday">Closed</td>
<td data-label="Tuesday">Closed</td>
<td data-label="Wednesday">Closed</td>
<td data-label="Thursday">Open</td>
<td data-label="Friday">Open</td>
</tr>
</tbody>
</table>
</rh-table>
</section>

<script type="module">
import '@rhds/elements/rh-table/rh-table.js';
</script>
Loading
Loading