File size: 1,426 Bytes
8153b56 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import { useState } from "react";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.jsx";
import { Button } from "@/components/ui/button.jsx";
import { ChevronDown, ChevronUp } from "lucide-react";
const ToggleChartCard = ({ title, children, defaultOpen = false, alwaysVisible = false }) => {
const [isOpen, setIsOpen] = useState(defaultOpen || alwaysVisible);
return (
<Card className="border border-kpi-border bg-card shadow-card hover:shadow-card-hover transition-all duration-200 animate-fade-in">
<CardHeader className="flex flex-row items-center justify-between pb-2 px-5 pt-4">
<CardTitle className="text-base font-semibold text-card-foreground">{title}</CardTitle>
{!alwaysVisible && (
<Button
variant="outline"
size="sm"
onClick={() => setIsOpen(!isOpen)}
className="border-kpi-border bg-kpi-bg text-muted-foreground hover:bg-toggle-hover hover:text-foreground transition-colors text-xs px-3"
>
{isOpen ? <ChevronUp className="h-3.5 w-3.5 mr-1" /> : <ChevronDown className="h-3.5 w-3.5 mr-1" />}
{isOpen ? "Hide" : "Show"}
</Button>
)}
</CardHeader>
{isOpen && (
<CardContent className="pt-0 px-5 pb-5 animate-fade-in">
{children}
</CardContent>
)}
</Card>
);
};
export default ToggleChartCard;
|