-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adding avatar icon to design system react #420
base: main
Are you sure you want to change the base?
Conversation
22409f2
to
05ca7f6
Compare
export const AVATAR_ICON_SIZE_TO_ICON_SIZE_CLASSNAME_MAP: Record< | ||
AvatarIconSize, | ||
IconSize | ||
> = { | ||
[AvatarIconSize.Xs]: IconSize.Xs, // 16px avatar -> 12px icon | ||
[AvatarIconSize.Sm]: IconSize.Sm, // 24px avatar -> 16px icon | ||
[AvatarIconSize.Md]: IconSize.Md, // 32px avatar -> 20px icon | ||
[AvatarIconSize.Lg]: IconSize.Lg, // 40px avatar -> 24px icon | ||
[AvatarIconSize.Xl]: IconSize.Xl, // 48px avatar -> 32px icon | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maps avatar size to icon size
export const AVATAR_ICON_SEVERITY_CLASSNAME_MAP: Record< | ||
AvatarIconSeverity, | ||
{ background: string; iconColor: IconColor } | ||
> = { | ||
[AvatarIconSeverity.Default]: { | ||
background: 'bg-background-muted', | ||
iconColor: IconColor.IconAlternative, | ||
}, | ||
[AvatarIconSeverity.Info]: { | ||
background: 'bg-info-muted', | ||
iconColor: IconColor.InfoDefault, | ||
}, | ||
[AvatarIconSeverity.Success]: { | ||
background: 'bg-success-muted', | ||
iconColor: IconColor.SuccessDefault, | ||
}, | ||
[AvatarIconSeverity.Error]: { | ||
background: 'bg-error-muted', | ||
iconColor: IconColor.ErrorDefault, | ||
}, | ||
[AvatarIconSeverity.Warning]: { | ||
background: 'bg-warning-muted', | ||
iconColor: IconColor.WarningDefault, | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maps severity prop to icon color and background color
export const AVATAR_ICON_TO_AVATAR_BASE_SIZE_MAP: Record< | ||
AvatarIconSize, | ||
AvatarBaseSize | ||
> = { | ||
[AvatarIconSize.Xs]: AvatarBaseSize.Xs, | ||
[AvatarIconSize.Sm]: AvatarBaseSize.Sm, | ||
[AvatarIconSize.Md]: AvatarBaseSize.Md, | ||
[AvatarIconSize.Lg]: AvatarBaseSize.Lg, | ||
[AvatarIconSize.Xl]: AvatarBaseSize.Xl, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mapping the new AvatarIconSize
enum to AvatarBaseSize
. The circular dependency issue has finally caught up with me, so I'll stop exporting as
—it seems to be causing circular dependencies and undefined issues.
export enum AvatarIconSize { | ||
/** | ||
* Extra small size (16px) | ||
*/ | ||
Xs = 'xs', | ||
/** | ||
* Small size (24px) | ||
*/ | ||
Sm = 'sm', | ||
/** | ||
* Medium size (32px) | ||
*/ | ||
Md = 'md', | ||
/** | ||
* Large size (40px) | ||
*/ | ||
Lg = 'lg', | ||
/** | ||
* Extra large size (48px) | ||
*/ | ||
Xl = 'xl', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, I exported AvatarBaseSize as AvatarIconSize
from the AvatarIcon
index, but it caused circular dependencies. After some consideration, I think this is bad practice and could lead to issues, so we'll need to revert to defining individual enums.
05ca7f6
to
c93ba9e
Compare
|
||
# AvatarIcon | ||
|
||
Avatar reserved for representing static icons inside of an avatar. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description matches figma
|
||
Avatar reserved for representing static icons inside of an avatar. | ||
|
||
> Note: For icon buttons, use the [ButtonIcon](/docs/react-components-buttonicon--docs) component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding not as per the insight report
@@ -38,3 +38,6 @@ export type { ButtonIconProps } from './button-icon'; | |||
|
|||
export { AvatarBase, AvatarBaseSize } from './avatar-base'; | |||
export type { AvatarBaseProps } from './avatar-base'; | |||
|
|||
export { AvatarIcon, AvatarIconSize, AvatarIconSeverity } from './avatar-icon'; | |||
export type { AvatarIconProps } from './avatar-icon'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exporting from root index
Description
This PR adds
AvatarIcon
to design system reactThe component is built on top of the existing
AvatarBase
andIcon
components, ensuring consistency with the design system.Related issues
Fixes: #370
Manual testing steps
Screenshots/Recordings
Before
N/A (New component)
After
after720.mov
Pre-merge author checklist
Pre-merge reviewer checklist