From 0b7eb05024bddbcd3fcbe96807929be4f692e18f Mon Sep 17 00:00:00 2001 From: Ayesha Mazumdar Date: Tue, 6 Apr 2021 17:04:16 -0700 Subject: [PATCH] Table: Add ability to specify sticky columns (#1395) --- .../integration/accessibility_Table_spec.js | 7 +- docs/src/Table.doc.js | 611 +++++++++++++++++- packages/gestalt/src/Table.css | 24 + packages/gestalt/src/Table.css.flow | 4 + packages/gestalt/src/Table.js | 42 +- packages/gestalt/src/Table.test.js | 11 + packages/gestalt/src/TableCell.js | 29 +- packages/gestalt/src/TableCell.test.js | 11 + packages/gestalt/src/TableHeaderCell.js | 30 +- packages/gestalt/src/TableRow.js | 31 +- packages/gestalt/src/TableRowExpandable.js | 45 +- .../src/__snapshots__/Table.test.js.snap | 19 + .../src/__snapshots__/TableCell.test.js.snap | 26 + .../TableHeaderCell.test.js.snap | 12 + .../TableRowExpandable.test.js.snap | 18 + .../TableSortableHeaderCell.test.js.snap | 12 + packages/gestalt/src/contexts/TableContext.js | 27 + 17 files changed, 940 insertions(+), 19 deletions(-) create mode 100644 packages/gestalt/src/contexts/TableContext.js diff --git a/cypress/integration/accessibility_Table_spec.js b/cypress/integration/accessibility_Table_spec.js index 23f55b6274..bd4525e793 100644 --- a/cypress/integration/accessibility_Table_spec.js +++ b/cypress/integration/accessibility_Table_spec.js @@ -7,8 +7,13 @@ describe('Table Accessibility check', () => { it('Tests accessibility on the Table page', () => { cy.configureAxe({ rules: [ + // Disabled until converted to new docs { - // Disabled to avoid confusion for sticky header example + id: 'color-contrast', + enabled: false, + }, + { + // Disabled to avoid confusion for sticky header and column examples id: 'scrollable-region-focusable', enabled: false, }, diff --git a/docs/src/Table.doc.js b/docs/src/Table.doc.js index e88ef0b87e..7e4e311dbb 100644 --- a/docs/src/Table.doc.js +++ b/docs/src/Table.doc.js @@ -259,6 +259,380 @@ card( />, ); +card( + + + + + + + Image + + + Name + + + Super Name + + + Favorite Food + + + Best Friend + + + Birthday + + + + + + + + + + + + + + Tony Stark + Iron Man + Shwarma + Spiderman + + May 29, 1970 + + + + + + + + + + + + Peter Parker + Spiderman + Sandwiches + Iron Man + December 28, 1995 + + + + + + + + + + + T'Challa + Black Panther + Beef suya + Shuri + November 28, 1977 + + + +
+ + +`} + />, +); + +card( + + + + + + + Image + + + Name + + + Super Name + + + Best Friend + + + Favorite Food + + + Super Powers + + + Home + + + Aliases + + + + + + + + + + + + + + Tony Stark + Iron Man + Spiderman + Shwarma + Flight, Super strength + New York + N/A + + + + + + + + + + + Peter Parker + Spiderman + Iron Man + Sandwiches + Spidey senses, super strength, web shooters + Brooklyn + Friendly Neighborhood Spiderman + + + + + + + + + + + Wanda Maximoff + Scarlet Witch + Vision + Chicken paprikash + Chaos magic, spells, reality warping + Sokovia + N/A + + + + + + + + + + + T'Challa + Black Panther + Shuri + Beef suya + Enhanced strength, speed, reflexes + Vibranium suit + Wakanda + King of the Dead + + + +
+ + +`} + />, +); + +card( + + + + + + + Image + + + Name + + + Super Name + + + Best Friend + + + Favorite Food + + + Super Powers + + + Home + + + Aliases + + + + + + + + + + + + + + + Tony Stark + Iron Man + Spiderman + Shwarma + Flight, Super strength + New York + N/A + + + + + + + + + + + Peter Parker + Spiderman + Iron Man + Sandwiches + Spidey senses, super strength, web shooters + Brooklyn + Friendly Neighborhood Spiderman + + + + + + + + + + + Wanda Maximoff + Scarlet Witch + Vision + Chicken paprikash + Chaos magic, spells, reality warping + Sokovia + N/A + + + + + + + + + + + T'Challa + Black Panther + Shuri + Beef suya + Enhanced strength, speed, reflexes + Vibranium suit + Wakanda + King of the Dead + + + +
+ + +`} + />, +); + card( element for the Collapse button.', + 'Accessibility: It populates aria-label on the `