Skip to content

Commit

Permalink
feat(peer-deps): extend styled-components support to v6 (#1978)
Browse files Browse the repository at this point in the history
  • Loading branch information
ze-flo authored Dec 5, 2024
1 parent f345fa1 commit bc5c1d4
Show file tree
Hide file tree
Showing 102 changed files with 441 additions and 360 deletions.
172 changes: 87 additions & 85 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@types/prop-types": "15.7.13",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.1",
"@types/styled-components": "5.1.34",
"@zendeskgarden/css-bedrock": "10.0.0",
"@zendeskgarden/eslint-config": "44.0.1",
"@zendeskgarden/scripts": "2.4.3",
Expand Down Expand Up @@ -100,7 +99,7 @@
"rollup-plugin-delete": "2.1.0",
"rollup-plugin-typescript2": "0.36.0",
"storybook": "7.6.20",
"styled-components": "5.3.11",
"styled-components": "6.1.13",
"stylelint": "16.10.0",
"stylelint-order": "6.0.4",
"temp": "0.9.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/.template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@zendeskgarden/react-theming": "^9.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/accordions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@zendeskgarden/react-theming": "^9.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/accordions/src/styled/accordion/StyledRotateIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

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

const COMPONENT_ID = 'accordions.rotate_icon';
Expand Down Expand Up @@ -38,7 +38,7 @@ const colorStyles = ({
`;
};

export const StyledRotateIcon = styled(StyledBaseIcon).attrs({
export const StyledRotateIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})<IStyledRotateIcon>`
Expand Down
4 changes: 2 additions & 2 deletions packages/accordions/src/styled/timeline/StyledItemIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

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

Expand Down Expand Up @@ -36,7 +36,7 @@ const colorStyles = ({ $surfaceColor, theme }: IStyledItemIcon & ThemeProps<Defa
/**
* 1. Odd sizing allows the timeline line to center respective of the circle icon.
*/
export const StyledItemIcon = styled(StyledBaseIcon).attrs({
export const StyledItemIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})<IStyledItemIcon>`
Expand Down
2 changes: 1 addition & 1 deletion packages/avatars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@zendeskgarden/react-dropdowns": "^9.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/avatars/src/elements/StatusIndicator.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('StatusIndicator', () => {
it('renders in RTL mode', () => {
const { getByRole } = renderRtl(<StatusIndicator type="transfers">Caption</StatusIndicator>);

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

Expand Down
16 changes: 8 additions & 8 deletions packages/avatars/src/styled/StyledAvatar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ describe('StyledAvatar', () => {
it('renders foreground color as expected', () => {
const { container } = render(<StyledAvatar $foregroundColor="red" />);

expect(container.firstChild).toHaveStyleRule('color', 'red', { modifier: '> svg' });
expect(container.firstChild).toHaveStyleRule('color', 'red', { modifier: '&>svg' });
});

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

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

expect(container.firstChild).toHaveStyleRule('width', '16px !important');
expect(container.firstChild).toHaveStyleRule('width', '16px!important');
});

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

expect(container.firstChild).toHaveStyleRule('width', '24px !important');
expect(container.firstChild).toHaveStyleRule('width', '24px!important');
});

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

expect(container.firstChild).toHaveStyleRule('width', '32px !important');
expect(container.firstChild).toHaveStyleRule('width', '32px!important');
});

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

expect(container.firstChild).toHaveStyleRule('width', '40px !important');
expect(container.firstChild).toHaveStyleRule('width', '40px!important');
});

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

expect(container.firstChild).toHaveStyleRule('width', '48px !important');
expect(container.firstChild).toHaveStyleRule('width', '48px!important');
});
});

describe('badge', () => {
const styleRuleOptions = {
modifier: `& > ${StyledStatusIndicator}`
modifier: `&>${StyledStatusIndicator}`
};

it('renders the status indicator correctly', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/breadcrumbs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@zendeskgarden/react-theming": "^9.2.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/breadcrumbs/src/elements/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React, { Children, cloneElement, forwardRef, HTMLAttributes } from 'react';
import ChevronRightStrokeIcon from '@zendeskgarden/svg-icons/src/12/chevron-right-stroke.svg';
import { useBreadcrumb } from '@zendeskgarden/container-breadcrumb';
import { useText } from '@zendeskgarden/react-theming';
import {
Expand Down Expand Up @@ -38,7 +39,9 @@ export const Breadcrumb = forwardRef<HTMLElement, HTMLAttributes<HTMLElement>>((
<>
<StyledBreadcrumbItem>{child}</StyledBreadcrumbItem>
<StyledCenteredBreadcrumbItem>
<StyledChevronIcon />
<StyledChevronIcon>
<ChevronRightStrokeIcon />
</StyledChevronIcon>
</StyledCenteredBreadcrumbItem>
</>
);
Expand Down
15 changes: 2 additions & 13 deletions packages/breadcrumbs/src/styled/StyledChevronIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,11 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

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

/**
* Accepts all `<svg>` props
*/
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export const StyledChevronIcon = styled(({ children, theme, ...props }) => (
<ChevronRightStrokeIcon {...props} />
)).attrs({
role: 'presentation',
'aria-hidden': 'true'
})`
export const StyledChevronIcon = styled(StyledBaseIcon)`
transform: ${p => p.theme.rtl && `rotate(180deg);`};
margin: 0 ${p => em(p.theme.space.base, p.theme.fontSizes.md)};
color: ${p => getColor({ variable: 'foreground.subtle', theme: p.theme })};
Expand Down
2 changes: 1 addition & 1 deletion packages/buttons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@zendeskgarden/react-theming": "^9.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/buttons/src/styled/StyledIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

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

const COMPONENT_ID = 'buttons.icon';

interface IStyledIconProps {
$isRotated: boolean;
$isRotated?: boolean;
$position?: 'start' | 'end';
}

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

export const StyledIcon = styled(StyledBaseIcon).attrs({
export const StyledIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})<IStyledIconProps>`
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@zendeskgarden/react-theming": "^9.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/chrome/src/elements/header/HeaderItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

import React from 'react';
import React, { HTMLAttributes, RefObject } from 'react';
import PropTypes from 'prop-types';
import { IHeaderItemProps, PRODUCTS } from '../../types';
import { StyledHeaderItem, StyledLogoHeaderItem } from '../../styled';
Expand All @@ -20,12 +20,12 @@ export const HeaderItem = React.forwardRef<HTMLButtonElement, IHeaderItemProps>(
if (hasLogo) {
return (
<StyledLogoHeaderItem
ref={ref}
ref={ref as RefObject<HTMLDivElement>}
$isRound={isRound}
$maxX={maxX}
$maxY={maxY}
$product={product}
{...other}
{...(other as HTMLAttributes<HTMLDivElement>)}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome/src/elements/nav/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { useMemo } from 'react';
import { ThemeProvider } from 'styled-components';
import { ThemeProvider } from '@zendeskgarden/react-theming';
import PropTypes from 'prop-types';
import { INavProps } from '../../types';
import { useChromeContext } from '../../utils/useChromeContext';
Expand Down
4 changes: 2 additions & 2 deletions packages/chrome/src/styled/header/StyledHeaderItemIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

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

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

export const StyledHeaderItemIcon = styled(StyledBaseIcon).attrs({
export const StyledHeaderItemIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})`
Expand Down
4 changes: 2 additions & 2 deletions packages/chrome/src/styled/nav/StyledNavItemIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

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

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

export const StyledNavItemIcon = styled(StyledBaseIcon).attrs({
export const StyledNavItemIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})`
Expand Down
2 changes: 1 addition & 1 deletion packages/colorpickers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@types/lodash.isequal": "4.5.8",
Expand Down
5 changes: 4 additions & 1 deletion packages/colorpickers/src/elements/ColorSwatch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import React, {
useRef,
useState
} from 'react';
import CheckIcon from '@zendeskgarden/svg-icons/src/12/check-sm-fill.svg';
import PropTypes from 'prop-types';
import { mergeRefs } from 'react-merge-refs';
import { ThemeContext } from 'styled-components';
Expand Down Expand Up @@ -150,7 +151,9 @@ export const ColorSwatch = forwardRef<HTMLTableElement, IColorSwatchProps>(
{...(gridCellProps as InputHTMLAttributes<HTMLInputElement>)}
/>
</Tooltip>
<StyledIcon />
<StyledIcon>
<CheckIcon />
</StyledIcon>
</StyledColorSwatchLabel>
</StyledCell>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const StyledColorSwatchLabel = styled(StyledButtonPreview).attrs({
as: 'label',
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})`
})<IStyledColorSwatchLabelProps>`
position: relative;
top: 0;
border-radius: ${props => props.theme.borderRadii.md};
Expand Down
7 changes: 3 additions & 4 deletions packages/colorpickers/src/styled/ColorSwatch/StyledIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

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

const COMPONENT_ID = 'colorpickers.colorswatch_check';

export const StyledIcon = styled(CheckIcon as 'svg').attrs({
export const StyledIcon = styled(StyledBaseIcon).attrs<DataAttributes>({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})`
Expand Down
2 changes: 1 addition & 1 deletion packages/datepickers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@zendeskgarden/react-theming": "^9.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/datepickers/src/styled/StyledMenuWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface IStyledMenuWrapperProps {
export const StyledMenuWrapper = styled.div.attrs<IStyledMenuWrapperProps>(props => ({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION,
className: props.$isAnimated && 'is-animated'
className: props.$isAnimated ? 'is-animated' : undefined
}))<IStyledMenuWrapperProps>`
top: 0; /* [1] */
left: 0; /* [1] */
Expand Down
2 changes: 1 addition & 1 deletion packages/draggable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@zendeskgarden/react-theming": ">=9.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.3.1"
"styled-components": "^5.3.1 || ^6.0.0"
},
"devDependencies": {
"@dnd-kit/core": "6.1.0",
Expand Down
Loading

0 comments on commit bc5c1d4

Please sign in to comment.