// axi0 Motion 0.2.0: Tumble. The words break loose and tumble into a pile you can drag and throw; click the pile and they fly home.
// Generated from src/tumble/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 TumbleProps extends HTMLAttributes<HTMLElement> {
  /** What makes the words fall (default "hover") */
  trigger?: "hover" | "click" | "view";
  /** Words to color (spaces or commas between them) (default auto) */
  mark?: string;
  /** Color of the marked words (default "#f6a04d") */
  color?: string;
  /** Where they fall: the parent's box or the element's own (default "parent") */
  area?: "parent" | "self";
  /** Gravity (default 1) */
  gravity?: number;
  /** Fly home on their own after (0 = on a click) (default 0) */
  again?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

const s = (v: unknown) => (v === undefined ? undefined : String(v));

export function Tumble({ as = "div", trigger, mark, color, area, gravity, again, ...rest }: TumbleProps) {
  return createElement(as, { ...rest, "data-motion": "tumble", "data-motion-trigger": s(trigger), "data-motion-mark": s(mark), "data-motion-color": s(color), "data-motion-area": s(area), "data-motion-gravity": s(gravity), "data-motion-again": s(again) });
}

export default Tumble;
