Skip to content

Commit 2b59cfa

Browse files
refactor: add nice enter animation for notification badge (coder#17119)
1 parent 5bd2a3f commit 2b59cfa

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

site/src/modules/notifications/NotificationsInbox/InboxButton.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Button, type ButtonProps } from "components/Button/Button";
22
import { BellIcon } from "lucide-react";
33
import { forwardRef } from "react";
4+
import { cn } from "utils/cn";
45
import { UnreadBadge } from "./UnreadBadge";
56

67
type InboxButtonProps = {
@@ -21,7 +22,11 @@ export const InboxButton = forwardRef<HTMLButtonElement, InboxButtonProps>(
2122
{unreadCount > 0 && (
2223
<UnreadBadge
2324
count={unreadCount}
24-
className="absolute top-0 right-0 -translate-y-1/2 translate-x-1/2"
25+
className={cn([
26+
"[--offset:calc(var(--unread-badge-size)/2)]",
27+
"absolute top-0 right-0 -mr-[--offset] -mt-[--offset]",
28+
"animate-in fade-in zoom-in duration-200",
29+
])}
2530
/>
2631
)}
2732
</Button>

site/src/modules/notifications/NotificationsInbox/UnreadBadge.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const UnreadBadge: FC<UnreadBadgeProps> = ({
1313
return (
1414
<span
1515
className={cn([
16-
"flex min-w-[18px] h-[18px] w-fit px-1 rounded text-2xs items-center justify-center",
16+
"[--unread-badge-size:18px] min-w-[--unread-badge-size] h-[--unread-badge-size]",
17+
"flex w-fit px-1 rounded text-2xs items-center justify-center",
1718
"bg-surface-sky text-highlight-sky",
1819
className,
1920
])}

0 commit comments

Comments
 (0)