Skip to content

Commit

Permalink
fix(avatar types): make size prop optional to match previous api surf…
Browse files Browse the repository at this point in the history
…ace with defaultProps in TAvatarProps, update avatar styles to assert that the size prop will always be assigned due to default param assignment
  • Loading branch information
ByronDWall committed Jan 21, 2025
1 parent cbb21cd commit ca0403a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 26 deletions.
6 changes: 6 additions & 0 deletions .changeset/curly-rings-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-uikit/data-table': patch
'@commercetools-uikit/avatar': patch
---

Update TAvatarProps.size type to be optional for backward compatibility, update readmes
4 changes: 2 additions & 2 deletions packages/components/avatar/src/avatar.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export const getFontSize = (
avatarSize: TAvatarProps['size']
) => {
const widthCode = avatarInitials.length > 1 ? 'wide' : 'narrow';
return fontSizeMap[avatarSize][widthCode];
return fontSizeMap[avatarSize!][widthCode];
};

export const getWidthSize = (avatarSize: TAvatarProps['size']) =>
widthSizeMap[avatarSize];
widthSizeMap[avatarSize!];

export const getBackgroundColor = (
avatarColor: TAvatarProps['color'] = 'accent',
Expand Down
2 changes: 1 addition & 1 deletion packages/components/avatar/src/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type TAvatarProps = {
/**
* The size of the rendered avatar.
*/
size: 's' | 'm' | 'l';
size?: 's' | 'm' | 'l';
/**
* The color of the avatar.
*/
Expand Down
Loading

0 comments on commit ca0403a

Please sign in to comment.