Skip to content

Commit

Permalink
✨ feat(avatar): Add default values for background prop and modify siz…
Browse files Browse the repository at this point in the history
…e of FluentEmoji component

This commit introduces new features to the Avatar component. Default values are
now added for the background prop, providing a fallback if not specified. The
size of the FluentEmoji component is now modified based on the size prop.

Changes Made:
- Added default values for the background prop in the Avatar component
- Modified the size of the FluentEmoji component based on the size prop
  • Loading branch information
canisminor1990 committed Jul 24, 2023
1 parent 74a7847 commit 4b7d547
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ export interface AvatarProps extends AntAvatarProps {
}

const Avatar = memo<AvatarProps>(
({ className, avatar, title, size = 40, shape = 'circle', background, ...props }) => {
({
className,
avatar,
title,
size = 40,
shape = 'circle',
background = 'rgba(0,0,0,0)',
...props
}) => {
const isImage = Boolean(
avatar && ['/', 'http', 'data:'].some((index) => avatar.startsWith(index)),
);
Expand All @@ -52,7 +60,7 @@ const Avatar = memo<AvatarProps>(
/>
) : (
<AntAvatar className={cx(styles.avatar, className)} shape={shape} size={size} {...props}>
{emoji ? <FluentEmoji emoji={emoji} size={size} /> : text?.toUpperCase().slice(0, 2)}
{emoji ? <FluentEmoji emoji={emoji} size={size * 0.8} /> : text?.toUpperCase().slice(0, 2)}
</AntAvatar>
);
},
Expand Down

1 comment on commit 4b7d547

@vercel
Copy link

@vercel vercel bot commented on 4b7d547 Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lobe-ui – ./

lobe-ui-git-master-lobehub.vercel.app
ui.lobehub.com
lobe-ui-lobehub.vercel.app
lobe-ui.vercel.app

Please sign in to comment.