/** @jsxImportSource react */ import React from 'react' import { cn } from "@nestri/ui/design" import { qwikify$ } from '@builder.io/qwik-react'; export const CursorSVG = ({ flip }: { flip?: boolean }) => ( ) type CursorProps = { class?: string; text: string, color?: string, flip?: boolean } const hexToRGBA = (hex: string, alpha: number = 1) => { const r = parseInt(hex.slice(1, 3), 16); const g = parseInt(hex.slice(3, 5), 16); const b = parseInt(hex.slice(5, 7), 16); return `rgba(${r}, ${g}, ${b}, ${alpha})`; }; export const ReactMyCursor: React.FC = ({ class: className, text, color = "#3B82F6", flip = false, }) => { const containerRef = React.useRef(null); const [position, setPosition] = React.useState({ x: 0, y: 0 }); React.useEffect(() => { const container = containerRef.current; if (!container) return; const handleMouseMove = (event: MouseEvent) => { const rect = container.getBoundingClientRect(); setPosition({ x: event.clientX - rect.left, y: event.clientY - rect.top }); console.log(event.clientX - rect.left, event.clientY - rect.top) }; window.addEventListener('mousemove', handleMouseMove); return () => { window.removeEventListener('mousemove', handleMouseMove); }; }, []); const cursorElement = ; const textElement = (
{text}
); const colorStyles = { '--cursor-color': color, '--cursor-color-light': hexToRGBA(color, 0.7), '--cursor-color-dark': hexToRGBA(color, 0.8), } as React.CSSProperties; return (
{flip ? ( <> {cursorElement} {textElement} ) : ( <> {textElement} {cursorElement} )}
); } export const MyCursor = qwikify$(ReactMyCursor)