// axi0 Motion 0.2.0: Silk. Folds of fabric ripple slowly across a background, with a fine film grain.
// Generated from src/silk/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 SilkProps extends HTMLAttributes<HTMLElement> {
  /** the fabric's color (default "#7b6cff") */
  color?: string;
  /** how fast the folds move (default 1) */
  speed?: number;
  /** larger numbers make smaller folds (default 1) */
  scale?: number;
  /** turns the pattern, in degrees (default 0) */
  rotation?: number;
  /** film grain (0 turns it off) (default 1) */
  grain?: 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 Silk({ color, speed, scale, rotation, grain, cover, ...rest }: SilkProps) {
  return createElement("axi0-silk", { ...rest, "color": s(color), "speed": s(speed), "scale": s(scale), "rotation": s(rotation), "grain": s(grain), "cover": flag(cover, false) });
}

export default Silk;
