1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

added empty avatar placeholder

This commit is contained in:
Fedor Katurov 2022-09-21 12:26:35 +07:00
parent 080d59858c
commit 8fc06a4819
6 changed files with 470 additions and 23 deletions

View file

@ -4,6 +4,7 @@ import classNames from 'classnames';
import { Square } from '~/components/common/Square';
import { ImagePresets } from '~/constants/urls';
import { useColorGradientFromString } from '~/hooks/color/useColorGradientFromString';
import { getURLFromString } from '~/utils/dom';
import { DivProps } from '~/utils/types';
@ -17,17 +18,20 @@ interface Props extends DivProps {
}
const Avatar = forwardRef<HTMLDivElement, Props>(
({ url, username, size, className, preset = ImagePresets.avatar, ...rest }, ref) => {
(
{ url, username, size, className, preset = ImagePresets.avatar, ...rest },
ref,
) => {
return (
<Square
{...rest}
image={getURLFromString(url, preset)}
image={getURLFromString(url, preset) || '/images/john_doe.svg'}
className={classNames(styles.avatar, className)}
size={size}
ref={ref}
/>
);
}
},
);
export { Avatar };