// axi0 Motion 0.2.0: Masonry. Pictures in columns of their own heights that rise into place the first time they come into view, glide to new places when the columns change and open full size.
// Generated from src/masonry/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 MasonryProps extends HTMLAttributes<HTMLElement> {
  /** the most columns it uses (default 3) */
  columns?: number;
  /** the narrowest a column may get before it drops one (default 150) */
  width?: number;
  /** space between pictures (default 14) */
  gap?: number;
  /** the beat between pictures as they rise in (default 55) */
  stagger?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function Masonry({ as = "div", columns, width, gap, stagger, ...rest }: MasonryProps) {
  return createElement(as, { ...rest, "data-motion": "masonry", "data-motion-columns": s(columns), "data-motion-width": s(width), "data-motion-gap": s(gap), "data-motion-stagger": s(stagger) });
}

export default Masonry;
