OverviewCard.jsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. "use client";
  2. import Link from "next/link";
  3. import { cn } from "@/lib/utils";
  4. import {
  5. Card,
  6. CardContent,
  7. CardDescription,
  8. CardTitle,
  9. } from "@/components/ui/card";
  10. export default function OverviewCard({
  11. title,
  12. description,
  13. imageSrc,
  14. href = null,
  15. disabledHint = null,
  16. containerClassName = "",
  17. }) {
  18. const isDisabled = !href;
  19. const card = (
  20. <Card
  21. className={[
  22. "h-[420px] w-full overflow-hidden gap-0 py-0 border",
  23. "bg-card/90",
  24. "transition-all duration-200",
  25. isDisabled
  26. ? "opacity-85"
  27. : "group-hover:-translate-y-0.5 group-hover:shadow-lg group-hover:border-primary/30 group-active:translate-y-0",
  28. ].join(" ")}
  29. >
  30. <div className="h-56 w-full overflow-hidden border-b bg-muted/30">
  31. <img
  32. src={imageSrc}
  33. alt={`${title} Karte`}
  34. className="h-full w-full object-cover"
  35. loading="lazy"
  36. />
  37. </div>
  38. <CardContent className="flex flex-1 flex-col space-y-2 px-4 py-3">
  39. <CardTitle className="text-base">{title}</CardTitle>
  40. <CardDescription className="text-sm leading-relaxed">
  41. {description}
  42. </CardDescription>
  43. {isDisabled && disabledHint ? (
  44. <p className="mt-auto text-xs text-muted-foreground">
  45. {disabledHint}
  46. </p>
  47. ) : null}
  48. </CardContent>
  49. </Card>
  50. );
  51. if (isDisabled) {
  52. return (
  53. <div
  54. className={cn("group block w-full", containerClassName)}
  55. aria-disabled="true"
  56. >
  57. {card}
  58. </div>
  59. );
  60. }
  61. return (
  62. <Link
  63. href={href}
  64. className={cn(
  65. "group block w-full rounded-xl focus:outline-none",
  66. containerClassName,
  67. )}
  68. >
  69. {card}
  70. </Link>
  71. );
  72. }