// axi0 Motion 0.2.0: Tilt card. A card leans toward the pointer in 3D, with a soft glare.
// Generated from src/tilt/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 TiltProps extends HTMLAttributes<HTMLElement> {
  /** the largest lean, in degrees (default 8) */
  max?: number;
  /** how much it grows while leaning (default 1.02) */
  scale?: number;
  /** perspective distance in pixels (default 900) */
  perspective?: number;
  /** a soft glare that follows the lean (default true) */
  glare?: boolean;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function Tilt({ as = "div", max, scale, perspective, glare, ...rest }: TiltProps) {
  return createElement(as, { ...rest, "data-motion": "tilt", "data-motion-max": s(max), "data-motion-scale": s(scale), "data-motion-perspective": s(perspective), "data-motion-glare": s(glare) });
}

export default Tilt;
