Files
ironmount/app/client/components/status-dot.tsx
Nico 6c30e7e357 Feat/notifications alerts (#52)
* feat: notifications backend & creation

* feat: assign notification to backup schedule

* refactor: status dot one component

* chore(notification-details): remove refetchInterval
2025-11-22 14:58:21 +01:00

62 lines
1.4 KiB
TypeScript

import { cn } from "~/client/lib/utils";
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
type StatusVariant = "success" | "neutral" | "error" | "warning" | "info";
interface StatusDotProps {
variant: StatusVariant;
label: string;
animated?: boolean;
}
export const StatusDot = ({ variant, label, animated }: StatusDotProps) => {
const statusMapping = {
success: {
color: "bg-green-500",
colorLight: "bg-emerald-400",
animated: animated ?? true,
},
neutral: {
color: "bg-gray-500",
colorLight: "bg-gray-400",
animated: animated ?? false,
},
error: {
color: "bg-red-500",
colorLight: "bg-red-400",
animated: animated ?? true,
},
warning: {
color: "bg-yellow-500",
colorLight: "bg-yellow-400",
animated: animated ?? true,
},
info: {
color: "bg-blue-500",
colorLight: "bg-blue-400",
animated: animated ?? true,
},
}[variant];
return (
<Tooltip>
<TooltipTrigger>
<span className="relative flex size-3 mx-auto">
{statusMapping.animated && (
<span
className={cn(
"absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",
`${statusMapping.colorLight}`,
)}
/>
)}
<span className={cn("relative inline-flex size-3 rounded-full", `${statusMapping.color}`)} />
</span>
</TooltipTrigger>
<TooltipContent>
<p>{label}</p>
</TooltipContent>
</Tooltip>
);
};