mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
refactor: add nice enter animation for notification badge (#17119)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Button, type ButtonProps } from "components/Button/Button";
|
||||
import { BellIcon } from "lucide-react";
|
||||
import { forwardRef } from "react";
|
||||
import { cn } from "utils/cn";
|
||||
import { UnreadBadge } from "./UnreadBadge";
|
||||
|
||||
type InboxButtonProps = {
|
||||
@@ -21,7 +22,11 @@ export const InboxButton = forwardRef<HTMLButtonElement, InboxButtonProps>(
|
||||
{unreadCount > 0 && (
|
||||
<UnreadBadge
|
||||
count={unreadCount}
|
||||
className="absolute top-0 right-0 -translate-y-1/2 translate-x-1/2"
|
||||
className={cn([
|
||||
"[--offset:calc(var(--unread-badge-size)/2)]",
|
||||
"absolute top-0 right-0 -mr-[--offset] -mt-[--offset]",
|
||||
"animate-in fade-in zoom-in duration-200",
|
||||
])}
|
||||
/>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
@@ -13,7 +13,8 @@ export const UnreadBadge: FC<UnreadBadgeProps> = ({
|
||||
return (
|
||||
<span
|
||||
className={cn([
|
||||
"flex min-w-[18px] h-[18px] w-fit px-1 rounded text-2xs items-center justify-center",
|
||||
"[--unread-badge-size:18px] min-w-[--unread-badge-size] h-[--unread-badge-size]",
|
||||
"flex w-fit px-1 rounded text-2xs items-center justify-center",
|
||||
"bg-surface-sky text-highlight-sky",
|
||||
className,
|
||||
])}
|
||||
|
||||
Reference in New Issue
Block a user