2025-05-12 16:30:06 -04:00
|
|
|
import { Badge, Indicator, Tooltip } from "@mantine/core"
|
|
|
|
|
import { Constants } from "app/constants"
|
|
|
|
|
import { tss } from "tss"
|
2024-06-13 21:54:14 +02:00
|
|
|
|
|
|
|
|
const useStyles = tss.create(() => ({
|
2025-05-12 16:30:06 -04:00
|
|
|
badge: {
|
|
|
|
|
width: "3.2rem",
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
},
|
|
|
|
|
}))
|
2024-06-13 21:54:14 +02:00
|
|
|
|
2025-05-18 00:03:28 -04:00
|
|
|
export function UnreadCount(props: { unreadCount: number; newMessages: boolean | undefined }) {
|
2025-05-12 16:30:06 -04:00
|
|
|
const { classes } = useStyles()
|
2024-06-13 21:54:14 +02:00
|
|
|
|
2025-05-12 16:30:06 -04:00
|
|
|
if (props.unreadCount <= 0) return null
|
2024-06-13 21:54:14 +02:00
|
|
|
|
2025-05-12 16:30:06 -04:00
|
|
|
const count = props.unreadCount >= 10000 ? "10k+" : props.unreadCount
|
2025-05-10 14:16:34 -04:00
|
|
|
|
2025-05-12 16:30:06 -04:00
|
|
|
return (
|
|
|
|
|
<Tooltip label={props.unreadCount} disabled={props.unreadCount === count} openDelay={Constants.tooltip.delay}>
|
|
|
|
|
<Indicator disabled={!props.newMessages} size={4} offset={10} position="top-start" color="orange" withBorder={false} zIndex={5}>
|
|
|
|
|
<Badge className={`${classes.badge} cf-badge`} variant="light" fullWidth>
|
|
|
|
|
{count}
|
|
|
|
|
</Badge>
|
|
|
|
|
</Indicator>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
)
|
2024-06-13 21:54:14 +02:00
|
|
|
}
|