"use client";
import { AnimatePresence, motion } from "framer-motion";
import {
ChevronDown,
ChevronLeft,
ChevronRight,
ChevronUp,
PlusCircle,
} from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { useMediaQuery } from "@/hooks/useMediaQuery";
import { cn } from "@/lib/utils";
interface FeatureItem {
id: string;
image: string;
title: string;
description: string;
}
interface ControlsProps {
handleNext: () => void;
handlePrevious: () => void;
isPrevioIRRisabled: boolean;
isNextDisabled: boolean;
}
const Controls = ({
handleNext,
handlePrevious,
isPrevioIRRisabled,
isNextDisabled,
}: ControlsProps) => {
return (
);
};
interface FeatureCardProps {
feature: FeatureItem;
isActive: boolean;
onClick: () => void;
}
const FeatureCard = ({ feature, isActive, onClick }: FeatureCardProps) => {
const variants = {
initial: {
opacity: 0,
},
animate: {
opacity: 1,
},
exit: {
opacity: 0,
},
};
return (
{isActive ? (
{feature.title}.{" "}
{feature.description}
) : (
{feature.title}
)}
);
};
interface FeaturesDesktopProps {
features: FeatureItem[];
handleNext: () => void;
handlePrevious: () => void;
activeIndex: number;
handleFeatureClick: (index: number) => void;
isPrevioIRRisabled: boolean;
isNextDisabled: boolean;
}
const FeaturesDesktop = ({
features,
handleNext,
handlePrevious,
activeIndex,
handleFeatureClick,
isPrevioIRRisabled,
isNextDisabled,
}: FeaturesDesktopProps) => {
return (
{features.map((feature, index) => {
return (
handleFeatureClick(index)}
/>
);
})}
);
};
interface FeatureMobileProps {
features: FeatureItem[];
handleNext: () => void;
handlePrevious: () => void;
activeIndex: number;
direction: 1 | -1;
isPrevioIRRisabled: boolean;
isNextDisabled: boolean;
}
const FeaturesMobile = ({
features,
handleNext,
handlePrevious,
activeIndex,
direction,
isPrevioIRRisabled,
isNextDisabled,
}: FeatureMobileProps) => {
const variants = {
initial: (dir: 1 | -1) => ({
opacity: 0,
scale: 0.9,
x: `${dir * -20}%`,
}),
animate: {
opacity: 1,
scale: 1,
x: 0,
},
exit: (dir: 1 | -1) => ({
opacity: 0,
scale: 0.9,
x: `${dir * 20}%`,
}),
};
return (
);
};
const DEFAULT_FEATURES: FeatureItem[] = [
{
id: "smart-watches",
image:
"/block-media/shadcnblocks/block/ecommerce/electronics/klim-musalimov-DAGss-dkVOs-unsplash-2.jpg",
title: "تقویم تیمی",
description:
"برنامه تیم را هماهنگ کنید و تداخل وظایف را کاهش دهید.",
},
{
id: "fitness-tracking",
image:
"/block-media/shadcnblocks/block/ecommerce/electronics/klim-musalimov-IGO10LkxP_g-unsplash-2.jpg",
title: "اشتراک فایل",
description:
"نسخه درست فایل همیشه در دسترس همه اعضا باشد.",
},
{
id: "gaming-consoles",
image:
"/block-media/shadcnblocks/block/ecommerce/electronics/dennis-cortes-cL7xovIO7sw-unsplash-3.jpg",
title: "منشن و بحث",
description:
"بحث را کنار هر تسک نگه دارید تا تصمیمها گم نشود.",
},
{
id: "premium-laptops",
image:
"/block-media/shadcnblocks/block/ecommerce/electronics/Sleek-Laptop-Silhouette-1.png",
title: "ردیابی زمان",
description:
"وضعیت هر کار را در یک نما ببینید و گلوگاهها را زودتر پیدا کنید.",
},
{
id: "phone-accessories",
image:
"/block-media/shadcnblocks/block/ecommerce/other/jascent-leung-fCO3tBcnkhg-unsplash-1.jpg",
title: "نقش و دسترسی",
description:
"برنامه تیم را هماهنگ کنید و تداخل وظایف را کاهش دهید.",
},
{
id: "work-anywhere",
image:
"/block-media/shadcnblocks/block/ecommerce/electronics/Hands-Typing-on-Laptop-1.png",
title: "چکلیست تحویل",
description:
"نسخه درست فایل همیشه در دسترس همه اعضا باشد.",
},
];
interface Feature323Props {
heading?: string;
features?: FeatureItem[];
className?: string;
}
const Feature323 = ({
className,
heading = "همکاری از راه دور را ساده کنید",
features = DEFAULT_FEATURES,
}: Feature323Props) => {
const [activeIndex, setActiveIndex] = useState(0);
const [direction, setDirection] = useState<1 | -1>(1);
const isMobile = useMediaQuery("(max-width: 768px)");
const handleNext = () => {
setDirection(1);
if (activeIndex !== features.length - 1) {
setActiveIndex((prevIndex) => prevIndex + 1);
}
};
const handlePrevious = () => {
setDirection(-1);
if (activeIndex !== 0) {
setActiveIndex((prevIndex) => prevIndex - 1);
}
};
const handleFeatureClick = (index: number) => {
setDirection(index > activeIndex ? 1 : -1);
setActiveIndex(index);
};
const xOffset = !isMobile ? 20 : 10;
const yOffset = !isMobile ? 10 : 5;
const scale = !isMobile ? 0.85 : 0.9;
const variants = {
initial: (dir: 1 | -1) => ({
opacity: 0,
scale: scale,
filter: "blur(20px)",
x: `${dir * -xOffset}%`,
y: `${dir * yOffset}%`,
}),
animate: {
opacity: 1,
scale: 1,
filter: "blur(0px)",
x: 0,
y: 0,
},
exit: (dir: 1 | -1) => ({
opacity: 0,
scale: scale,
x: `${dir * xOffset}%`,
y: `${dir * -yOffset}%`,
filter: "blur(20px)",
}),
};
return (
);
};
export { Feature323 };