-
Notifications
You must be signed in to change notification settings - Fork 202
feat(table): s2 table migration layout part-1 #3799
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
base: spectrum-two
Are you sure you want to change the base?
feat(table): s2 table migration layout part-1 #3799
Conversation
🚀 Deployed on https://pr-3799--spectrum-css.netlify.app |
File metricsSummaryTotal size: 1.40 MB*
table
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
25578c0
to
8a6fb2f
Compare
|
- creates a TableCellTemplate - creates a TableRowTemplate - creates several helper functions like createCell, createRow - implements some new arguments, such as isSortable, support for more visual elements, different text alignments in the table cells, and the different sorting icons - adds numerical data handling (text alignment) - adds menu disclosure icon to table header cells
- uses new approach for creating table cells and rows (createRow()) - new args implemented like isSortable, visual elements, isLoading,etc. - new stories for sortable columns, selection modes (previously known as multi-select), empty state, loading - removes any dropzone stories from autodocs since design isn't certain the S2 table will support those. - adds numerical data alignment story - adds hasMenu story (disclosure icon)
- consolidates repetitive code - moves custom properties to top of file - moves high contrast styles to bottom of file
- removes createRow and createCell functions - reimplements ExampleRowItems - adjusts numerical data story to show text alignment - removes sort icon story - adds table row focus/selected states
- removes createRow and createCell functions - removes the TableCell and TableRow components - adds support for text alignment, selection and checkboxes, loading and empty states - reimplements sorting icons with new S2 icons in spec - attempts to re-simplify the template
- continues to reorganize custom properties - adds styles for headCells and icons
- clarifies some code comments - reorganizes code for focus styles - corrects border and border-radii for cells and rows based on new specs - fixes any scroll styling issues
- uses sentence-case for story names - updates to some display names and cell organization
- updates the thumbnail styles to "visual" to reflect the avatar, icon, and thumbnail support - minor changes to code comments for clarity - fixes vertical alignment for sort and disclosure/menu icons
- fixes the indentation for the isCollapsible block - removes columnIndex limit for visual elements - adds tabIndex to cells and rows to support keyboard navigation and design specs - adds -headRow class name for header rows - adds isFocused arg for rows
- reorganizes custom properties for section headers and summary rows into the rest of the custom properties - corrects some styles for section headers - adds some mods for summary rows and section headers - corrects some styling for checkboxes
- adds focus indicators for cells and rows - opts for a pseudo-element for the focus indicator instead of outline - adds cellCustomClasses to support focused cells - adds a TableStates story to show the focus and selected states
dfd9619
to
36920dd
Compare
- addresses some unused or "undefined" custom properties related to thumbnail that are not in use anymore - updates metadata - passes density arg to table row template to appropriately size the visuals
36920dd
to
490a4e9
Compare
Visuals.storyName = "With visuals"; | ||
|
||
|
||
// TODO: The design team doesn't have support for collapsible rows in the table component, so they are removed from the docs page for now. |
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 a couple TODO
notes throughout the stories file here, reflecting on the conversation I had with Stefan.
Design doesn't have collapsible row designs, or dropzone designs done (and they're unsure if they will). React only has beta drag & drop table components.
So I didn't really want to get rid of our stories or tests for those table variants/options. What are our thoughts on just removing these 5 or 6 stories regarding collapsible rows and dropzones from the autodocs?
Sizing.args = {}; | ||
Sizing.tags = ["!dev"]; | ||
Sizing.parameters = { | ||
export const EmptyState = Template.bind({}); |
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'd love some feedback on the empty and loading states. Should I do anything more than return the illustrated message or progress circle component? As in, do I return the header row, AND THEN render the illustrated message/progress circle, with those 2 components like "in" the table? That's not really what Figma looks like, but...open to feedback on these two new stories.
> | ||
${when(showCheckbox && !isSectionHeader, () => html` | ||
<${cellTag} | ||
role="gridcell" | ||
class=${classMap({ | ||
[`${rootClass}-cell`]: true, | ||
[`${rootClass}-checkboxCell`]: true, | ||
[`${rootClass}-cell--alignEnd`]: getTextAlignment(0) === "end", | ||
...cellCustomClasses?.[0]?.reduce((a, c) => ({ ...a, [c]: true }), {}), |
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 wanted to show the individual cell focus states, so I had to pass custom classes to the cells.
})} | ||
tabindex="0" |
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.
The rows should be keyboard focusable, as well as the cells (according to the designs), so I added the tabindex in quite a few places.
Any accessibility concerns with how everything is laid out right now? I don't know the flow for tables. Should each focused row move to the next focusable row, or would a user focus on a row, then move through the cells?
*/ | ||
export const Sizing = (args, context) => Sizes({ |
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.
Doesn't look like we ever really supported sizes actually. The guidance site doesn't refer to table sizes, nor do the current Figma designs for S2 🤷♀️
- fixes up existing tests to use new default props if necessary - adds numerical test, text alignment, visual elements, empty state, loading state, and a test of a smattering of other focus/selected tests for the rows and cells
the indeterminate checkbox for a multi-select table should only show in the header row. Single select tables should not have a checkbox in the header row.
14fcf31
to
4b76b0c
Compare
@@ -204,65 +285,75 @@ export const Template = ({ | |||
id=${ifDefined(id)} | |||
role=${ifDefined(useCheckboxCell ? "grid" : useDivs ? "table" : undefined)} | |||
aria-multiselectable=${ifDefined(useCheckboxCell ? "true" : undefined)} | |||
style="max-width: 800px;" |
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.
Should I keep this? Is it necessary? I'm fine with adding this max-width back on, just let me know!
isChecked: false, | ||
isIndeterminate: true, | ||
customClasses: [`${rootClass}-checkbox`], | ||
${when(selectionMode === "multiple", () => html` |
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.
Checkboxes should only appear in the thead
if users can select more than one row (and this puts the indeterminate checkbox in that header row). Otherwise, checkboxes for single select rows just appear in their rows.
tabindex="0" | ||
> | ||
${Icon({ | ||
iconName: "Sort", |
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 added each of the new sort icons to each header cell.
customClasses: [`${rootClass}-sortIcon`], | ||
}, context)} | ||
<span class="${rootClass}-columnTitle">Column title</span> | ||
${Icon({ |
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.
The second column now has the additional "menu" or disclosure icon. It's non functional but...should this be a button? Like an action button to trigger a menu?
The rest of the collapsible disclosure icons are all buttons so...that's what trigger the question for me.
description: | ||
"Uses the thumbnail component at the start of the first column's cells.", | ||
type: { name: "boolean" }, | ||
selectionMode: { |
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 got "selection mode" from the menu component, as well as React.
|
||
export const LoadingState = Template.bind({}); |
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.
What else can I say here? 😆 Any thoughts?
"The table may render a progress circle while populating data."
@@ -12,511 +12,348 @@ | |||
*/ | |||
|
|||
.spectrum-Table { |
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.
A lot of the CSS has just been reorganized to more or less match what we are doing in other components. There was a lot of consolidating of the custom properties up at the top that needed to happen.
.spectrum-Table-body { | ||
position: relative; | ||
border: none; | ||
border-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); | ||
border-end-start-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); | ||
border-end-end-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); | ||
display: table-row-group; | ||
|
||
&.is-drop-target { |
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.
&::after { | ||
content: ""; | ||
position: absolute; | ||
inset: calc(-1 * var(--mod-table-border-width, var(--spectrum-table-border-width))); | ||
border-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); | ||
border: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)) solid var(--highcontrast-table-cell-focus-indicator-color, var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)))); | ||
pointer-events: none; | ||
} |
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.
The cells have a different focus indicator border radius, than they do when non-focused. I'd love some feedback on this ::after
approach to achieve that.
--highcontrast-table-icon-color: var(--highcontrast-table-row-text-color-hover); | ||
--spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color-hover, var(--mod-table-row-active-color, var(--spectrum-table-row-active-color))); | ||
} | ||
/* First cell of focused rows need fancy new focus indicator borders & no border-radius, and the thicker row focus indicator */ |
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.
This was pretty complex, so again- feedback is welcome!
The table row itself can be focused.
It's got a 4px blue side focus indicator, as well as (basically) a border that goes around the entire row.
Some rows don't have border radii, and some do. But- those border radii are created with the individual table cells in that row.
🥵🥵🥵
padding-block-start: calc(var(--mod-table-row-top-to-text, var(--spectrum-table-row-top-to-text)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); | ||
padding-block-end: var(--mod-table-row-bottom-to-text, var(--spectrum-table-row-bottom-to-text)); | ||
} | ||
align-items: center; |
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.
Calling all feedback again!
The guidance says: "All content should be centered vertically within the row to offer the right visual balance." That's why I added the align-items: center, ripped out all of the custom padding, and centered everything everywhere else. That does however, prove difficult in collapsible rows for a number of reasons:
- the button component (with the disclosure icon) is just tall, so the padding around the cells beefs the height up.
- it's really weird to have a cell with wrapped text where everything is aligned to the center

However....collapsible rows aren't quite designed out so we don't have any true guidance on how to handle any of that spacing. I removed them from the docs page (pending others' agreement/approval). Should I reimplement some of this padding and alignment handling since the collapsible table variants are still in the test grid? How would we like to handle this?
@marissahuysentruyt TODO: write changeset |
Description
This PR is part 1 of the table's migration to S2! Table has been updated to include:
Layout
have been addressed)!autodocs
)NOTE: Tokens for color and typography, variant support for sparklines, and any remaining touch ups (like selected hover/down states) will be done in part 2 of the table migration here: #3818
All styles for the full migration will not be addressed in this PR. Layout changes only!
Jira/Specs
CSS-1178
Figma token specs- layout token column only
CSS-1180- this is a corresponding spike ticket. I used the answers to the questions in that ticket to inform some of my decisions around not exposing certain stories.
How and where has this been tested?
Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.
Validation steps
Please review the following table layout-specific styles to ensure the tokens are used as outlined in the tokens spec Figma file:
Additional validation
Regression testing
Validate:
Screenshots
To-do list