OverviewCard.jsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. imageLoading = "lazy",
  18. imageFetchPriority = "auto",
  19. imageDecoding = "async",
  20. }) {
  21. const isDisabled = !href;
  22. const card = (
  23. <Card
  24. className={[
  25. "h-[420px] w-full overflow-hidden gap-0 py-0 border",
  26. "bg-card/90",
  27. "transition-all duration-200",
  28. isDisabled
  29. ? "opacity-85"
  30. : "group-hover:-translate-y-0.5 group-hover:shadow-lg group-hover:border-primary/30 group-active:translate-y-0",
  31. ].join(" ")}
  32. >
  33. <div className="h-56 w-full overflow-hidden border-b bg-muted/30">
  34. <img
  35. src={imageSrc}
  36. alt={`${title} Karte`}
  37. className="h-full w-full object-cover"
  38. loading={imageLoading}
  39. fetchPriority={imageFetchPriority}
  40. decoding={imageDecoding}
  41. />
  42. </div>
  43. <CardContent className="flex flex-1 flex-col space-y-2 px-4 py-3">
  44. <CardTitle className="text-base">{title}</CardTitle>
  45. <CardDescription className="text-sm leading-relaxed">
  46. {description}
  47. </CardDescription>
  48. {isDisabled && disabledHint ? (
  49. <p className="mt-auto text-xs text-muted-foreground">
  50. {disabledHint}
  51. </p>
  52. ) : null}
  53. </CardContent>
  54. </Card>
  55. );
  56. if (isDisabled) {
  57. return (
  58. <div
  59. className={cn("group block w-full", containerClassName)}
  60. aria-disabled="true"
  61. >
  62. {card}
  63. </div>
  64. );
  65. }
  66. return (
  67. <Link
  68. href={href}
  69. className={cn(
  70. "group block w-full rounded-xl focus:outline-none",
  71. containerClassName,
  72. )}
  73. >
  74. {card}
  75. </Link>
  76. );
  77. }