// axi0 Motion 0.2.0: Glare sweep. A glossy streak of light sweeps across in the direction the pointer moves.
// Generated from src/glare-sweep/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 GlareSweepProps extends HTMLAttributes<HTMLElement> {
  /** the streak's color (default "#ffffff") */
  color?: string;
  /** how strong the streak is, 0 to 1 (default 0.6) */
  opacity?: number;
  /** the streak's width, in percent of the element's diagonal (default 22) */
  width?: number;
  /** milliseconds per sweep (default 850) */
  duration?: number;
  /** sweep again, outward, when the pointer leaves (default true) */
  back?: boolean;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function GlareSweep({ as = "div", color, opacity, width, duration, back, ...rest }: GlareSweepProps) {
  return createElement(as, { ...rest, "data-motion": "glare-sweep", "data-motion-color": s(color), "data-motion-opacity": s(opacity), "data-motion-width": s(width), "data-motion-duration": s(duration), "data-motion-back": s(back) });
}

export default GlareSweep;
