// axi0 Motion 0.2.0: Tank gauge. A value as liquid in a glass tank: the level springs to it, the surface tilts with the speed and ripples as it settles, and drops splash when it fills.
// Generated from src/tank-gauge/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 TankGaugeProps extends HTMLAttributes<HTMLElement> {
  /** the liquid's color; empty takes the accent (default auto) */
  color?: string;
  /** written after the number (default "%") */
  unit?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function TankGauge({ as = "div", color, unit, ...rest }: TankGaugeProps) {
  return createElement(as, { ...rest, "data-motion": "tank-gauge", "data-motion-color": s(color), "data-motion-unit": s(unit) });
}

export default TankGauge;
