ldc-bien-etre-animal/resources/ts/front/Components/Shared/CurvedImageCard.tsx
2026-08-28 10:40:04 +02:00

56 lines
1.4 KiB
TypeScript

import { type ReactNode } from "react";
import useDeviceType from "@/hooks/use-device-type";
interface CurvedImageCardProps {
image: string;
imageWebp?: string;
children: ReactNode;
rotation?: number;
className?: string;
imageClassName?: string;
imageHeight?: string;
shadow?: "default" | "blue";
}
const SHADOW_CLASSES: Record<
NonNullable<CurvedImageCardProps["shadow"]>,
string
> = {
default: "drop-shadow-card",
blue: "drop-shadow-card-blue",
};
export default function CurvedImageCard({
image,
imageWebp,
children,
rotation = 3,
className = "",
imageClassName = "",
imageHeight = "h-[325px]",
shadow = "default",
}: Readonly<CurvedImageCardProps>) {
const { isMobile, isTablet } = useDeviceType();
const isCompact = isMobile || isTablet;
const effectiveRotation = isCompact ? 0 : rotation;
return (
<div
className={`relative flex shrink-0 flex-col overflow-hidden rounded-[50px] bg-white ${SHADOW_CLASSES[shadow]} transition-all duration-300 ${className}`}
style={{ transform: `rotate(${String(effectiveRotation)}deg)` }}
>
<picture>
{imageWebp && <source srcSet={imageWebp} type="image/webp" />}
<img
src={image}
alt=""
title=""
className={`clip-guarantee w-full object-cover ${imageHeight} ${imageClassName}`}
/>
</picture>
{children}
</div>
);
}