mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
3ec2c189b0
Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Brad Decker <bhdecker84@gmail.com>
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import React, { forwardRef, Ref } from 'react';
|
|
import classnames from 'classnames';
|
|
|
|
import {
|
|
BackgroundColor,
|
|
BorderColor,
|
|
TextColor,
|
|
Display,
|
|
JustifyContent,
|
|
AlignItems,
|
|
BorderRadius,
|
|
TextVariant,
|
|
TextTransform,
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import { Text, ValidTag } from '../text';
|
|
|
|
import { AvatarBaseProps, AvatarBaseSize } from './avatar-base.types';
|
|
|
|
export const AvatarBase = forwardRef(
|
|
(
|
|
{
|
|
size = AvatarBaseSize.Md,
|
|
children,
|
|
backgroundColor = BackgroundColor.backgroundAlternative,
|
|
borderColor = BorderColor.borderDefault,
|
|
color = TextColor.textDefault,
|
|
className = '',
|
|
...props
|
|
}: AvatarBaseProps,
|
|
ref: Ref<HTMLElement>,
|
|
) => {
|
|
let fallbackTextVariant;
|
|
|
|
if (size === AvatarBaseSize.Lg || size === AvatarBaseSize.Xl) {
|
|
fallbackTextVariant = TextVariant.bodyLgMedium;
|
|
} else if (size === AvatarBaseSize.Sm || size === AvatarBaseSize.Md) {
|
|
fallbackTextVariant = TextVariant.bodySm;
|
|
} else {
|
|
fallbackTextVariant = TextVariant.bodyXs;
|
|
}
|
|
return (
|
|
<Text
|
|
className={classnames(
|
|
'mm-avatar-base',
|
|
`mm-avatar-base--size-${size}`,
|
|
className,
|
|
)}
|
|
ref={ref}
|
|
as={ValidTag.Div}
|
|
display={Display.Flex}
|
|
justifyContent={JustifyContent.center}
|
|
alignItems={AlignItems.center}
|
|
borderRadius={BorderRadius.full}
|
|
variant={fallbackTextVariant}
|
|
textTransform={TextTransform.Uppercase}
|
|
{...{ backgroundColor, borderColor, color, ...props }}
|
|
>
|
|
{children}
|
|
</Text>
|
|
);
|
|
},
|
|
);
|