// axi0 Motion 0.2.0: Cube field. Outlined 3D cubes turn to face the pointer, spin when swept and ripple on click.
// Generated from src/cube-field/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 CubeFieldProps extends HTMLAttributes<HTMLElement> {
  /** grid cell in pixels (each cube is a little over half of it) (default 56) */
  size?: number;
  /** cubes near the pointer and in a ripple (default "#f6a04d") */
  active?: string;
  /** a slow wave while no pointer is near (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 CubeField({ as = "div", size, active, idle, ...rest }: CubeFieldProps) {
  return createElement(as, { ...rest, "data-motion": "cube-field", "data-motion-size": s(size), "data-motion-active": s(active), "data-motion-idle": s(idle) });
}

export default CubeField;
