Files
frigate/web/src/components/card/EmptyCard.tsx
T

57 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-10-11 15:40:39 -06:00
import React from "react";
import { Button } from "../ui/button";
import Heading from "../ui/heading";
2025-10-20 08:03:22 -05:00
import { Link } from "react-router-dom";
2025-12-31 06:48:56 -06:00
import { cn } from "@/lib/utils";
2025-10-11 15:40:39 -06:00
type EmptyCardProps = {
2025-12-31 06:48:56 -06:00
className?: string;
2025-10-11 15:40:39 -06:00
icon: React.ReactNode;
title: string;
2026-01-04 11:12:03 -07:00
titleHeading?: boolean;
2025-12-31 06:48:56 -06:00
description?: string;
2025-10-11 15:40:39 -06:00
buttonText?: string;
2025-10-20 08:03:22 -05:00
link?: string;
2026-05-12 11:20:39 -05:00
onClick?: () => void;
2025-10-11 15:40:39 -06:00
};
export function EmptyCard({
2025-12-31 06:48:56 -06:00
className,
2025-10-11 15:40:39 -06:00
icon,
title,
2026-01-04 11:12:03 -07:00
titleHeading = true,
2025-10-11 15:40:39 -06:00
description,
buttonText,
2025-10-20 08:03:22 -05:00
link,
2026-05-12 11:20:39 -05:00
onClick,
2025-10-11 15:40:39 -06:00
}: EmptyCardProps) {
2026-01-04 11:12:03 -07:00
let TitleComponent;
if (titleHeading) {
TitleComponent = <Heading as="h4">{title}</Heading>;
} else {
TitleComponent = <div>{title}</div>;
}
2025-10-11 15:40:39 -06:00
return (
2025-12-31 06:48:56 -06:00
<div className={cn("flex flex-col items-center gap-2", className)}>
2025-10-11 15:40:39 -06:00
{icon}
2026-01-04 11:12:03 -07:00
{TitleComponent}
2025-12-31 06:48:56 -06:00
{description && (
2026-01-20 09:17:58 -06:00
<div className="mb-3 text-center text-secondary-foreground">
{description}
</div>
2025-12-31 06:48:56 -06:00
)}
2026-05-12 11:20:39 -05:00
{buttonText?.length &&
(onClick ? (
<Button size="sm" variant="select" onClick={onClick}>
{buttonText}
</Button>
) : (
<Button size="sm" variant="select">
<Link to={link ?? "#"}>{buttonText}</Link>
</Button>
))}
2025-10-11 15:40:39 -06:00
</div>
);
}