2022-06-19 17:46:15 +00:00
|
|
|
import BoringAvatar, { AvatarProps } from 'boring-avatars';
|
|
|
|
import { useStoreState } from '@/state/hooks';
|
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
const palette = ['#FFAD08', '#EDD75A', '#73B06F', '#0C8F8F', '#587291'];
|
2022-06-19 17:46:15 +00:00
|
|
|
|
|
|
|
type Props = Omit<AvatarProps, 'colors'>;
|
|
|
|
|
|
|
|
const _Avatar = ({ variant = 'beam', ...props }: AvatarProps) => (
|
2022-06-26 19:13:52 +00:00
|
|
|
<BoringAvatar colors={palette} variant={variant} {...props} />
|
2022-06-19 17:46:15 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const _UserAvatar = ({ variant = 'beam', ...props }: Omit<Props, 'name'>) => {
|
2022-11-25 20:25:03 +00:00
|
|
|
const uuid = useStoreState(state => state.user.data?.uuid);
|
2022-06-19 17:46:15 +00:00
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
return <BoringAvatar colors={palette} name={uuid || 'system'} variant={variant} {...props} />;
|
2022-06-19 17:46:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_Avatar.displayName = 'Avatar';
|
|
|
|
_UserAvatar.displayName = 'Avatar.User';
|
|
|
|
|
|
|
|
const Avatar = Object.assign(_Avatar, {
|
|
|
|
User: _UserAvatar,
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Avatar;
|