1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/components/component-library/avatar-account/avatar-account.tsx
Dhruv 9b55791af7
fix/migrate AvatarAccount to TS (#20208)
* migrating AvatarAccount to TS

* updates

* reverting changes to diameter

* suggested changes

* adding explicit types for AvatarAccountDiameter

* updating documentation

* Some small updates to types

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2023-08-01 14:19:32 -07:00

50 lines
1.3 KiB
TypeScript

import React from 'react';
import classnames from 'classnames';
import Jazzicon from '../../ui/jazzicon/jazzicon.component';
import BlockieIdenticon from '../../ui/identicon/blockieIdenticon/blockieIdenticon.component';
import type { PolymorphicRef } from '../box';
import { AvatarBase, AvatarBaseProps } from '../avatar-base';
import {
AvatarAccountDiameter,
AvatarAccountVariant,
AvatarAccountSize,
AvatarAccountComponent,
AvatarAccountProps,
} from './avatar-account.types';
export const AvatarAccount: AvatarAccountComponent = React.forwardRef(
<C extends React.ElementType = 'div'>(
{
size = AvatarAccountSize.Md,
address,
className = '',
variant = AvatarAccountVariant.Jazzicon,
...props
}: AvatarAccountProps<C>,
ref?: PolymorphicRef<C>,
) => (
<AvatarBase
ref={ref}
size={size}
className={classnames('mm-avatar-account', className)}
{...(props as AvatarBaseProps<C>)}
>
{variant === AvatarAccountVariant.Jazzicon ? (
<Jazzicon
className={classnames('mm-avatar-account__jazzicon')}
address={address}
diameter={AvatarAccountDiameter[size]}
/>
) : (
<BlockieIdenticon
address={address}
diameter={AvatarAccountDiameter[size]}
borderRadius="50%"
/>
)}
</AvatarBase>
),
);