// axi0 Motion 0.2.0: Shape lattice. A drifting grid of squares, circles, triangles or hexagons lights up under the pointer and leaves a fading rainbow trail that drifts with it.
// Generated from src/shape-lattice/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 ShapeLatticeProps extends HTMLAttributes<HTMLElement> {
  /** The grid's shape (default "square") */
  shape?: "square" | "circle" | "triangle" | "hexagon";
  /** Cell size (default 44) */
  size?: number;
  /** Drift direction (default 45) */
  angle?: number;
  /** Drift speed (default 18) */
  drift?: number;
  /** How long a lit cell takes to fade (default 1.2) */
  trail?: number;
  /** Color the trail through the rainbow (off: the first palette color) (default true) */
  rainbow?: boolean;
  /** Colors, comma separated (empty: the palette for the page's theme) (default auto) */
  colors?: string;
  /** Background color (empty: the theme's) (default auto) */
  background?: string;
  /** How fast it moves (default 1) */
  speed?: number;
  /** Light or dark palette (auto: from the page behind it) (default "auto") */
  theme?: "auto" | "light" | "dark";
  /** Fill the nearest positioned parent, behind its content (default false) */
  cover?: boolean;
  children?: ReactNode;
}

const s = (v: unknown) => (v === undefined ? undefined : String(v));
// a present attribute is on; "false" turns off an option that is on by default
const flag = (v: boolean | undefined, d: boolean) => (v === undefined || v === d ? undefined : v ? "" : "false");

export function ShapeLattice({ shape, size, angle, drift, trail, rainbow, colors, background, speed, theme, cover, ...rest }: ShapeLatticeProps) {
  return createElement("axi0-shape-lattice", { ...rest, "shape": s(shape), "size": s(size), "angle": s(angle), "drift": s(drift), "trail": s(trail), "rainbow": flag(rainbow, true), "colors": s(colors), "background": s(background), "speed": s(speed), "theme": s(theme), "cover": flag(cover, false) });
}

export default ShapeLattice;
