// axi0 Motion 0.2.0: Crosshair. Hairlines follow the pointer with its position and lock onto links and buttons to measure them.
// Generated from src/crosshair/meta.json by motion-pack: a thin wrapper. The loader (motion.js) must be on the page once;
// it starts the effect on the element this renders. Options left out keep the effect's own defaults.
import { createElement } from "react";
import type { HTMLAttributes, ReactNode } from "react";

export interface CrosshairProps extends HTMLAttributes<HTMLElement> {
  /** the frame's distance from a locked element, in pixels (default 6) */
  pad?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

const s = (v: unknown) => (v === undefined ? undefined : String(v));

export function Crosshair({ as = "div", pad, ...rest }: CrosshairProps) {
  return createElement(as, { ...rest, "data-motion": "crosshair", "data-motion-pad": s(pad) });
}

export default Crosshair;
