2022-08-01 11:44:33 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
2022-08-18 18:30:19 +02:00
|
|
|
|
2022-08-01 11:44:33 +02:00
|
|
|
import Box from '../../ui/box/box';
|
|
|
|
import { COLORS, SIZES } from '../../../helpers/constants/design-system';
|
|
|
|
|
|
|
|
export const BaseAvatar = ({
|
|
|
|
size = SIZES.MD,
|
|
|
|
children,
|
|
|
|
backgroundColor = COLORS.BACKGROUND_ALTERNATIVE,
|
|
|
|
borderColor = COLORS.BORDER_DEFAULT,
|
2022-08-18 18:30:19 +02:00
|
|
|
color = COLORS.TEXT_DEFAULT,
|
|
|
|
className,
|
2022-08-01 11:44:33 +02:00
|
|
|
...props
|
|
|
|
}) => (
|
|
|
|
<Box
|
2022-08-18 18:30:19 +02:00
|
|
|
className={classnames(
|
|
|
|
'base-avatar',
|
|
|
|
`base-avatar--size-${size}`,
|
|
|
|
className,
|
|
|
|
)}
|
|
|
|
{...{ backgroundColor, borderColor, color, ...props }}
|
2022-08-01 11:44:33 +02:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
|
|
|
BaseAvatar.propTypes = {
|
|
|
|
/**
|
|
|
|
* The size of the BaseAvatar.
|
2022-08-18 18:30:19 +02:00
|
|
|
* Possible values could be 'SIZES.XS', 'SIZES.SM', 'SIZES.MD', 'SIZES.LG', 'SIZES.XL'
|
|
|
|
* Defaults to SIZES.MD
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
|
|
|
size: PropTypes.oneOf(Object.values(SIZES)),
|
|
|
|
/**
|
|
|
|
* The children to be rendered inside the BaseAvatar
|
|
|
|
*/
|
|
|
|
children: PropTypes.node,
|
|
|
|
/**
|
|
|
|
* The background color of the BaseAvatar
|
2022-08-18 18:30:19 +02:00
|
|
|
* Defaults to COLORS.BACKGROUND_ALTERNATIVE
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
|
|
|
backgroundColor: Box.propTypes.backgroundColor,
|
|
|
|
/**
|
|
|
|
* The background color of the BaseAvatar
|
2022-08-18 18:30:19 +02:00
|
|
|
* Defaults to COLORS.BORDER_DEFAULT
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
|
|
|
borderColor: Box.propTypes.borderColor,
|
|
|
|
/**
|
2022-08-18 18:30:19 +02:00
|
|
|
* The color of the text inside the BaseAvatar
|
|
|
|
* Defaults to COLORS.TEXT_DEFAULT
|
|
|
|
*/
|
|
|
|
color: Box.propTypes.color,
|
|
|
|
/**
|
|
|
|
* Additional classNames to be added to the AvatarToken
|
|
|
|
*/
|
|
|
|
className: PropTypes.string,
|
|
|
|
/**
|
|
|
|
* BaseAvatar also accepts all Box props including but not limited to
|
|
|
|
* className, as(change root element of HTML element) and margin props
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
|
|
|
...Box.propTypes,
|
|
|
|
};
|