2023-12-29 21:53:41 +01:00
|
|
|
import { Badge, Tooltip } from "@mantine/core"
|
2024-04-14 11:26:39 +02:00
|
|
|
import { Constants } from "app/constants"
|
2023-12-29 21:53:41 +01:00
|
|
|
import { tss } from "tss"
|
2022-08-13 10:56:07 +02:00
|
|
|
|
2023-12-29 21:53:41 +01:00
|
|
|
const useStyles = tss.create(() => ({
|
2022-08-13 10:56:07 +02:00
|
|
|
badge: {
|
|
|
|
|
width: "3.2rem",
|
|
|
|
|
// for some reason, mantine Badge has "cursor: 'default'"
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
},
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
export function UnreadCount(props: { unreadCount: number }) {
|
|
|
|
|
const { classes } = useStyles()
|
|
|
|
|
|
|
|
|
|
if (props.unreadCount <= 0) return null
|
|
|
|
|
|
2023-09-23 16:43:22 +02:00
|
|
|
const count = props.unreadCount >= 10000 ? "10k+" : props.unreadCount
|
|
|
|
|
return (
|
2024-04-14 11:26:39 +02:00
|
|
|
<Tooltip label={props.unreadCount} disabled={props.unreadCount === count} openDelay={Constants.tooltip.delay}>
|
2023-12-29 23:09:30 +01:00
|
|
|
<Badge className={classes.badge} variant="light">
|
|
|
|
|
{count}
|
|
|
|
|
</Badge>
|
2023-09-23 16:43:22 +02:00
|
|
|
</Tooltip>
|
|
|
|
|
)
|
2022-08-13 10:56:07 +02:00
|
|
|
}
|