// axi0 Motion 0.2.0: Grain gradient. Flowing grainy gradients that the pointer stirs like paint.
// Generated from src/grain-gradient/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 GrainGradientProps extends HTMLAttributes<HTMLElement> {
  /** four colors that flow into each other (default "#ff9a5a,#ff5f8f,#7c6cff,#1c1640") */
  colors?: string;
  /** how strong the grain is (0 = smooth) (default 0.09) */
  grain?: number;
  /** how fast the colors flow (default 1) */
  speed?: number;
  /** how much the pointer swirls the colors (default 1) */
  stir?: number;
  /** 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 GrainGradient({ colors, grain, speed, stir, cover, ...rest }: GrainGradientProps) {
  return createElement("axi0-grain-gradient", { ...rest, "colors": s(colors), "grain": s(grain), "speed": s(speed), "stir": s(stir), "cover": flag(cover, false) });
}

export default GrainGradient;
