add `Badge` component

This commit is contained in:
Felicio Mununga 2022-08-24 11:01:00 +02:00
parent 0ced78661c
commit 214df58a14
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
1 changed files with 14 additions and 12 deletions

View File

@ -20,6 +20,7 @@ const ChatItem = (props: Props, ref: Ref<HTMLAnchorElement>) => {
const muted = false const muted = false
const unread = unreadChats.has(chat.id) const unread = unreadChats.has(chat.id)
const count = unreadChats.get(chat.id)?.count
const { color, displayName } = chat.identity! const { color, displayName } = chat.identity!
@ -30,6 +31,7 @@ const ChatItem = (props: Props, ref: Ref<HTMLAnchorElement>) => {
state={muted ? 'muted' : unread ? 'unread' : undefined} state={muted ? 'muted' : unread ? 'unread' : undefined}
> >
<Avatar size={24} name={displayName} color={color} />#{displayName} <Avatar size={24} name={displayName} color={color} />#{displayName}
{count > 0 && <Badge>{count}</Badge>}
</Link> </Link>
) )
} }
@ -69,19 +71,19 @@ const Link = styled(NavLink, {
unread: { unread: {
color: '$accent-1', color: '$accent-1',
fontWeight: '$600', fontWeight: '$600',
// '&::after': {
// content: '"1"',
// textAlign: 'center',
// position: 'absolute',
// right: 8,
// width: 22,
// height: 22,
// background: '$primary-1',
// borderRadius: '$full',
// fontSize: 12,
// color: '$accent-11',
// },
}, },
}, },
}, },
}) })
const Badge = styled('div', {
textAlign: 'center',
position: 'absolute',
right: 8,
width: 22,
height: 22,
background: '$primary-1',
borderRadius: '$full',
fontSize: 12,
color: '$accent-11',
})