-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add unread badge to sidebar collapser (#33897)
- Loading branch information
1 parent
4de6ea6
commit 92b6a50
Showing
10 changed files
with
260 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rocket.chat/meteor': minor | ||
--- | ||
|
||
adds unread badge to sidebar collapser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/meteor/client/sidebarv2/RoomList/RoomListCollapser.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { ISubscription } from '@rocket.chat/core-typings'; | ||
import { Badge, SidebarV2CollapseGroup } from '@rocket.chat/fuselage'; | ||
import type { HTMLAttributes, KeyboardEvent, MouseEventHandler } from 'react'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { useUnreadDisplay } from '../hooks/useUnreadDisplay'; | ||
|
||
type RoomListCollapserProps = { | ||
groupTitle: string; | ||
collapsedGroups: string[]; | ||
onClick: MouseEventHandler<HTMLElement>; | ||
onKeyDown: (e: KeyboardEvent) => void; | ||
unreadCount: Pick<ISubscription, 'userMentions' | 'groupMentions' | 'unread' | 'tunread' | 'tunreadUser' | 'tunreadGroup'>; | ||
} & Omit<HTMLAttributes<HTMLElement>, 'onClick' | 'onKeyDown'>; | ||
const RoomListCollapser = ({ groupTitle, unreadCount: unreadGroupCount, collapsedGroups, ...props }: RoomListCollapserProps) => { | ||
const { t } = useTranslation(); | ||
|
||
const { unreadTitle, unreadVariant, showUnread, unreadCount } = useUnreadDisplay(unreadGroupCount); | ||
|
||
return ( | ||
<SidebarV2CollapseGroup | ||
title={t(groupTitle)} | ||
expanded={!collapsedGroups.includes(groupTitle)} | ||
badge={ | ||
showUnread ? ( | ||
<Badge variant={unreadVariant} title={unreadTitle} aria-label={unreadTitle} role='status'> | ||
{unreadCount.total} | ||
</Badge> | ||
) : undefined | ||
} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export default RoomListCollapser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.