// axi0 Motion 0.2.0: Star rate. A star rating whose stars lift in a wave up to the pointer, name the score above it and pop when one is chosen.
// Generated from src/star-rate/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 StarRateProps extends HTMLAttributes<HTMLElement> {
  /** Star color (default "#f6a04d") */
  color?: string;
  /** Star size (default 40) */
  size?: number;
  /** One word per star, shown above the star the pointer is on (comma separated) (default "Poor,Fair,Good,Great,Superb") */
  words?: string;
  /** Show the word above the stars (default true) */
  tip?: boolean;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function StarRate({ as = "div", color, size, words, tip, ...rest }: StarRateProps) {
  return createElement(as, { ...rest, "data-motion": "star-rate", "data-motion-color": s(color), "data-motion-size": s(size), "data-motion-words": s(words), "data-motion-tip": s(tip) });
}

export default StarRate;
