Files
Athou_commafeed/commafeed-client/src/components/sidebar/UnreadCount.tsx

29 lines
982 B
TypeScript
Raw Normal View History

2025-05-12 16:30:06 -04:00
import { Badge, Indicator, Tooltip } from "@mantine/core"
2025-06-27 16:29:31 +02:00
import { Constants } from "@/app/constants"
import { tss } from "@/tss"
const useStyles = tss.create(() => ({
2025-05-12 16:30:06 -04:00
badge: {
width: "3.2rem",
2025-05-23 15:57:53 +02:00
// for some reason, mantine Badge has "cursor: 'default'"
2025-05-12 16:30:06 -04:00
cursor: "pointer",
},
}))
2025-05-23 15:57:53 +02:00
export function UnreadCount(props: { unreadCount: number; showIndicator: boolean }) {
2025-05-12 16:30:06 -04:00
const { classes } = useStyles()
2025-05-12 16:30:06 -04:00
if (props.unreadCount <= 0) return null
2025-05-12 16:30:06 -04:00
const count = props.unreadCount >= 10000 ? "10k+" : props.unreadCount
return (
<Tooltip label={props.unreadCount} disabled={props.unreadCount === count} openDelay={Constants.tooltip.delay}>
2025-05-23 15:57:53 +02:00
<Indicator disabled={!props.showIndicator} size={4} offset={10} position="middle-start">
2025-05-12 16:30:06 -04:00
<Badge className={`${classes.badge} cf-badge`} variant="light" fullWidth>
{count}
</Badge>
</Indicator>
</Tooltip>
)
}