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

Table: Allow complex content to be displayed in Pharos tables #840

Merged
merged 7 commits into from
Jan 30, 2025

Conversation

brentswisher
Copy link
Contributor

@brentswisher brentswisher commented Jan 17, 2025

This change: (check at least one)

  • Adds a new feature
  • Fixes a bug
  • Improves maintainability
  • Improves documentation
  • Is a release activity

Is this a breaking change? (check one)

  • Yes
  • No

Is the: (complete all)

  • Title of this pull request clear, concise, and indicative of the issue number it addresses, if any?
  • Test suite(s) passing?
  • Code coverage maximal?
  • Changeset added?
  • Component status page up to date?

What does this change address?
Closes #808

The current pharos table component only allows for plain text content to be included. This updates the table to be able to take any type of content that may need to be displayed.

How does this change work?
The table component was updates to accept content in two formats, by padding in an array as a rowData parameter (like it does now) or by utilizing a slot for the table contents.

To accomplish the slotted version, there are three new components:

PharosTableBody - the equivalent of a
PharosTableRow - the equivalent of a
PharosTableCell - the equivalent of a

These are needed because the HTML spec for a table element does not recognize a <slot></slot> as a valid child elements. If you try to pass one in, the table renders without the slotted content, and instead displays it after the table.

While this somewhat complicates the markup because we cannot use a semantic table, using proper roles for the custom elements renders a table which looks and acts the same as a native one, including for assistive technology users.

Additional context
There has been some conversation among the Pharos maintainers about using a CSS grid based layout instead of display:table-row. That worked for the initial design, but when integrating it into the sticky header, it ran into a problem. To properly display the table like a semantic table required using display:contents. That causes the content of the header to "not produce a specific box by themselves. They are replaced by their pseudo-box and their child boxes" - this then makes it impossible to use an interactionObserver for the sticky header, so I reverted back to not using a CSS grid.

Copy link

changeset-bot bot commented Jan 17, 2025

🦋 Changeset detected

Latest commit: 6e9c553

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ithaka/pharos Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 17, 2025

size-limit report 📦

Path Size
packages/pharos/lib/index.js 67.78 KB (+0.34% 🔺)

@brentswisher brentswisher force-pushed the feature/complex-table-data branch 3 times, most recently from ae1ddc5 to 7dd8cae Compare January 17, 2025 20:08
@brentswisher brentswisher force-pushed the feature/complex-table-data branch 2 times, most recently from 8304989 to 2904267 Compare January 28, 2025 15:50
@brentswisher brentswisher force-pushed the feature/complex-table-data branch from 2904267 to b5526d3 Compare January 28, 2025 16:08
@brentswisher brentswisher changed the title feat(table): allow custom content in table cells - WIP Table: Allow complex content to be displayed in Pharos tables Jan 28, 2025
@brentswisher brentswisher self-assigned this Jan 28, 2025
@brentswisher brentswisher marked this pull request as ready for review January 28, 2025 20:26
@brentswisher brentswisher requested a review from a team as a code owner January 28, 2025 20:26
@brentswisher brentswisher requested review from sirrah-tam, mtorres3, satya-achanta-venkata, daneah and jialin-he and removed request for a team January 28, 2025 20:26
@brentswisher
Copy link
Contributor Author

Waiting on #862 to merge this in

* fix(table): add resizeObserver to set cell height

When using slotted content in a table cell, it currently
is not possible to set the content to be 100% of the cell.
This is because using a slot takes the content our of the normal
flow and it doesn't know what height it should use when
set to 100%. By adding a resizeObserver to see the height of the cell
and set that height manually, the descendant content can set
height:100% and it will work as expected.

While each cell will be set to it's own height, the nature of
table rows means that all cells in a row will display as the
height of the tallest cell, regardless of what height they have
manually set.

* fix(table): account for border when calculating height
@brentswisher brentswisher merged commit 308b8af into develop Jan 30, 2025
11 checks passed
@brentswisher brentswisher deleted the feature/complex-table-data branch January 30, 2025 14:20
@github-actions github-actions bot mentioned this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table: Allow for complex data to be displayed in the table component
3 participants