import React, { useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; export default function EcosystemWheel({ layers, onLayerClick, selectedLayer, onLayerHover }) { const [hoveredIndex, setHoveredIndex] = useState(null); const centerX = 300; const centerY = 300; // Icon positions - precisely positioned in center of each puzzle piece const iconPositions = [ { x: 385, y: 160 }, // 30° - Buyer (top-right) { x: 460, y: 300 }, // 60° - Enterprises (top-right) { x: 380, y: 440 }, // 120° - Sectors (bottom-right) { x: 220, y: 440 }, // 180° - Partner (bottom-center) { x: 140, y: 300}, // 240° - Approved Vendor (bottom-left) { x: 220, y: 160} // 300° - Workforce (top-left) ]; // Create interlocking puzzle pieces const createOuterPuzzle = (index, total) => { const startAngle = index * 360 / total - 90; const endAngle = (index + 1) * 360 / total - 90; const midAngle = (startAngle + endAngle) / 2; const innerRadius = 110; const outerRadius = 210; const tabSize = 18; const toRad = (deg) => deg * Math.PI / 180; const startInner = { x: centerX + innerRadius * Math.cos(toRad(startAngle)), y: centerY + innerRadius * Math.sin(toRad(startAngle)) }; const endInner = { x: centerX + innerRadius * Math.cos(toRad(endAngle)), y: centerY + innerRadius * Math.sin(toRad(endAngle)) }; const startOuter = { x: centerX + outerRadius * Math.cos(toRad(startAngle)), y: centerY + outerRadius * Math.sin(toRad(startAngle)) }; const endOuter = { x: centerX + outerRadius * Math.cos(toRad(endAngle)), y: centerY + outerRadius * Math.sin(toRad(endAngle)) }; const innerTabAngle = startAngle + (endAngle - startAngle) * 0.5; const outerTabAngle = startAngle + (endAngle - startAngle) * 0.5; const innerTabOut = { x: centerX + (innerRadius - tabSize) * Math.cos(toRad(innerTabAngle)), y: centerY + (innerRadius - tabSize) * Math.sin(toRad(innerTabAngle)) }; const outerTabOut = { x: centerX + (outerRadius + tabSize) * Math.cos(toRad(outerTabAngle)), y: centerY + (outerRadius + tabSize) * Math.sin(toRad(outerTabAngle)) }; let path = `M ${startInner.x} ${startInner.y}`; const innerArc1End = startAngle + (endAngle - startAngle) * 0.4; const innerArc2Start = startAngle + (endAngle - startAngle) * 0.6; path += ` A ${innerRadius} ${innerRadius} 0 0 1 ${centerX + innerRadius * Math.cos(toRad(innerArc1End))} ${centerY + innerRadius * Math.sin(toRad(innerArc1End))}`; path += ` Q ${innerTabOut.x} ${innerTabOut.y} ${centerX + innerRadius * Math.cos(toRad(innerArc2Start))} ${centerY + innerRadius * Math.sin(toRad(innerArc2Start))}`; path += ` A ${innerRadius} ${innerRadius} 0 0 1 ${endInner.x} ${endInner.y}`; path += ` L ${endOuter.x} ${endOuter.y}`; const outerArc1End = endAngle - (endAngle - startAngle) * 0.4; const outerArc2Start = endAngle - (endAngle - startAngle) * 0.6; path += ` A ${outerRadius} ${outerRadius} 0 0 0 ${centerX + outerRadius * Math.cos(toRad(outerArc1End))} ${centerY + outerRadius * Math.sin(toRad(outerArc1End))}`; path += ` Q ${outerTabOut.x} ${outerTabOut.y} ${centerX + outerRadius * Math.cos(toRad(outerArc2Start))} ${centerY + outerRadius * Math.sin(toRad(outerArc2Start))}`; path += ` A ${outerRadius} ${outerRadius} 0 0 0 ${startOuter.x} ${startOuter.y}`; path += ` L ${startInner.x} ${startInner.y}`; path += " Z"; return path; }; const createCenterPuzzle = () => { const radius = 90; const numTabs = layers.length; let path = ""; for (let i = 0; i < numTabs; i++) { const angle1 = i * 360 / numTabs - 90; const angle2 = (i + 1) * 360 / numTabs - 90; const midAngle = (angle1 + angle2) / 2; const tabSize = 18; const toRad = (deg) => deg * Math.PI / 180; const start = { x: centerX + radius * Math.cos(toRad(angle1)), y: centerY + radius * Math.sin(toRad(angle1)) }; const end = { x: centerX + radius * Math.cos(toRad(angle2)), y: centerY + radius * Math.sin(toRad(angle2)) }; const tabIn = { x: centerX + (radius + tabSize) * Math.cos(toRad(midAngle)), y: centerY + (radius + tabSize) * Math.sin(toRad(midAngle)) }; if (i === 0) { path += `M ${start.x} ${start.y}`; } const arc1End = angle1 + (angle2 - angle1) * 0.4; const arc2Start = angle1 + (angle2 - angle1) * 0.6; path += ` A ${radius} ${radius} 0 0 1 ${centerX + radius * Math.cos(toRad(arc1End))} ${centerY + radius * Math.sin(toRad(arc1End))}`; path += ` Q ${tabIn.x} ${tabIn.y} ${centerX + radius * Math.cos(toRad(arc2Start))} ${centerY + radius * Math.sin(toRad(arc2Start))}`; path += ` A ${radius} ${radius} 0 0 1 ${end.x} ${end.y}`; } path += " Z"; return path; }; return (
Hover over each piece to see details • Click to explore
Click to view full dashboard