// axi0 Motion 0.2.0: Near type. Letters grow bolder the closer the pointer comes, and their neighbors slide apart to make room, so the line breathes without moving the page.
// Generated from src/near-type/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 NearTypeProps extends HTMLAttributes<HTMLElement> {
  /** Weight far from the pointer (0: the text's own weight) (default 0) */
  from?: number;
  /** Weight right under the pointer (default 800) */
  to?: number;
  /** How far the pull reaches (default 130) */
  radius?: number;
  /** How the weight eases off with distance (default "smooth") */
  falloff?: "smooth" | "linear" | "exponential";
  /** Tint the nearest letters toward this color (empty: no tint) (default auto) */
  color?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function NearType({ as = "div", from, to, radius, falloff, color, ...rest }: NearTypeProps) {
  return createElement(as, { ...rest, "data-motion": "near-type", "data-motion-from": s(from), "data-motion-to": s(to), "data-motion-radius": s(radius), "data-motion-falloff": s(falloff), "data-motion-color": s(color) });
}

export default NearType;
