Skip to content

Commit 70dcf8c

Browse files
fix(table): button styles in whcm
- fixes background colors, text colors, icon colors, interactive states, and border radius in high contrast mode - removes duplicate quiet styles - adds forced-color-adjust: none to avoid flash of orange button text color in WHCM
1 parent 973bf6d commit 70dcf8c

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

components/table/index.css

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
--mod-button-content-color-down: var(--spectrum-table-header-text-color);
140140
--mod-button-edge-to-text: var(--spectrum-table-cell-inline-spacing);
141141
--mod-button-padding-label-to-icon: var(--spectrum-table-visual-to-text);
142-
--mod-button-height: var(--spectrum-table-min-header-row-height);
142+
--mod-button-border-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-focused-cell-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width)));
143143
--mod-button-focus-ring-border-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-focused-cell-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width)));
144144

145145
&:dir(rtl) {
@@ -256,7 +256,7 @@
256256
&.is-sortable,
257257
&.spectrum-Table-hasMenuButton,
258258
.spectrum-Table-sortButton {
259-
--spectrum-table-icon-color: var(--mod-table-header-icons-color-default, var(--spectrum-table-header-icons-color-default));
259+
--spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-header-icons-color-default, var(--spectrum-table-header-icons-color-default)));
260260

261261
&:hover {
262262
--spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-header-icons-color-hover, var(--spectrum-table-header-icons-color-hover)));
@@ -401,17 +401,6 @@
401401
}
402402
}
403403

404-
/* Quiet table header rows do not have inline borders */
405-
.spectrum-Table--quiet .spectrum-Table-headRow:first-child {
406-
.spectrum-Table-headCell:first-child {
407-
border-inline-start: 0;
408-
}
409-
410-
.spectrum-Table-headCell:last-child {
411-
border-inline-end: 0;
412-
}
413-
}
414-
415404
/********* ICONS- SORT, DISCLOSURE/MENU *********/
416405
/* Head cell column text */
417406
.spectrum-Table-columnTitle {
@@ -423,6 +412,21 @@
423412
.spectrum-Table-headCell.is-sortable {
424413
padding: 0;
425414

415+
/* Ensure the button text color is the same as the header text color, particularly in high contrast mode. */
416+
.spectrum-Table-sortButton {
417+
color: var(--highcontrast-table-header-text-color, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)));
418+
419+
/* Avoids flash of a different text color from the button in WHCM. */
420+
forced-color-adjust: none;
421+
422+
&:hover,
423+
&:focus,
424+
&:focus-visible,
425+
&:active {
426+
color: var(--highcontrast-table-header-text-color-hover, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)));
427+
}
428+
}
429+
426430
/* Focus indicator- brings the focus indicator above the border and matches the table cell dimensions. */
427431
.spectrum-Table-sortButton::after {
428432
inset: calc(3 * var(--mod-table-border-width, var(--spectrum-table-border-width)));
@@ -438,9 +442,16 @@
438442
/* Head cell column text in the button that opens the menu */
439443
.spectrum-Table-headCell.spectrum-Table-hasMenuButton {
440444
.spectrum-Table-sortButton {
441-
min-block-size: calc(var(--spectrum-table-min-header-row-height) + var(--mod-table-border-width, var(--spectrum-table-border-width)));
442445
min-inline-size: 100%;
443446
justify-content: flex-start;
447+
color: var(--highcontrast-table-header-text-color, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)));
448+
449+
/* Avoids flash of a different text color from the button in WHCM. */
450+
forced-color-adjust: none;
451+
452+
&:hover {
453+
color: var(--highcontrast-table-header-text-color-hover, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)));
454+
}
444455

445456
/* Focus indicator- brings the focus indicator above the cell borders and matches the table cell dimensions. */
446457
&:focus-visible::after,
@@ -931,7 +942,7 @@
931942

932943
&:focus-visible,
933944
&.is-keyboardFocused {
934-
--spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-key-focus, var(--spectrum-table-icon-color-key-focus)));
945+
--spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-icon-color-key-focus, var(--spectrum-table-icon-color-key-focus)));
935946

936947
outline-width: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness));
937948
outline-style: solid;
@@ -981,6 +992,10 @@
981992
--highcontrast-table-selected-row-background-color: Highlight;
982993
--highcontrast-table-selected-row-text-color: HighlightText;
983994

995+
/* Button text colors */
996+
--highcontrast-table-header-text-color: CanvasText;
997+
--highcontrast-table-header-text-color-hover: Highlight;
998+
984999
@supports (color: SelectedItem) {
9851000
--highcontrast-table-selected-row-background-color: SelectedItem;
9861001
--highcontrast-table-selected-row-text-color: SelectedItemText;

0 commit comments

Comments
 (0)