mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-14 11:10:29 +03:00
Added unread symbol for Spaces, DMs and Home (#82)
This commit is contained in:
parent
fc0dc8aea0
commit
b07c50e580
14 changed files with 229 additions and 108 deletions
|
|
@ -84,7 +84,10 @@ RoomSelector.propTypes = {
|
|||
iconSrc: PropTypes.string,
|
||||
isSelected: PropTypes.bool,
|
||||
isUnread: PropTypes.bool.isRequired,
|
||||
notificationCount: PropTypes.number.isRequired,
|
||||
notificationCount: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.number,
|
||||
]).isRequired,
|
||||
isAlert: PropTypes.bool.isRequired,
|
||||
options: PropTypes.node,
|
||||
onClick: PropTypes.func.isRequired,
|
||||
|
|
|
|||
|
|
@ -2,29 +2,22 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import './SidebarAvatar.scss';
|
||||
|
||||
import Tippy from '@tippyjs/react';
|
||||
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, notifyCount,
|
||||
iconSrc, active, onClick, isUnread, notificationCount, isAlert,
|
||||
}, ref) => {
|
||||
let activeClass = '';
|
||||
if (active) activeClass = ' sidebar-avatar--active';
|
||||
return (
|
||||
<Tippy
|
||||
<Tooltip
|
||||
content={<Text variant="b1">{tooltip}</Text>}
|
||||
className="sidebar-avatar-tippy"
|
||||
touch="hold"
|
||||
arrow={false}
|
||||
placement="right"
|
||||
maxWidth={200}
|
||||
delay={[0, 0]}
|
||||
duration={[100, 0]}
|
||||
offset={[0, 0]}
|
||||
>
|
||||
<button
|
||||
ref={ref}
|
||||
|
|
@ -40,9 +33,14 @@ const SidebarAvatar = React.forwardRef(({
|
|||
iconSrc={iconSrc}
|
||||
size="normal"
|
||||
/>
|
||||
{ notifyCount !== null && <NotificationBadge alert content={notifyCount} /> }
|
||||
{ isUnread && (
|
||||
<NotificationBadge
|
||||
alert={isAlert}
|
||||
content={notificationCount !== 0 ? notificationCount : null}
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
</Tippy>
|
||||
</Tooltip>
|
||||
);
|
||||
});
|
||||
SidebarAvatar.defaultProps = {
|
||||
|
|
@ -52,7 +50,9 @@ SidebarAvatar.defaultProps = {
|
|||
imageSrc: null,
|
||||
active: false,
|
||||
onClick: null,
|
||||
notifyCount: null,
|
||||
isUnread: false,
|
||||
notificationCount: 0,
|
||||
isAlert: false,
|
||||
};
|
||||
|
||||
SidebarAvatar.propTypes = {
|
||||
|
|
@ -63,10 +63,12 @@ SidebarAvatar.propTypes = {
|
|||
iconSrc: PropTypes.string,
|
||||
active: PropTypes.bool,
|
||||
onClick: PropTypes.func,
|
||||
notifyCount: PropTypes.oneOfType([
|
||||
isUnread: PropTypes.bool,
|
||||
notificationCount: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.number,
|
||||
]),
|
||||
isAlert: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default SidebarAvatar;
|
||||
|
|
|
|||
|
|
@ -1,28 +1,18 @@
|
|||
|
||||
.sidebar-avatar-tippy {
|
||||
padding: var(--sp-extra-tight) var(--sp-normal);
|
||||
background-color: var(--bg-tooltip);
|
||||
border-radius: var(--bo-radius);
|
||||
box-shadow: var(--bs-popup);
|
||||
|
||||
.text {
|
||||
color: var(--tc-tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-avatar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
|
||||
& .notification-badge {
|
||||
position: absolute;
|
||||
right: var(--sp-extra-tight);
|
||||
top: calc(-1 * var(--sp-ultra-tight));
|
||||
right: 0;
|
||||
top: 0;
|
||||
box-shadow: 0 0 0 2px var(--bg-surface-low);
|
||||
transform: translate(20%, -20%);
|
||||
|
||||
margin: 0 !important;
|
||||
}
|
||||
&:focus {
|
||||
outline: none;
|
||||
|
|
@ -37,7 +27,7 @@
|
|||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
left: -11px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
|
||||
|
|
@ -48,7 +38,8 @@
|
|||
transition: height 200ms linear;
|
||||
|
||||
[dir=rtl] & {
|
||||
right: 0;
|
||||
left: unset;
|
||||
right: -11px;
|
||||
border-radius: 4px 0 0 4px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue