"use client"; import rawLoadingMain from "@/assets/lottie/loading-main.json"; import { applyLoadingLottieTheme } from "@/lib/lottie-theme"; import { cn } from "@/lib/utils"; import Lottie from "lottie-react"; import { useTheme } from "next-themes"; import { useEffect, useMemo, useState } from "react"; interface IProps { className?: string | null; } /** * Extract of `animations/main.json` from `public/lottie/loading.lottie` (regenerate when * the .lottie changes: `unzip -p public/lottie/loading.lottie animations/main.json > src/assets/lottie/loading-main.json`). */ const LOTTIE_RAW = rawLoadingMain as object; /** * Route-level loader: SVG Lottie via `lottie-react` (reliable on refresh). Source animation * stays in sync with `public/lottie/loading.lottie` via the bundled extract above. */ const Loading = ({ className }: IProps) => { const { resolvedTheme } = useTheme(); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); const mode = mounted && resolvedTheme === "dark" ? "dark" : "light"; const animationData = useMemo( () => applyLoadingLottieTheme(LOTTIE_RAW, mode), [mode], ); return (
Loading