// axi0 Motion 0.2.0: Cursor trail. Letters, a word or an emoji follow the pointer, as glowing stamps that shrink away or as a chain that snakes behind it.
// Generated from src/cursor-trail/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 CursorTrailProps extends HTMLAttributes<HTMLElement> {
  /** What to stamp (letters, a word or an emoji) (default "✦") */
  text?: string;
  /** Trail (default "stamp") */
  mode?: "stamp" | "chain";
  /** Distance between stamps (default 22) */
  spacing?: number;
  /** How long a stamp lasts (default 1500) */
  life?: number;
  /** Links in a chain (default 10) */
  count?: number;
  /** Size, in the text's letter heights (default 1) */
  size?: number;
  /** Turn each stamp with the movement (off: a playful random tilt) (default false) */
  turn?: boolean;
  /** Color (default "#f6a04d") */
  color?: string;
  /** Where it follows the pointer (default "self") */
  area?: "self" | "parent";
  /** Draw a slow loop when nobody points (default true) */
  idle?: boolean;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function CursorTrail({ as = "div", text, mode, spacing, life, count, size, turn, color, area, idle, ...rest }: CursorTrailProps) {
  return createElement(as, { ...rest, "data-motion": "cursor-trail", "data-motion-text": s(text), "data-motion-mode": s(mode), "data-motion-spacing": s(spacing), "data-motion-life": s(life), "data-motion-count": s(count), "data-motion-size": s(size), "data-motion-turn": s(turn), "data-motion-color": s(color), "data-motion-area": s(area), "data-motion-idle": s(idle) });
}

export default CursorTrail;
