import { GlobeAltIcon } from "@heroicons/react/16/solid"; import { TwitterIcon, TypeIcon } from "lucide-react"; import { useState } from "react"; import { motion } from "framer-motion"; import useMeasure from "react-use-measure"; type CardType = string; export default function Card({ type, title, content, source, }: { type: CardType; title: string; content: string; source?: string; }) { const [ref, bounds] = useMeasure(); const [isDragging, setIsDragging] = useState(false); const handleDragStart = ( event: React.DragEvent, dragSource: "icon" | "link" | "parent", ) => { setIsDragging(true); switch (dragSource) { case "icon": event.dataTransfer.setData( "application/json", JSON.stringify({ type, title, content, text: true, }), ); break; case "link": event.dataTransfer.setData("text/plain", source || ""); break; case "parent": event.dataTransfer.setData( "application/json", JSON.stringify({ type, title, content, text: false, }), ); break; } }; const handleDragEnd = () => { setIsDragging(false); }; return (
handleDragStart(e, "parent")} className={`rounded-lg hover:scale-[1.02] group cursor-grab scale-[0.98] select-none transition-all border-[#232c2f] hover:bg-[#232c32] ${ isDragging ? "border-blue-600 border-dashed border-2" : "" }`} >
{ e.stopPropagation(); handleDragStart(e, "icon"); }} >

{title}

{content}

{ e.stopPropagation(); handleDragStart(e, "link"); }} > {source}
); } function Icon({ type }: { type: CardType }) { return type === "note" ? ( ) : type === "page" ? ( ) : ( ); }