Skip to content

Commit 23e81e4

Browse files
authored
feat: update text colors to match new S2 spectrum design for Table/Tree (#9280)
1 parent ade3851 commit 23e81e4

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

packages/@react-spectrum/s2/src/TableView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,10 @@ const commonCellStyles = {
953953

954954
const cell = style<CellRenderProps & S2TableProps & {isDivider: boolean}>({
955955
...commonCellStyles,
956-
color: baseColor('neutral'),
956+
color: {
957+
default: baseColor('neutral-subdued'),
958+
isSelected: baseColor('neutral')
959+
},
957960
paddingY: centerPadding(),
958961
minHeight: {
959962
default: 40,

packages/@react-spectrum/s2/src/TreeView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import {ActionButtonGroupContext} from './ActionButtonGroup';
1414
import {ActionMenuContext} from './ActionMenu';
15+
import {baseColor, colorMix, focusRing, fontRelative, style} from '../style' with {type: 'macro'};
1516
import {
1617
Button,
1718
ButtonContext,
@@ -31,7 +32,6 @@ import {
3132
import {centerBaseline} from './CenterBaseline';
3233
import {Checkbox} from './Checkbox';
3334
import Chevron from '../ui-icons/Chevron';
34-
import {colorMix, focusRing, fontRelative, style} from '../style' with {type: 'macro'};
3535
import {DOMRef, forwardRefType, GlobalDOMAttributes, Key, LoadingState} from '@react-types/shared';
3636
import {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};
3737
import {IconContext} from './Icon';
@@ -153,7 +153,10 @@ const treeRow = style({
153153
width: 'full',
154154
boxSizing: 'border-box',
155155
font: 'ui',
156-
color: 'body',
156+
color: {
157+
default: baseColor('neutral-subdued'),
158+
isSelected: baseColor('neutral')
159+
},
157160
outlineStyle: 'none',
158161
cursor: {
159162
default: 'default',

packages/react-aria-components/src/Table.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,11 @@ export interface CellRenderProps {
13131313
* @selector [data-hovered]
13141314
*/
13151315
isHovered: boolean,
1316+
/**
1317+
* Whether the parent row is currently selected.
1318+
* @selector [data-selected]
1319+
*/
1320+
isSelected: boolean,
13161321
/**
13171322
* The unique id of the cell.
13181323
**/
@@ -1363,6 +1368,7 @@ export const Cell = /*#__PURE__*/ createLeafComponent(TableCellNode, (props: Cel
13631368
}, state, ref);
13641369
let {isFocused, isFocusVisible, focusProps} = useFocusRing();
13651370
let {hoverProps, isHovered} = useHover({});
1371+
let isSelected = cell.parentKey != null ? state.selectionManager.isSelected(cell.parentKey) : false;
13661372

13671373
let renderProps = useRenderProps({
13681374
...props,
@@ -1373,6 +1379,7 @@ export const Cell = /*#__PURE__*/ createLeafComponent(TableCellNode, (props: Cel
13731379
isFocusVisible,
13741380
isPressed,
13751381
isHovered,
1382+
isSelected,
13761383
id: cell.key
13771384
}
13781385
});
@@ -1386,7 +1393,8 @@ export const Cell = /*#__PURE__*/ createLeafComponent(TableCellNode, (props: Cel
13861393
ref={ref as any}
13871394
data-focused={isFocused || undefined}
13881395
data-focus-visible={isFocusVisible || undefined}
1389-
data-pressed={isPressed || undefined}>
1396+
data-pressed={isPressed || undefined}
1397+
data-selected={isSelected || undefined}>
13901398
<CollectionRendererContext.Provider value={DefaultCollectionRenderer}>
13911399
{renderProps.children}
13921400
</CollectionRendererContext.Provider>

0 commit comments

Comments
 (0)