1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 22:24:27 +01:00
metamask-extension/ui/components/component-library/avatar-with-badge/avatar-with-badge.js

61 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import Box from '../../ui/box/box';
import { AVATAR_WITH_BADGE_POSTIONS } from './avatar-with-badge.constants';
export const AvatarWithBadge = ({
children,
badgePosition,
className,
badge,
badgeWrapperProps,
...props
}) => {
return (
<Box className={classnames('mm-avatar-with-badge', className)} {...props}>
{/* Generally the AvatarAccount */}
{children}
<Box
className={
badgePosition === 'top'
? 'mm-avatar-with-badge__badge-wrapper--position-top'
: 'mm-avatar-with-badge__badge-wrapper--position-bottom'
}
{...badgeWrapperProps}
>
{/* Generally the AvatarNetwork at SIZES.XS */}
{badge}
</Box>
</Box>
);
};
AvatarWithBadge.propTypes = {
/**
* The position of the Badge
* Possible values could be 'top', 'bottom',
*/
badgePosition: PropTypes.oneOf(Object.values(AVATAR_WITH_BADGE_POSTIONS)),
/**
* The Badge Wrapper props of the component. All Box props can be used
*/
badgeWrapperProps: PropTypes.shape(Box.PropTypes),
/**
* The children to be rendered inside the AvatarWithBadge
*/
children: PropTypes.node,
/**
* The badge to be rendered inside the AvatarWithBadge
*/
badge: PropTypes.object,
/**
* Add custom css class
*/
className: PropTypes.string,
/**
* AvatarWithBadge accepts all the props from Box
*/
...Box.propTypes,
};