This commit is contained in:
mr.sabri
2026-07-22 08:52:46 +03:30
parent 55ba2df7b6
commit 89fbd6d158
5 changed files with 124 additions and 94 deletions
+93 -70
View File
@@ -12,81 +12,99 @@ interface Hero213Props {
className?: string;
}
const Hero213 = ({ className }: Hero213Props) => {
const images = [
{
src: "/block-media/shadcnblocks/block/lummi/bw12.jpeg",
alt: "تصویر نمونه",
name: "Joanna Doe",
},
{
src: "/block-media/shadcnblocks/block/lummi/bw13.jpeg",
alt: "تصویر نمونه",
name: "مریم چناری",
},
{
src: "/block-media/shadcnblocks/block/lummi/bw14.jpeg",
alt: "تصویر نمونه",
name: "Joanna Doe",
},
];
const IMAGES = [
{
src: "/block-media/shadcnblocks/block/lummi/bw12.jpeg",
alt: "تصویر نمونه",
name: "Joanna Doe",
},
{
src: "/block-media/shadcnblocks/block/lummi/bw13.jpeg",
alt: "تصویر نمونه",
name: "مریم چناری",
},
{
src: "/block-media/shadcnblocks/block/lummi/bw14.jpeg",
alt: "تصویر نمونه",
name: "Joanna Doe",
},
] as const;
const Hero213 = ({ className }: Hero213Props) => {
const [currentIndex, setCurrentIndex] = useState(0);
const nextIndex = (currentIndex + 1) % IMAGES.length;
useEffect(() => {
const timer = setTimeout(() => {
setCurrentIndex((prevIndex) => (prevIndex + 1) % images.length);
setCurrentIndex((prev) => (prev + 1) % IMAGES.length);
}, 2500);
return () => clearTimeout(timer);
}, [currentIndex, images.length]);
}, [currentIndex]);
return (
<section className={cn("py-32", className)}>
<section className={cn("overflow-x-hidden py-32", className)}>
<div className="container">
<div className="mx-auto flex max-w-2xl flex-col items-center justify-center gap-4">
<h1 className="font-calSans text-center text-2xll lg:text-2xll">
<h1 className="font-calSans text-center text-5xl leading-tight lg:text-6xl">
مجموعه بلاک‌های آماده <br />
برای رابط کاربری و استایل‌دهی مدرن
</h1>
<p className="px-10 text-center text-muted-foreground lg:text-lg">
صدها کامپوننت استاندارد و قابل سفارشی‌سازی که مستقیماً در پروژه‌های شما قابل استفاده هستند.
</p>
</h1>
<p className="px-10 text-center leading-relaxed text-muted-foreground lg:text-lg">
صدها کامپوننت استاندارد و قابل سفارشی‌سازی که مستقیماً در پروژه‌های
شما قابل استفاده هستند.
</p>
</div>
<div className="relative mt-4">
<div className="relative z-10 mx-auto my-7 flex w-fit cursor-pointer items-center justify-center gap-8 rounded-full bg-muted px-4 py-2 md:my-0 lg:translate-y-12 lg:py-3 xl:px-8 xl:py-4">
<GalleryVerticalEnd className="size-4 opacity-40 hover:opacity-100 lg:size-6" />
<Signature className="size-4 opacity-40 hover:opacity-100 lg:size-6" />
<Figma className="size-4 opacity-40 hover:opacity-100 lg:size-6" />
</div>
<MaskedDiv maskType="type-3">
<AnimatePresence mode="popLayout">
<motion.img
key={currentIndex}
className="h-full w-full object-cover"
src={images[currentIndex].src}
alt={images[currentIndex].alt}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 1.5 }}
/>
</AnimatePresence>
</MaskedDiv>
<div className="absolute bottom-22 -left-8 hidden h-36 w-32 items-center justify-center overflow-hidden rounded-4xl border lg:flex xl:bottom-28 xl:h-42 2xl:-left-28 2xl:h-52 2xl:w-62 2xl:rounded-[4rem]">
<AnimatePresence mode="popLayout">
<motion.img
key={currentIndex}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 1.5 }}
src={images[currentIndex + 1]?.src || images[currentIndex].src}
alt={images[currentIndex + 1]?.alt || images[currentIndex].alt}
className="h-full w-full object-cover"
/>
</AnimatePresence>
{/* Shared box = mask bounds, so the tile can sit in the cutout precisely */}
<div className="relative w-full">
<MaskedDiv maskType="type-3">
<AnimatePresence mode="wait" initial={false}>
<motion.img
key={currentIndex}
className="absolute inset-0 size-full object-cover"
src={IMAGES[currentIndex].src}
alt={IMAGES[currentIndex].alt}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.8 }}
/>
</AnimatePresence>
</MaskedDiv>
{/*
type-3 cutout ≈ left 0–12.5%, bottom pocket ≈ 29% of height.
Tile sized under that so a white gutter remains vs the concave edge.
left/bottom 0 align with the mask’s outer edges (like the reference).
*/}
<div
className={cn(
"absolute bottom-0 left-0 z-20 hidden overflow-hidden border border-border bg-background",
"aspect-[4/5] w-[11.2%] min-w-[6.5rem] max-w-[15.5rem]",
"rounded-[1.75rem] lg:block xl:rounded-[2.25rem] 2xl:rounded-[2.75rem]",
)}
>
<AnimatePresence mode="wait" initial={false}>
<motion.img
key={nextIndex}
src={IMAGES[nextIndex].src}
alt={IMAGES[nextIndex].alt}
className="absolute inset-0 size-full object-cover"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.8 }}
/>
</AnimatePresence>
</div>
</div>
</div>
</div>
@@ -103,7 +121,7 @@ interface SvgPath {
}
interface MaskedDivProps {
children: React.ReactElement<HTMLImageElement | HTMLVideoElement>;
children: React.ReactNode;
maskType?: MaskType;
className?: string;
backgroundColor?: string;
@@ -121,9 +139,10 @@ const svgPaths: Record<MaskType, SvgPath> = {
height: 381,
width: 850,
},
// Height matches path bounds (max Y ≈ 765) so the cutout sits on the true bottom edge
"type-3": {
path: "M0.680664 112.659C0.680664 50.805 50.823 0.662672 112.677 0.662672H413.07C456.315 0.662672 497.495 19.1588 526.221 51.4846V51.4846C554.948 83.8104 596.128 102.307 639.373 102.307H711.793C752.427 102.307 790.787 83.5522 815.744 51.4846V51.4846C840.7 19.417 879.06 0.662644 919.695 0.662597L1225.01 0.66224C1286.86 0.662168 1337.01 50.8046 1337.01 112.658V652.815C1337.01 714.668 1286.86 764.811 1225.01 764.811L670 764.811H335.34H278.376C217.423 764.811 168.01 715.399 168.01 654.446V626.747C168.01 580.208 130.283 542.48 83.7437 542.48V542.48C37.8692 542.48 0.680664 505.292 0.680664 459.417V382.737V112.659Z",
height: 889,
height: 765,
width: 1340,
},
"type-4": {
@@ -133,6 +152,10 @@ const svgPaths: Record<MaskType, SvgPath> = {
},
};
function buildMaskDataUrl(mask: SvgPath): string {
return `data:image/svg+xml,%3Csvg width='${mask.width}' height='${mask.height}' viewBox='0 0 ${mask.width} ${mask.height}' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='${mask.path}' fill='%23D9D9D9'/%3E%3C/svg%3E`;
}
const MaskedDiv: React.FC<MaskedDivProps> = ({
children,
maskType = "type-1",
@@ -141,30 +164,30 @@ const MaskedDiv: React.FC<MaskedDivProps> = ({
size = 1,
}) => {
const selectedMask = svgPaths[maskType];
const svgString = `${selectedMask.width}${selectedMask.height}${selectedMask.width} ${selectedMask.height}${selectedMask.path}`;
const maskUrl = buildMaskDataUrl(selectedMask);
const containerStyle: React.CSSProperties = {
aspectRatio: `${selectedMask.width}/${selectedMask.height}`,
aspectRatio: `${selectedMask.width} / ${selectedMask.height}`,
backgroundColor,
maskImage: `url("${svgString}")`,
WebkitMaskImage: `url("${svgString}")`,
maskImage: `url("${maskUrl}")`,
WebkitMaskImage: `url("${maskUrl}")`,
maskRepeat: "no-repeat",
WebkitMaskRepeat: "no-repeat",
maskSize: "contain",
WebkitMaskSize: "contain",
maskSize: "100% 100%",
WebkitMaskSize: "100% 100%",
maskPosition: "center",
WebkitMaskPosition: "center",
width: `${size * 100}%`,
maxWidth: "100%",
margin: "0 auto",
marginInline: "auto",
};
return (
<section className={`relative ${className}`} style={containerStyle}>
{React.cloneElement(children, {
className: `w-full h-full object-cover transition-all duration-300 ${
children.props.className || ""
}`,
})}
</section>
<div
className={cn("relative overflow-hidden", className)}
style={containerStyle}
>
{children}
</div>
);
};