import { createSignal, createEffect, onCleanup, Show } from 'solid-js'; export default function TourSpotlight(props) { const [rect, setRect] = createSignal(null); let resizeObserver = null; const updateRect = () => { if (!props.selector) { setRect(null); return; } const element = document.querySelector(props.selector); if (element) { const elementRect = element.getBoundingClientRect(); const padding = 6; setRect({ top: elementRect.top - padding, left: elementRect.left - padding, width: elementRect.width + padding * 2, height: elementRect.height + padding * 2 }); } else { setRect(null); } }; createEffect(() => { props.selector; const timeout = setTimeout(updateRect, 100); if (props.selector) { const element = document.querySelector(props.selector); if (element) { resizeObserver = new ResizeObserver(updateRect); resizeObserver.observe(element); } } window.addEventListener('scroll', updateRect, true); window.addEventListener('resize', updateRect); onCleanup(() => { clearTimeout(timeout); if (resizeObserver) resizeObserver.disconnect(); window.removeEventListener('scroll', updateRect, true); window.removeEventListener('resize', updateRect); }); }); return ( <> } > {/* Spotlight with cutout - element is fully visible */}
{/* Clickable overlay areas around the spotlight */}
); }