UNPKG

unicornstudio-react

Version:

React component for embedding Unicorn.Studio interactive scenes with TypeScript support. Compatible with React (Vite) and Next.js.

63 lines (61 loc) 1.55 kB
type ValidFPS = 15 | 24 | 30 | 60 | 120; type ScaleRange = number; interface UnicornSceneProps { projectId?: string; jsonFilePath?: string; altText?: string; width?: number | string; height?: number | string; scale?: ScaleRange; dpi?: number; fps?: ValidFPS; ariaLabel?: string; className?: string; lazyLoad?: boolean; production?: boolean; placeholder?: string | React.ReactNode; placeholderClassName?: string; showPlaceholderOnError?: boolean; showPlaceholderWhileLoading?: boolean; onLoad?: () => void; onError?: (error: Error) => void; } interface UnicornStudioScene { element: HTMLElement; destroy: () => void; resize?: () => void; paused?: boolean; contains?: (element: HTMLElement | null) => boolean; } interface UnicornSceneConfig { elementId: string; scale?: ScaleRange; dpi?: number; fps?: ValidFPS; projectId?: string; filePath?: string; lazyLoad?: boolean; fixed?: boolean; altText?: string; ariaLabel?: string; production?: boolean; interactivity?: { mouse?: { disableMobile?: boolean; }; }; } interface UnicornStudioAPI { init: (config: { scale: ScaleRange; dpi: number; }) => Promise<UnicornStudioScene[]>; addScene: (config: UnicornSceneConfig) => Promise<UnicornStudioScene>; destroy: () => void; } declare global { interface Window { UnicornStudio?: UnicornStudioAPI; } } export type { UnicornSceneProps as U };