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';
|
2023-02-02 21:15:26 +01:00
|
|
|
import {
|
|
|
|
BackgroundColor,
|
|
|
|
BorderColor,
|
|
|
|
TextColor,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
2022-11-23 17:42:43 +01:00
|
|
|
import { AVATAR_BASE_SIZES } from './avatar-base.constants';
|
2022-08-01 11:44:33 +02:00
|
|
|
|
2022-11-23 17:42:43 +01:00
|
|
|
export const AvatarBase = ({
|
|
|
|
size = AVATAR_BASE_SIZES.MD,
|
2022-08-01 11:44:33 +02:00
|
|
|
children,
|
2023-02-02 21:15:26 +01:00
|
|
|
backgroundColor = BackgroundColor.backgroundAlternative,
|
|
|
|
borderColor = BorderColor.borderDefault,
|
|
|
|
color = TextColor.textDefault,
|
2022-08-18 18:30:19 +02:00
|
|
|
className,
|
2022-08-01 11:44:33 +02:00
|
|
|
...props
|
|
|
|
}) => (
|
|
|
|
<Box
|
2022-08-18 18:30:19 +02:00
|
|
|
className={classnames(
|
2022-11-23 17:42:43 +01:00
|
|
|
'mm-avatar-base',
|
|
|
|
`mm-avatar-base--size-${size}`,
|
2022-08-18 18:30:19 +02:00
|
|
|
className,
|
|
|
|
)}
|
|
|
|
{...{ backgroundColor, borderColor, color, ...props }}
|
2022-08-01 11:44:33 +02:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
2022-11-23 17:42:43 +01:00
|
|
|
AvatarBase.propTypes = {
|
2022-08-01 11:44:33 +02:00
|
|
|
/**
|
2022-11-23 17:42:43 +01:00
|
|
|
* The size of the AvatarBase.
|
|
|
|
* Possible values could be 'AVATAR_BASE_SIZES.XS'(16px), 'AVATAR_BASE_SIZES.SM'(24px), 'AVATAR_BASE_SIZES.MD'(32px), 'AVATAR_BASE_SIZES.LG'(40px), 'AVATAR_BASE_SIZES.XL'(48px)
|
|
|
|
* Defaults to AVATAR_BASE_SIZES.MD
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
2022-11-23 17:42:43 +01:00
|
|
|
size: PropTypes.oneOf(Object.values(AVATAR_BASE_SIZES)),
|
2022-08-01 11:44:33 +02:00
|
|
|
/**
|
2022-11-23 17:42:43 +01:00
|
|
|
* The children to be rendered inside the AvatarBase
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
|
|
|
children: PropTypes.node,
|
|
|
|
/**
|
2022-11-23 17:42:43 +01:00
|
|
|
* The background color of the AvatarBase
|
2023-02-14 18:33:04 +01:00
|
|
|
* Defaults to Color.backgroundAlternative
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
2023-03-16 21:18:00 +01:00
|
|
|
backgroundColor: PropTypes.oneOf(Object.values(BackgroundColor)),
|
2022-08-01 11:44:33 +02:00
|
|
|
/**
|
2022-11-23 17:42:43 +01:00
|
|
|
* The background color of the AvatarBase
|
2023-02-14 18:33:04 +01:00
|
|
|
* Defaults to Color.borderDefault
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
2023-03-16 21:18:00 +01:00
|
|
|
borderColor: PropTypes.oneOf(Object.values(BorderColor)),
|
2022-08-01 11:44:33 +02:00
|
|
|
/**
|
2022-11-23 17:42:43 +01:00
|
|
|
* The color of the text inside the AvatarBase
|
2023-02-02 21:15:26 +01:00
|
|
|
* Defaults to TextColor.textDefault
|
2022-08-18 18:30:19 +02:00
|
|
|
*/
|
2023-03-16 21:18:00 +01:00
|
|
|
color: PropTypes.oneOf(Object.values(TextColor)),
|
2022-08-18 18:30:19 +02:00
|
|
|
/**
|
|
|
|
* Additional classNames to be added to the AvatarToken
|
|
|
|
*/
|
|
|
|
className: PropTypes.string,
|
|
|
|
/**
|
2022-11-23 17:42:43 +01:00
|
|
|
* AvatarBase also accepts all Box props including but not limited to
|
2022-08-18 18:30:19 +02:00
|
|
|
* className, as(change root element of HTML element) and margin props
|
2022-08-01 11:44:33 +02:00
|
|
|
*/
|
|
|
|
...Box.propTypes,
|
|
|
|
};
|