mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🎨 feat: Create Avatars of Initials Locally (#1869)
This commit is contained in:
parent
4012dea4ab
commit
5f6d1f3db0
6 changed files with 477 additions and 32 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
CustomMinimalIcon,
|
||||
} from '~/components/svg';
|
||||
import { useAuthContext } from '~/hooks/AuthContext';
|
||||
import useAvatar from '~/hooks/Messages/useAvatar';
|
||||
import { IconProps } from '~/common';
|
||||
import { cn } from '~/utils';
|
||||
|
||||
|
|
@ -27,6 +28,8 @@ const Icon: React.FC<IconProps> = (props) => {
|
|||
assistantName,
|
||||
} = props;
|
||||
|
||||
const avatarSrc = useAvatar(user);
|
||||
|
||||
if (isCreatedByUser) {
|
||||
const username = user?.name || 'User';
|
||||
|
||||
|
|
@ -39,14 +42,7 @@ const Icon: React.FC<IconProps> = (props) => {
|
|||
}}
|
||||
className={cn('relative flex items-center justify-center', props.className ?? '')}
|
||||
>
|
||||
<img
|
||||
className="rounded-sm"
|
||||
src={
|
||||
user?.avatar ||
|
||||
`https://api.dicebear.com/6.x/initials/svg?seed=${username}&fontFamily=Verdana&fontSize=36`
|
||||
}
|
||||
alt="avatar"
|
||||
/>
|
||||
<img className="rounded-sm" src={user?.avatar || avatarSrc} alt="avatar" />
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue