Skip to content

Commit fc5ef83

Browse files
committed
feat: adds StyledBaseIcon to typography
1 parent 55ed476 commit fc5ef83

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

packages/typography/src/elements/span/StartIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React, { SVGAttributes } from 'react';
99
import { StyledIcon } from '../../styled';
1010

11-
const StartIconComponent = (props: SVGAttributes<SVGElement>) => <StyledIcon isStart {...props} />;
11+
const StartIconComponent = (props: SVGAttributes<SVGElement>) => <StyledIcon $isStart {...props} />;
1212

1313
StartIconComponent.displayName = 'Span.StartIcon';
1414

packages/typography/src/styled/StyledIcon.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('StyledIcon', () => {
3333

3434
it('renders start styling if provided', () => {
3535
const { container } = render(
36-
<StyledIcon isStart>
36+
<StyledIcon $isStart>
3737
<TestIcon />
3838
</StyledIcon>
3939
);
@@ -43,7 +43,7 @@ describe('StyledIcon', () => {
4343

4444
it('renders expected RTL styling', () => {
4545
const { container } = renderRtl(
46-
<StyledIcon isStart>
46+
<StyledIcon $isStart>
4747
<TestIcon />
4848
</StyledIcon>
4949
);

packages/typography/src/styled/StyledIcon.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66
*/
77

88
import styled, { css, ThemeProps, DefaultTheme } from 'styled-components';
9-
import React, { Children } from 'react';
10-
import { DEFAULT_THEME, retrieveComponentStyles } from '@zendeskgarden/react-theming';
9+
import {
10+
DEFAULT_THEME,
11+
StyledBaseIcon,
12+
retrieveComponentStyles
13+
} from '@zendeskgarden/react-theming';
1114

1215
const COMPONENT_ID = 'typography.icon';
1316

1417
interface IStyledIconProps {
15-
isStart?: boolean;
18+
$isStart?: boolean;
1619
}
1720

1821
const sizeStyles = (props: IStyledIconProps & ThemeProps<DefaultTheme>) => {
19-
const margin = props.isStart && `${props.theme.space.base * 2}px`;
22+
const margin = props.$isStart && `${props.theme.space.base * 2}px`;
2023
const size = props.theme.iconSizes.md;
2124

2225
return css`
@@ -27,10 +30,7 @@ const sizeStyles = (props: IStyledIconProps & ThemeProps<DefaultTheme>) => {
2730
`;
2831
};
2932

30-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
31-
export const StyledIcon = styled(({ children, isStart, ...props }) =>
32-
React.cloneElement(Children.only(children), props)
33-
).attrs({
33+
export const StyledIcon = styled(StyledBaseIcon).attrs({
3434
'data-garden-id': COMPONENT_ID,
3535
'data-garden-version': PACKAGE_VERSION
3636
})<IStyledIconProps>`

0 commit comments

Comments
 (0)