// axi0 Motion 0.2.0: Magnet. An element leans toward the pointer when it comes near, then settles back.
// Generated from src/magnet/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 MagnetProps extends HTMLAttributes<HTMLElement> {
  /** how far around the element it reacts, in pixels (default 70) */
  radius?: number;
  /** how far it follows (0 to 1) (default 0.3) */
  strength?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function Magnet({ as = "div", radius, strength, ...rest }: MagnetProps) {
  return createElement(as, { ...rest, "data-motion": "magnet", "data-motion-radius": s(radius), "data-motion-strength": s(strength) });
}

export default Magnet;
