Skip to content

Commit 54514f3

Browse files
authored
feat(tables): new light/dark mode colors (#1833)
1 parent 69741c2 commit 54514f3

27 files changed

+508
-379
lines changed

docs/migration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ consider additional positioning prop support on a case-by-case basis.
173173

174174
- All subcomponent exports have been deprecated and will be removed in a future major version.
175175
Update to subcomponent properties (e.g., `Table.Body`).
176+
- Removed `isHovered`, `isActive`, and `isFocused` props from `Table.OverflowButton`
176177

177178
#### @zendeskgarden/react-tabs
178179

package-lock.json

Lines changed: 99 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/tables/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"types": "dist/typings/index.d.ts",
2323
"dependencies": {
2424
"@zendeskgarden/container-utilities": "^2.0.0",
25+
"@zendeskgarden/react-buttons": "^9.0.0-next.13",
2526
"dom-helpers": "^5.1.0",
2627
"polished": "^4.3.1",
2728
"prop-types": "^15.5.7"

packages/tables/src/elements/Cell.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ import { ICellProps } from '../types';
1717
* @extends TdHTMLAttributes<HTMLTableCellElement>
1818
*/
1919
export const Cell = React.forwardRef<HTMLTableCellElement, ICellProps>(
20-
({ hidden, ...props }, ref) => {
20+
({ hidden, isMinimum, isTruncated, hasOverflow, ...props }, ref) => {
2121
const { size } = useTableContext();
2222

2323
return (
24-
<StyledCell ref={ref} size={size} {...props}>
24+
<StyledCell
25+
ref={ref}
26+
$size={size}
27+
$isMinimum={isMinimum}
28+
$isTruncated={isTruncated}
29+
$hasOverflow={hasOverflow}
30+
{...props}
31+
>
2532
{hidden && props.children ? (
2633
<StyledHiddenCell>{props.children}</StyledHiddenCell>
2734
) : (

packages/tables/src/elements/GroupRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const GroupRow = forwardRef<HTMLTableRowElement, HTMLAttributes<HTMLTable
1818
(props, ref) => {
1919
const { size } = useTableContext();
2020

21-
return <StyledGroupRow ref={ref} size={size} {...props} />;
21+
return <StyledGroupRow ref={ref} $size={size} {...props} />;
2222
}
2323
);
2424

packages/tables/src/elements/Head.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { IHeadProps } from '../types';
1414
*
1515
* @extends HTMLAttributes<HTMLTableSectionElement>
1616
*/
17-
export const Head = forwardRef<HTMLTableSectionElement, IHeadProps>((props, ref) => (
18-
<StyledHead ref={ref} {...props} />
19-
));
17+
export const Head = forwardRef<HTMLTableSectionElement, IHeadProps>(
18+
({ isSticky, ...props }, ref) => <StyledHead ref={ref} $isSticky={isSticky} {...props} />
19+
);
2020

2121
Head.displayName = 'Head';

packages/tables/src/elements/HeaderCell.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ import { Cell } from './Cell';
1717
* @extends ThHTMLAttributes<HTMLTableCellElement>
1818
*/
1919
export const HeaderCell = forwardRef<HTMLTableCellElement, IHeaderCellProps>(
20-
({ hidden, ...props }, ref) => {
20+
({ hidden, isMinimum, isTruncated, hasOverflow, ...props }, ref) => {
2121
const { size } = useTableContext();
2222

2323
return (
24-
<StyledHeaderCell ref={ref} size={size} {...props}>
24+
<StyledHeaderCell
25+
ref={ref}
26+
$size={size}
27+
$isMinimum={isMinimum}
28+
$isTruncated={isTruncated}
29+
$hasOverflow={hasOverflow}
30+
{...props}
31+
>
2532
{hidden && props.children ? (
2633
<StyledHiddenCell>{props.children}</StyledHiddenCell>
2734
) : (

packages/tables/src/elements/HeaderRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const HeaderRow = React.forwardRef<HTMLTableRowElement, HTMLAttributes<HT
1818
(props, ref) => {
1919
const { size } = useTableContext();
2020

21-
return <StyledHeaderRow ref={ref} size={size} {...props} />;
21+
return <StyledHeaderRow ref={ref} $size={size} {...props} />;
2222
}
2323
);
2424

packages/tables/src/elements/OverflowButton.spec.tsx

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,14 @@
66
*/
77

88
import React from 'react';
9-
import userEvent from '@testing-library/user-event';
109
import { render } from 'garden-test-utils';
1110
import { OverflowButton } from './OverflowButton';
12-
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1311

1412
describe('OverflowButton', () => {
15-
const user = userEvent.setup();
16-
1713
it('passes ref to underlying DOM element', () => {
1814
const ref = React.createRef<HTMLButtonElement>();
1915
const { container } = render(<OverflowButton ref={ref} />);
2016

2117
expect(container.firstChild).toBe(ref.current);
2218
});
23-
24-
it('applies isHovered styling', () => {
25-
const { container } = render(<OverflowButton isHovered />);
26-
27-
expect(container.firstElementChild).toHaveStyleRule('color', PALETTE_V8.grey[700]);
28-
});
29-
30-
it('applies isActive styling', () => {
31-
const { container } = render(<OverflowButton isActive />);
32-
33-
expect(container.firstElementChild).toHaveStyleRule('z-index', '1');
34-
expect(container.firstElementChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
35-
});
36-
37-
describe('onFocus', () => {
38-
it('applies focused state', async () => {
39-
const { container } = render(<OverflowButton />);
40-
41-
await user.click(container.firstElementChild!);
42-
expect(container.firstElementChild).toHaveStyleRule('box-shadow');
43-
});
44-
});
45-
46-
describe('onBlur', () => {
47-
it('removes focused state', async () => {
48-
const { container } = render(<OverflowButton />);
49-
50-
await user.click(container.firstElementChild!);
51-
await user.tab();
52-
expect(container.firstElementChild).not.toHaveStyleRule('box-shadow');
53-
});
54-
});
5519
});

packages/tables/src/elements/OverflowButton.tsx

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,27 @@
55
* found at http://www.apache.org/licenses/LICENSE-2.0.
66
*/
77

8-
import React, { ButtonHTMLAttributes, useState, forwardRef } from 'react';
9-
import PropTypes from 'prop-types';
10-
import { composeEventHandlers } from '@zendeskgarden/container-utilities';
11-
import OverflowStrokeIcon from '@zendeskgarden/svg-icons/src/16/overflow-stroke.svg';
12-
import { StyledOverflowButton, StyledOverflowButtonIconWrapper } from '../styled';
8+
import React, { ButtonHTMLAttributes, forwardRef } from 'react';
9+
import OverflowStrokeIcon from '@zendeskgarden/svg-icons/src/16/overflow-vertical-stroke.svg';
10+
import { StyledOverflowButton } from '../styled';
1311
import { useTableContext } from '../utils/useTableContext';
1412

15-
export interface IOverflowButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
16-
/** @ignore Applies hover styling */
17-
isHovered?: boolean;
18-
/** @ignore Applies active styling */
19-
isActive?: boolean;
20-
/** @ignore Applies focus styling */
21-
isFocused?: boolean;
22-
}
23-
2413
/**
2514
* @deprecated use `Table.OverflowButton` instead
2615
*
2716
* @extends ButtonHTMLAttributes<HTMLButtonElement>
2817
*/
29-
export const OverflowButton = forwardRef<HTMLButtonElement, IOverflowButtonProps>(
30-
({ onFocus, onBlur, isFocused: focused, ...other }, ref) => {
31-
const [isFocused, setIsFocused] = useState(false);
32-
const { size } = useTableContext();
18+
export const OverflowButton = forwardRef<
19+
HTMLButtonElement,
20+
ButtonHTMLAttributes<HTMLButtonElement>
21+
>((props, ref) => {
22+
const { size } = useTableContext();
3323

34-
return (
35-
<StyledOverflowButton
36-
onFocus={composeEventHandlers(onFocus, () => {
37-
setIsFocused(true);
38-
})}
39-
onBlur={composeEventHandlers(onBlur, () => {
40-
setIsFocused(false);
41-
})}
42-
size={size}
43-
isFocused={typeof focused === 'undefined' ? isFocused : focused}
44-
ref={ref}
45-
{...other}
46-
>
47-
<StyledOverflowButtonIconWrapper>
48-
<OverflowStrokeIcon />
49-
</StyledOverflowButtonIconWrapper>
50-
</StyledOverflowButton>
51-
);
52-
}
53-
);
24+
return (
25+
<StyledOverflowButton type="button" $size={size} ref={ref} {...props} focusInset>
26+
<OverflowStrokeIcon />
27+
</StyledOverflowButton>
28+
);
29+
});
5430

5531
OverflowButton.displayName = 'OverflowButton';
56-
57-
OverflowButton.propTypes = {
58-
isHovered: PropTypes.bool,
59-
isActive: PropTypes.bool,
60-
isFocused: PropTypes.bool
61-
};

0 commit comments

Comments
 (0)