"use client" import { useInViewport } from "ahooks" import { type LottieRefCurrentProps } from "lottie-react" import dynamic from "next/dynamic" import React, { useRef } from "react" import { Image } from "~/components/ui/Image" import LogoLottieJSON from "../../../public/assets/logo.json" const DynamicLottie = dynamic(() => import("lottie-react")) export const Logo = ({ type, width, height, loop, autoplay, }: { type: "svg" | "png" | "lottie" width?: number height?: number loop?: boolean autoplay?: boolean }) => { const ref = useRef(null) const containerRef = useRef(null) const [isInView] = useInViewport(containerRef) switch (type) { case "svg": return ( logo ) case "png": return ( logo ) case "lottie": return (
{isInView && ( ref.current?.goToAndPlay(0)} className="xlog-lottie-logo text-black w-full h-full" /> )}
) } }