2022-10-12 20:19:12 +02:00
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Box from '../../ui/box/box';
|
2022-12-21 20:06:40 +01:00
|
|
|
import { AVATAR_WITH_BADGE_POSTIONS } from './avatar-with-badge.constants';
|
2022-10-12 20:19:12 +02:00
|
|
|
|
|
|
|
export const AvatarWithBadge = ({
|
|
|
|
children,
|
|
|
|
badgePosition,
|
|
|
|
className,
|
|
|
|
badge,
|
|
|
|
badgeWrapperProps,
|
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
return (
|
2022-12-21 20:06:40 +01:00
|
|
|
<Box className={classnames('mm-avatar-with-badge', className)} {...props}>
|
2022-10-12 20:19:12 +02:00
|
|
|
{/* Generally the AvatarAccount */}
|
|
|
|
{children}
|
|
|
|
<Box
|
|
|
|
className={
|
|
|
|
badgePosition === 'top'
|
2022-12-21 20:06:40 +01:00
|
|
|
? 'mm-avatar-with-badge__badge-wrapper--position-top'
|
|
|
|
: 'mm-avatar-with-badge__badge-wrapper--position-bottom'
|
2022-10-12 20:19:12 +02:00
|
|
|
}
|
|
|
|
{...badgeWrapperProps}
|
|
|
|
>
|
|
|
|
{/* Generally the AvatarNetwork at SIZES.XS */}
|
|
|
|
{badge}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
AvatarWithBadge.propTypes = {
|
|
|
|
/**
|
|
|
|
* The position of the Badge
|
|
|
|
* Possible values could be 'top', 'bottom',
|
|
|
|
*/
|
2022-12-21 20:06:40 +01:00
|
|
|
badgePosition: PropTypes.oneOf(Object.values(AVATAR_WITH_BADGE_POSTIONS)),
|
2022-10-12 20:19:12 +02:00
|
|
|
/**
|
|
|
|
* 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,
|
2022-12-21 20:06:40 +01:00
|
|
|
/**
|
|
|
|
* AvatarWithBadge accepts all the props from Box
|
|
|
|
*/
|
|
|
|
...Box.propTypes,
|
2022-10-12 20:19:12 +02:00
|
|
|
};
|