From 034eb39917b5bf019efd6b6202930da53c106a52 Mon Sep 17 00:00:00 2001 From: Kevin Chang Date: Fri, 9 Dec 2022 15:08:38 -0800 Subject: [PATCH] fix(table): correct SR table headings, adjust spacing --- .../lib/stylesheets/components/_table.scss | 24 ++++++------------- packages/sage-system/lib/table.js | 4 ++++ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/packages/sage-assets/lib/stylesheets/components/_table.scss b/packages/sage-assets/lib/stylesheets/components/_table.scss index 75cbd61414..0f46a89b29 100644 --- a/packages/sage-assets/lib/stylesheets/components/_table.scss +++ b/packages/sage-assets/lib/stylesheets/components/_table.scss @@ -38,6 +38,7 @@ $-table-overflow-indicator-gradient: linear-gradient( // Responsive stacked table $-table-stack-row-padding-block: rem(18px); $-table-stack-row-padding-inline: rem(20px); +$-table-stack-row-margin-block: rem(15); // UXD TODO: confirm size with design $-table-stack-cell-max-children: 4; // Other @@ -359,6 +360,10 @@ $-table-avatar-width: rem(32px); } @media screen and (max-width: sage-breakpoint(sm-max)) { + .sage-table-wrapper__overflow--stack::after { + opacity: 0; + } + .sage-table--stack { thead tr { @include visually-hidden; @@ -376,13 +381,10 @@ $-table-avatar-width: rem(32px); tbody tr { padding: #{$-table-stack-row-padding-block} #{$-table-stack-row-padding-inline}; + margin-bottom: #{$-table-stack-row-margin-block}; position: relative; border: sage-border(default); border-radius: sage-border(radius); - - & + & { - margin-top: #{$-table-stack-row-padding-block}; - } } tbody td { @@ -411,20 +413,8 @@ $-table-avatar-width: rem(32px); } .sage-table-cell--avatar, - .sage-table--has-menu-options td:last-child::before { + &.sage-table--has-menu-options td:last-child::before { display: none; } } } - -@media screen and (min-width: sage-breakpoint(md-min)) { - .sage-table td::before { - display: none; - } - - .sage-table--has-leading-input { - tbody td:first-child { - width: rem(44px); - } - } -} diff --git a/packages/sage-system/lib/table.js b/packages/sage-system/lib/table.js index 4afb826fc7..e50f44ec48 100644 --- a/packages/sage-system/lib/table.js +++ b/packages/sage-system/lib/table.js @@ -49,8 +49,11 @@ Sage.table = (function() { tables.forEach(table => { const headers = table.querySelectorAll('.sage-table__header'); const rows = table.querySelectorAll('tbody tr'); + const tableWrapper = table.parentElement; const tableHeadings = []; + tableWrapper.classList.add("sage-table-wrapper__overflow--stack"); + // populate an array with each table's headers headers.forEach(header => { const label = header.textContent.trim(); @@ -102,6 +105,7 @@ Sage.table = (function() { function addTableAria() { const tableItems = [ + { items: 'thead th', role: 'columnheader' }, { items: 'tbody', role: 'rowgroup' }, { items: 'tbody tr', role: 'row' }, { items: 'tbody td', role: 'cell' },