Skip to content

Commit 514bd5a

Browse files
author
Simon Taggart
authored
fix(icon) correctly type the size prop (#1299)
* fix(icons): correct size prop typings * chore: changeset * fix(icons): make size optional
1 parent 6e40d59 commit 514bd5a

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

.changeset/purple-grapes-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@twilio-paste/theme': patch
3+
---
4+
5+
Correctly type the generic theme type to only include icon sizes in the iconSizes key

.changeset/wicked-trees-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@twilio-paste/icons': patch
3+
---
4+
5+
Correctly type the size prop to use the icons sizes from style props and not from box

packages/paste-icons/build.icon-list.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/paste-icons/src/helpers/IconWrapper.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import * as React from 'react';
22
import {Box, safelySpreadBoxProps} from '@twilio-paste/box';
33
import type {BoxElementProps, BoxStyleProps} from '@twilio-paste/box';
4+
import type {IconSize} from '@twilio-paste/style-props';
45

5-
export interface IconWrapperProps extends BoxElementProps, Pick<BoxStyleProps, 'display' | 'size' | 'color'> {}
6+
export interface IconWrapperProps extends BoxElementProps, Pick<BoxStyleProps, 'display' | 'color'> {
7+
size?: IconSize;
8+
}
69

710
const IconWrapper: React.FC<IconWrapperProps> = ({display, color, size, ...props}) => {
811
return <Box {...safelySpreadBoxProps(props)} lineHeight="lineHeight0" display={display} color={color} size={size} />;

packages/paste-theme/src/types/GenericThemeShape.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,19 @@ export interface GenericThemeShape {
5454
[key in keyof typeof sizings]: any;
5555
}
5656
>;
57-
iconSizes: Partial<
58-
{
59-
[key in keyof typeof sizings]: any;
60-
}
61-
>;
57+
iconSizes: {
58+
sizeIcon10: typeof sizings['sizeIcon10'];
59+
sizeIcon20: typeof sizings['sizeIcon20'];
60+
sizeIcon30: typeof sizings['sizeIcon30'];
61+
sizeIcon40: typeof sizings['sizeIcon40'];
62+
sizeIcon50: typeof sizings['sizeIcon50'];
63+
sizeIcon60: typeof sizings['sizeIcon60'];
64+
sizeIcon70: typeof sizings['sizeIcon70'];
65+
sizeIcon80: typeof sizings['sizeIcon80'];
66+
sizeIcon90: typeof sizings['sizeIcon90'];
67+
sizeIcon100: typeof sizings['sizeIcon100'];
68+
sizeIcon110: typeof sizings['sizeIcon110'];
69+
};
6270
lineHeights: Partial<
6371
{
6472
[key in keyof typeof lineHeights]: any;

0 commit comments

Comments
 (0)