// axi0 Motion 0.2.0: Pixel flurry. Pixel-art snowflakes drift down in layers of depth, the near ones big and bright, and the pointer brushes them aside as it moves.
// Generated from src/pixel-flurry/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 PixelFlurryProps extends HTMLAttributes<HTMLElement> {
  /** Flakes per 100 x 100 pixels (default 2.6) */
  density?: number;
  /** Sideways drift (negative blows left) (default 0.2) */
  wind?: number;
  /** How hard the pointer pushes the flakes (default 1) */
  brush?: number;
  /** 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 PixelFlurry({ density, wind, brush, colors, background, speed, theme, cover, ...rest }: PixelFlurryProps) {
  return createElement("axi0-pixel-flurry", { ...rest, "density": s(density), "wind": s(wind), "brush": s(brush), "colors": s(colors), "background": s(background), "speed": s(speed), "theme": s(theme), "cover": flag(cover, false) });
}

export default PixelFlurry;
