1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/components/component-library/avatar-account/avatar-account.js
Nidhi Kumari 67bfd446fc
avatar base component housekeeping (#16583)
* replace base avatar with avatar base component

* updated tests

* updated description for props

* updated docs and background colors

* updated snapshot

* replaced size with avatar size constant

* added tests and fixed indentation

* fixed indentation in readme
2022-11-23 22:12:43 +05:30

55 lines
1.5 KiB
JavaScript

import React from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import Jazzicon from '../../ui/jazzicon/jazzicon.component';
import BlockieIdenticon from '../../ui/identicon/blockieIdenticon/blockieIdenticon.component';
import { AvatarBase } from '../avatar-base';
import { SIZES } from '../../../helpers/constants/design-system';
import { DIAMETERS, TYPES } from './avatar-account.constants';
export const AvatarAccount = ({ size, address, className, type, ...props }) => {
return (
<AvatarBase
size={size}
className={classnames('avatar-account', className)}
{...props}
>
{type === 'Jazzicon' ? (
<Jazzicon
className={classnames('avatar-account__jazzicon')}
address={address}
diameter={DIAMETERS[size]}
/>
) : (
<BlockieIdenticon
address={address}
diameter={DIAMETERS[size]}
borderRadius="50%"
/>
)}
</AvatarBase>
);
};
AvatarAccount.propTypes = {
/**
* The size of the AvatarAccount.
* Possible values could be 'SIZES.XS', 'SIZES.SM', 'SIZES.MD', 'SIZES.LG', 'SIZES.XL'
* Defaults to SIZES.MD
*/
size: PropTypes.oneOf(Object.values(SIZES)),
/**
* The type of the avatar to be rendered, it can render either a Jazzicon or a Blockie
*/
type: PropTypes.oneOf(Object.values(TYPES)),
/**
* Address used for generating random image
*/
address: PropTypes.string,
/**
* Add custom css class
*/
className: PropTypes.string,
};