Skip to content

Commit 8b1ee34

Browse files
committed
fix(Icon): pass stroke width
1 parent 24d5061 commit 8b1ee34

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/icons/Icon.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo } from 'react';
1+
import { ForwardedRef, forwardRef, memo } from 'react';
22

33
import {
44
BASE_STYLES,
@@ -11,6 +11,7 @@ import {
1111
Styles,
1212
tasty,
1313
} from '../tasty';
14+
import { mergeProps } from '../utils/react/index';
1415

1516
const IconElement = tasty({
1617
as: 'span',
@@ -29,6 +30,7 @@ const IconElement = tasty({
2930
'& svg': {
3031
width: '1em 1em',
3132
height: 'min 1em',
33+
strokeWidth: '@stroke-width',
3234
},
3335
},
3436
styleProps: [...OUTER_STYLES, ...BASE_STYLES, ...COLOR_STYLES],
@@ -40,16 +42,24 @@ export interface CubeIconProps
4042
ColorStyleProps,
4143
BaseStyleProps {
4244
size?: Styles['fontSize'];
45+
stroke?: number;
4346
}
4447

45-
export const Icon = memo(function Icon(props: CubeIconProps) {
46-
const { size, styles, ...rest } = props;
48+
export const Icon = memo(
49+
forwardRef(function Icon(
50+
props: CubeIconProps,
51+
ref: ForwardedRef<HTMLSpanElement>,
52+
) {
53+
const { size, styles, stroke, ...rest } = props;
4754

48-
return (
49-
<IconElement
50-
qa="Icon"
51-
{...rest}
52-
styles={size ? { fontSize: size, ...styles } : styles}
53-
/>
54-
);
55-
});
55+
const mergedProps =
56+
size != null && stroke != null
57+
? mergeProps(rest, {
58+
...(size ? { fontSize: size } : {}),
59+
...(stroke ? { '@stroke-width': stroke } : {}),
60+
})
61+
: rest;
62+
63+
return <IconElement ref={ref} qa="Icon" {...mergedProps} />;
64+
}),
65+
);

0 commit comments

Comments
 (0)