// axi0 Motion 0.2.0: Pixel wipe. A second picture builds in over the first pixel by pixel, in a springy wave that starts wherever the pointer comes in, and pulls back out the same way.
// Generated from src/pixel-wipe/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 PixelWipeProps extends HTMLAttributes<HTMLElement> {
  /** Pixel size (default 22) */
  cell?: number;
  /** How fast the wave travels (default 1) */
  speed?: number;
  /** Swap on click or tap only (the pointer passing over does nothing) (default false) */
  toggle?: boolean;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function PixelWipe({ as = "div", cell, speed, toggle, ...rest }: PixelWipeProps) {
  return createElement(as, { ...rest, "data-motion": "pixel-wipe", "data-motion-cell": s(cell), "data-motion-speed": s(speed), "data-motion-toggle": s(toggle) });
}

export default PixelWipe;
