mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-15 19:50:28 +03:00
Refactor sidebar avatar component
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
e1a67acde1
commit
8f41139076
2 changed files with 54 additions and 63 deletions
|
|
@ -4,16 +4,13 @@ import './SidebarAvatar.scss';
|
|||
|
||||
import { twemojify } from '../../../util/twemojify';
|
||||
|
||||
import Avatar from '../../atoms/avatar/Avatar';
|
||||
import Text from '../../atoms/text/Text';
|
||||
import Tooltip from '../../atoms/tooltip/Tooltip';
|
||||
import NotificationBadge from '../../atoms/badge/NotificationBadge';
|
||||
import { blurOnBubbling } from '../../atoms/button/script';
|
||||
|
||||
const SidebarAvatar = React.forwardRef(({
|
||||
tooltip, text, bgColor, imageSrc,
|
||||
iconSrc, active, onClick, onContextMenu,
|
||||
isUnread, notificationCount, isAlert,
|
||||
tooltip, active, onClick, onContextMenu,
|
||||
avatar, notificationBadge,
|
||||
}, ref) => {
|
||||
let activeClass = '';
|
||||
if (active) activeClass = ' sidebar-avatar--active';
|
||||
|
|
@ -30,51 +27,26 @@ const SidebarAvatar = React.forwardRef(({
|
|||
onClick={onClick}
|
||||
onContextMenu={onContextMenu}
|
||||
>
|
||||
<Avatar
|
||||
text={text}
|
||||
bgColor={bgColor}
|
||||
imageSrc={imageSrc}
|
||||
iconSrc={iconSrc}
|
||||
size="normal"
|
||||
/>
|
||||
{ isUnread && (
|
||||
<NotificationBadge
|
||||
alert={isAlert}
|
||||
content={notificationCount !== 0 ? notificationCount : null}
|
||||
/>
|
||||
)}
|
||||
{avatar}
|
||||
{notificationBadge}
|
||||
</button>
|
||||
</Tooltip>
|
||||
);
|
||||
});
|
||||
SidebarAvatar.defaultProps = {
|
||||
text: null,
|
||||
bgColor: 'transparent',
|
||||
iconSrc: null,
|
||||
imageSrc: null,
|
||||
active: false,
|
||||
onClick: null,
|
||||
onContextMenu: null,
|
||||
isUnread: false,
|
||||
notificationCount: 0,
|
||||
isAlert: false,
|
||||
notificationBadge: null,
|
||||
};
|
||||
|
||||
SidebarAvatar.propTypes = {
|
||||
tooltip: PropTypes.string.isRequired,
|
||||
text: PropTypes.string,
|
||||
bgColor: PropTypes.string,
|
||||
imageSrc: PropTypes.string,
|
||||
iconSrc: PropTypes.string,
|
||||
active: PropTypes.bool,
|
||||
onClick: PropTypes.func,
|
||||
onContextMenu: PropTypes.func,
|
||||
isUnread: PropTypes.bool,
|
||||
notificationCount: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.number,
|
||||
]),
|
||||
isAlert: PropTypes.bool,
|
||||
avatar: PropTypes.node.isRequired,
|
||||
notificationBadge: PropTypes.node,
|
||||
};
|
||||
|
||||
export default SidebarAvatar;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue