import clsx from 'clsx'; import { motion, MotionConfigProps } from 'motion/react'; import { type ImgHTMLAttributes } from 'react'; import { Img } from 'react-image'; import { InView } from 'react-intersection-observer'; import styles from './image.module.css'; import { animationProps } from '/@/shared/components/animations/animation-props'; import { Icon } from '/@/shared/components/icon/icon'; import { Skeleton } from '/@/shared/components/skeleton/skeleton'; interface ImageContainerProps extends MotionConfigProps { children: React.ReactNode; className?: string; enableAnimation?: boolean; } interface ImageLoaderProps { className?: string; } interface ImageProps extends Omit, 'src'> { containerClassName?: string; enableAnimation?: boolean; imageContainerProps?: Omit; includeLoader?: boolean; includeUnloader?: boolean; src: string | string[] | undefined; thumbHash?: string; } interface ImageUnloaderProps { className?: string; } export function Image({ className, containerClassName, enableAnimation, imageContainerProps, includeLoader = true, includeUnloader = true, src, }: ImageProps) { if (src) { return ( {({ inView, ref }) => (
{inView && ( ( {children} )} loader={ includeLoader ? ( ) : null } src={src} unloader={ includeUnloader ? ( ) : null } /> )}
)}
); } return ; } function ImageContainer({ children, className, enableAnimation, ...props }: ImageContainerProps) { if (!enableAnimation) { return (
{children}
); } return ( {children} ); } function ImageLoader({ className }: ImageLoaderProps) { return (
); } function ImageUnloader({ className }: ImageUnloaderProps) { return (
); }