mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
33 lines
837 B
TypeScript
33 lines
837 B
TypeScript
import React, { forwardRef } from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { Square } from '~/components/common/Square';
|
|
import { ImagePresets } from '~/constants/urls';
|
|
import { getURLFromString } from '~/utils/dom';
|
|
import { DivProps } from '~/utils/types';
|
|
|
|
import styles from './styles.module.scss';
|
|
|
|
interface Props extends DivProps {
|
|
url?: string;
|
|
username?: string;
|
|
size?: number;
|
|
preset?: typeof ImagePresets[keyof typeof ImagePresets];
|
|
}
|
|
|
|
const Avatar = forwardRef<HTMLDivElement, Props>(
|
|
({ url, username, size, className, preset = ImagePresets.avatar, ...rest }, ref) => {
|
|
return (
|
|
<Square
|
|
{...rest}
|
|
image={getURLFromString(url, preset)}
|
|
className={classNames(styles.avatar, className)}
|
|
size={size}
|
|
ref={ref}
|
|
/>
|
|
);
|
|
}
|
|
);
|
|
|
|
export { Avatar };
|