Skip to content

Commit bc5c1d4

Browse files
authored
feat(peer-deps): extend styled-components support to v6 (#1978)
1 parent f345fa1 commit bc5c1d4

File tree

102 files changed

+441
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+441
-360
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"@types/prop-types": "15.7.13",
5858
"@types/react": "18.3.11",
5959
"@types/react-dom": "18.3.1",
60-
"@types/styled-components": "5.1.34",
6160
"@zendeskgarden/css-bedrock": "10.0.0",
6261
"@zendeskgarden/eslint-config": "44.0.1",
6362
"@zendeskgarden/scripts": "2.4.3",
@@ -100,7 +99,7 @@
10099
"rollup-plugin-delete": "2.1.0",
101100
"rollup-plugin-typescript2": "0.36.0",
102101
"storybook": "7.6.20",
103-
"styled-components": "5.3.11",
102+
"styled-components": "6.1.13",
104103
"stylelint": "16.10.0",
105104
"stylelint-order": "6.0.4",
106105
"temp": "0.9.4",

packages/.template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@zendeskgarden/react-theming": ">=9.0.0",
2929
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3030
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
31-
"styled-components": "^5.3.1"
31+
"styled-components": "^5.3.1 || ^6.0.0"
3232
},
3333
"devDependencies": {
3434
"@zendeskgarden/react-theming": "^9.0.0"

packages/accordions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@zendeskgarden/react-theming": ">=9.0.0",
3131
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3232
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
33-
"styled-components": "^5.3.1"
33+
"styled-components": "^5.3.1 || ^6.0.0"
3434
},
3535
"devDependencies": {
3636
"@zendeskgarden/react-theming": "^9.2.0",

packages/accordions/src/styled/accordion/StyledRotateIcon.ts

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

8-
import styled, { css, ThemeProps, DefaultTheme } from 'styled-components';
8+
import styled, { css, ThemeProps, DefaultTheme, DataAttributes } from 'styled-components';
99
import { retrieveComponentStyles, StyledBaseIcon, getColor } from '@zendeskgarden/react-theming';
1010

1111
const COMPONENT_ID = 'accordions.rotate_icon';
@@ -38,7 +38,7 @@ const colorStyles = ({
3838
`;
3939
};
4040

41-
export const StyledRotateIcon = styled(StyledBaseIcon).attrs({
41+
export const StyledRotateIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
4242
'data-garden-id': COMPONENT_ID,
4343
'data-garden-version': PACKAGE_VERSION
4444
})<IStyledRotateIcon>`

packages/accordions/src/styled/timeline/StyledItemIcon.ts

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

8-
import styled, { DefaultTheme, ThemeProps, css } from 'styled-components';
8+
import styled, { DataAttributes, DefaultTheme, ThemeProps, css } from 'styled-components';
99
import { math } from 'polished';
1010
import { retrieveComponentStyles, StyledBaseIcon, getColor } from '@zendeskgarden/react-theming';
1111

@@ -36,7 +36,7 @@ const colorStyles = ({ $surfaceColor, theme }: IStyledItemIcon & ThemeProps<Defa
3636
/**
3737
* 1. Odd sizing allows the timeline line to center respective of the circle icon.
3838
*/
39-
export const StyledItemIcon = styled(StyledBaseIcon).attrs({
39+
export const StyledItemIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
4040
'data-garden-id': COMPONENT_ID,
4141
'data-garden-version': PACKAGE_VERSION
4242
})<IStyledItemIcon>`

packages/avatars/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@zendeskgarden/react-theming": ">=9.0.0",
2929
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3030
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
31-
"styled-components": "^5.3.1"
31+
"styled-components": "^5.3.1 || ^6.0.0"
3232
},
3333
"devDependencies": {
3434
"@zendeskgarden/react-dropdowns": "^9.2.0",

packages/avatars/src/elements/StatusIndicator.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ describe('StatusIndicator', () => {
4444
it('renders in RTL mode', () => {
4545
const { getByRole } = renderRtl(<StatusIndicator type="transfers">Caption</StatusIndicator>);
4646

47-
expect(getByRole('img')).toHaveStyleRule('transform', 'scale(-1,1)', {
48-
modifier: "& > svg[data-icon-status='transfers']"
47+
expect(getByRole('img')).toHaveStyleRule('transform', 'scale(-1, 1)', {
48+
modifier: "&>svg[data-icon-status='transfers']"
4949
});
5050
});
5151

packages/avatars/src/styled/StyledAvatar.spec.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ describe('StyledAvatar', () => {
8383
it('renders foreground color as expected', () => {
8484
const { container } = render(<StyledAvatar $foregroundColor="red" />);
8585

86-
expect(container.firstChild).toHaveStyleRule('color', 'red', { modifier: '> svg' });
86+
expect(container.firstChild).toHaveStyleRule('color', 'red', { modifier: '&>svg' });
8787
});
8888

8989
it('renders foreground color variable as expected', () => {
9090
const { container } = render(<StyledAvatar $foregroundColor="foreground.default" />);
9191

9292
expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[900], {
93-
modifier: '> svg'
93+
modifier: '&>svg'
9494
});
9595
});
9696
});
@@ -99,37 +99,37 @@ describe('StyledAvatar', () => {
9999
it('renders extraextrasmall', () => {
100100
const { container } = render(<StyledAvatar $size="extraextrasmall" />);
101101

102-
expect(container.firstChild).toHaveStyleRule('width', '16px !important');
102+
expect(container.firstChild).toHaveStyleRule('width', '16px!important');
103103
});
104104

105105
it('renders extrasmall', () => {
106106
const { container } = render(<StyledAvatar $size="extrasmall" />);
107107

108-
expect(container.firstChild).toHaveStyleRule('width', '24px !important');
108+
expect(container.firstChild).toHaveStyleRule('width', '24px!important');
109109
});
110110

111111
it('renders small', () => {
112112
const { container } = render(<StyledAvatar $size="small" />);
113113

114-
expect(container.firstChild).toHaveStyleRule('width', '32px !important');
114+
expect(container.firstChild).toHaveStyleRule('width', '32px!important');
115115
});
116116

117117
it('renders medium', () => {
118118
const { container } = render(<StyledAvatar $size="medium" />);
119119

120-
expect(container.firstChild).toHaveStyleRule('width', '40px !important');
120+
expect(container.firstChild).toHaveStyleRule('width', '40px!important');
121121
});
122122

123123
it('renders large', () => {
124124
const { container } = render(<StyledAvatar $size="large" />);
125125

126-
expect(container.firstChild).toHaveStyleRule('width', '48px !important');
126+
expect(container.firstChild).toHaveStyleRule('width', '48px!important');
127127
});
128128
});
129129

130130
describe('badge', () => {
131131
const styleRuleOptions = {
132-
modifier: `& > ${StyledStatusIndicator}`
132+
modifier: `&>${StyledStatusIndicator}`
133133
};
134134

135135
it('renders the status indicator correctly', () => {

packages/breadcrumbs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@zendeskgarden/react-theming": ">=9.0.0",
3030
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3131
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
32-
"styled-components": "^5.3.1"
32+
"styled-components": "^5.3.1 || ^6.0.0"
3333
},
3434
"devDependencies": {
3535
"@zendeskgarden/react-theming": "^9.2.0",

packages/breadcrumbs/src/elements/Breadcrumb.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import React, { Children, cloneElement, forwardRef, HTMLAttributes } from 'react';
9+
import ChevronRightStrokeIcon from '@zendeskgarden/svg-icons/src/12/chevron-right-stroke.svg';
910
import { useBreadcrumb } from '@zendeskgarden/container-breadcrumb';
1011
import { useText } from '@zendeskgarden/react-theming';
1112
import {
@@ -38,7 +39,9 @@ export const Breadcrumb = forwardRef<HTMLElement, HTMLAttributes<HTMLElement>>((
3839
<>
3940
<StyledBreadcrumbItem>{child}</StyledBreadcrumbItem>
4041
<StyledCenteredBreadcrumbItem>
41-
<StyledChevronIcon />
42+
<StyledChevronIcon>
43+
<ChevronRightStrokeIcon />
44+
</StyledChevronIcon>
4245
</StyledCenteredBreadcrumbItem>
4346
</>
4447
);

packages/breadcrumbs/src/styled/StyledChevronIcon.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,11 @@
55
* found at http://www.apache.org/licenses/LICENSE-2.0.
66
*/
77

8-
import React from 'react';
98
import styled from 'styled-components';
109
import { em } from 'polished';
11-
import { getColor } from '@zendeskgarden/react-theming';
12-
import ChevronRightStrokeIcon from '@zendeskgarden/svg-icons/src/12/chevron-right-stroke.svg';
10+
import { getColor, StyledBaseIcon } from '@zendeskgarden/react-theming';
1311

14-
/**
15-
* Accepts all `<svg>` props
16-
*/
17-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
18-
export const StyledChevronIcon = styled(({ children, theme, ...props }) => (
19-
<ChevronRightStrokeIcon {...props} />
20-
)).attrs({
21-
role: 'presentation',
22-
'aria-hidden': 'true'
23-
})`
12+
export const StyledChevronIcon = styled(StyledBaseIcon)`
2413
transform: ${p => p.theme.rtl && `rotate(180deg);`};
2514
margin: 0 ${p => em(p.theme.space.base, p.theme.fontSizes.md)};
2615
color: ${p => getColor({ variable: 'foreground.subtle', theme: p.theme })};

packages/buttons/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@zendeskgarden/react-theming": ">=9.0.0",
3131
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3232
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
33-
"styled-components": "^5.3.1"
33+
"styled-components": "^5.3.1 || ^6.0.0"
3434
},
3535
"devDependencies": {
3636
"@zendeskgarden/react-theming": "^9.2.0",

packages/buttons/src/styled/StyledIcon.ts

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

8-
import styled, { css, ThemeProps, DefaultTheme } from 'styled-components';
8+
import styled, { css, ThemeProps, DefaultTheme, DataAttributes } from 'styled-components';
99
import { StyledBaseIcon, retrieveComponentStyles } from '@zendeskgarden/react-theming';
1010

1111
const COMPONENT_ID = 'buttons.icon';
1212

1313
interface IStyledIconProps {
14-
$isRotated: boolean;
14+
$isRotated?: boolean;
1515
$position?: 'start' | 'end';
1616
}
1717

@@ -32,7 +32,7 @@ const sizeStyles = (props: IStyledIconProps & ThemeProps<DefaultTheme>) => {
3232
);
3333
};
3434

35-
export const StyledIcon = styled(StyledBaseIcon).attrs({
35+
export const StyledIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
3636
'data-garden-id': COMPONENT_ID,
3737
'data-garden-version': PACKAGE_VERSION
3838
})<IStyledIconProps>`

packages/chrome/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@zendeskgarden/react-theming": ">=9.0.0",
3333
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3434
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
35-
"styled-components": "^5.3.1"
35+
"styled-components": "^5.3.1 || ^6.0.0"
3636
},
3737
"devDependencies": {
3838
"@zendeskgarden/react-theming": "^9.2.0",

packages/chrome/src/elements/header/HeaderItem.tsx

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

8-
import React from 'react';
8+
import React, { HTMLAttributes, RefObject } from 'react';
99
import PropTypes from 'prop-types';
1010
import { IHeaderItemProps, PRODUCTS } from '../../types';
1111
import { StyledHeaderItem, StyledLogoHeaderItem } from '../../styled';
@@ -20,12 +20,12 @@ export const HeaderItem = React.forwardRef<HTMLButtonElement, IHeaderItemProps>(
2020
if (hasLogo) {
2121
return (
2222
<StyledLogoHeaderItem
23-
ref={ref}
23+
ref={ref as RefObject<HTMLDivElement>}
2424
$isRound={isRound}
2525
$maxX={maxX}
2626
$maxY={maxY}
2727
$product={product}
28-
{...other}
28+
{...(other as HTMLAttributes<HTMLDivElement>)}
2929
/>
3030
);
3131
}

packages/chrome/src/elements/nav/Nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import React, { useMemo } from 'react';
9-
import { ThemeProvider } from 'styled-components';
9+
import { ThemeProvider } from '@zendeskgarden/react-theming';
1010
import PropTypes from 'prop-types';
1111
import { INavProps } from '../../types';
1212
import { useChromeContext } from '../../utils/useChromeContext';

packages/chrome/src/styled/header/StyledHeaderItemIcon.ts

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

8-
import styled, { DefaultTheme, ThemeProps, css } from 'styled-components';
8+
import styled, { DataAttributes, DefaultTheme, ThemeProps, css } from 'styled-components';
99
import { retrieveComponentStyles, StyledBaseIcon } from '@zendeskgarden/react-theming';
1010

1111
const COMPONENT_ID = 'chrome.header_item_icon';
@@ -22,7 +22,7 @@ const sizeStyles = ({ theme }: ThemeProps<DefaultTheme>) => {
2222
`;
2323
};
2424

25-
export const StyledHeaderItemIcon = styled(StyledBaseIcon).attrs({
25+
export const StyledHeaderItemIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
2626
'data-garden-id': COMPONENT_ID,
2727
'data-garden-version': PACKAGE_VERSION
2828
})`

packages/chrome/src/styled/nav/StyledNavItemIcon.ts

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

8-
import styled, { DefaultTheme, ThemeProps, css } from 'styled-components';
8+
import styled, { DataAttributes, DefaultTheme, ThemeProps, css } from 'styled-components';
99
import { retrieveComponentStyles, StyledBaseIcon } from '@zendeskgarden/react-theming';
1010

1111
const COMPONENT_ID = 'chrome.nav_item_icon';
@@ -19,7 +19,7 @@ const sizeStyles = ({ theme }: ThemeProps<DefaultTheme>) => {
1919
`;
2020
};
2121

22-
export const StyledNavItemIcon = styled(StyledBaseIcon).attrs({
22+
export const StyledNavItemIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
2323
'data-garden-id': COMPONENT_ID,
2424
'data-garden-version': PACKAGE_VERSION
2525
})`

packages/colorpickers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@zendeskgarden/react-theming": ">=9.0.0",
3838
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3939
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
40-
"styled-components": "^5.3.1"
40+
"styled-components": "^5.3.1 || ^6.0.0"
4141
},
4242
"devDependencies": {
4343
"@types/lodash.isequal": "4.5.8",

packages/colorpickers/src/elements/ColorSwatch/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import React, {
1414
useRef,
1515
useState
1616
} from 'react';
17+
import CheckIcon from '@zendeskgarden/svg-icons/src/12/check-sm-fill.svg';
1718
import PropTypes from 'prop-types';
1819
import { mergeRefs } from 'react-merge-refs';
1920
import { ThemeContext } from 'styled-components';
@@ -150,7 +151,9 @@ export const ColorSwatch = forwardRef<HTMLTableElement, IColorSwatchProps>(
150151
{...(gridCellProps as InputHTMLAttributes<HTMLInputElement>)}
151152
/>
152153
</Tooltip>
153-
<StyledIcon />
154+
<StyledIcon>
155+
<CheckIcon />
156+
</StyledIcon>
154157
</StyledColorSwatchLabel>
155158
</StyledCell>
156159
);

packages/colorpickers/src/styled/ColorSwatch/StyledColorSwatchLabel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const StyledColorSwatchLabel = styled(StyledButtonPreview).attrs({
4444
as: 'label',
4545
'data-garden-id': COMPONENT_ID,
4646
'data-garden-version': PACKAGE_VERSION
47-
})`
47+
})<IStyledColorSwatchLabelProps>`
4848
position: relative;
4949
top: 0;
5050
border-radius: ${props => props.theme.borderRadii.md};

packages/colorpickers/src/styled/ColorSwatch/StyledIcon.ts

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

8-
import styled from 'styled-components';
9-
import CheckIcon from '@zendeskgarden/svg-icons/src/12/check-sm-fill.svg';
10-
import { retrieveComponentStyles } from '@zendeskgarden/react-theming';
8+
import styled, { DataAttributes } from 'styled-components';
9+
import { retrieveComponentStyles, StyledBaseIcon } from '@zendeskgarden/react-theming';
1110
import { StyledColorSwatchInput } from './StyledColorSwatchInput';
1211

1312
const COMPONENT_ID = 'colorpickers.colorswatch_check';
1413

15-
export const StyledIcon = styled(CheckIcon as 'svg').attrs({
14+
export const StyledIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
1615
'data-garden-id': COMPONENT_ID,
1716
'data-garden-version': PACKAGE_VERSION
1817
})`

packages/datepickers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@zendeskgarden/react-theming": ">=9.0.0",
3232
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3333
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
34-
"styled-components": "^5.3.1"
34+
"styled-components": "^5.3.1 || ^6.0.0"
3535
},
3636
"devDependencies": {
3737
"@zendeskgarden/react-theming": "^9.2.0",

packages/datepickers/src/styled/StyledMenuWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface IStyledMenuWrapperProps {
2424
export const StyledMenuWrapper = styled.div.attrs<IStyledMenuWrapperProps>(props => ({
2525
'data-garden-id': COMPONENT_ID,
2626
'data-garden-version': PACKAGE_VERSION,
27-
className: props.$isAnimated && 'is-animated'
27+
className: props.$isAnimated ? 'is-animated' : undefined
2828
}))<IStyledMenuWrapperProps>`
2929
top: 0; /* [1] */
3030
left: 0; /* [1] */

packages/draggable/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@zendeskgarden/react-theming": ">=9.0.0",
2929
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
3030
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
31-
"styled-components": "^5.3.1"
31+
"styled-components": "^5.3.1 || ^6.0.0"
3232
},
3333
"devDependencies": {
3434
"@dnd-kit/core": "6.1.0",

0 commit comments

Comments
 (0)