"use client"; import { useEffect, useRef, useState } from "react"; import Image from "next/image"; import { Icon } from "@iconify/react"; import { Badge, Card, Typography } from "poyraz-ui/atoms"; import { Popover, PopoverContent, PopoverTrigger, } from "poyraz-ui/molecules"; import { Link } from "@/i18n/routing"; type ProjectCardWithPopoverProps = { title: string; description: string; image: string; badge?: string; href?: string; caseStudyHref?: string; caseStudyLabel?: string; technologies: string[]; architecture: string; technologiesLabel: string; architectureLabel: string; className?: string; triggerClassName?: string; priority?: boolean; }; export function ProjectCardWithPopover({ title, description, image, badge, href, caseStudyHref, caseStudyLabel, technologies, architecture, technologiesLabel, architectureLabel, className, triggerClassName, priority = false, }: ProjectCardWithPopoverProps) { const [open, setOpen] = useState(false); const closeTimer = useRef | null>(null); const cancelClose = () => { if (closeTimer.current) { clearTimeout(closeTimer.current); closeTimer.current = null; } }; const showPopover = () => { cancelClose(); setOpen(true); }; const scheduleClose = () => { cancelClose(); closeTimer.current = setTimeout(() => setOpen(false), 120); }; useEffect(() => { return () => { if (closeTimer.current) clearTimeout(closeTimer.current); }; }, []); const card = (
{badge ? ( {badge} ) : null}

{title}

{description ? (

{description}

) : null}
); const triggerClasses = `block ${triggerClassName ?? ""} text-inherit outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`; return ( {caseStudyHref ? ( {card} ) : href ? ( {card} ) : ( )} event.preventDefault()} onCloseAutoFocus={(event) => event.preventDefault()} >
{title}
{technologiesLabel}
{technologies.map((technology) => ( {technology} ))}
{architectureLabel} {architecture}
{caseStudyHref && caseStudyLabel ? ( setOpen(false)} className="flex items-center justify-between border-t border-border pt-3 text-xs font-semibold text-foreground transition-colors hover:text-red-600" > {caseStudyLabel}
); }