From 2471cde6bdfbcc3bbc76f26656fdc79bd1f6bdb1 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 26 Sep 2023 09:33:01 +0700 Subject: Update Image component with next image --- src/core/components/elements/Image/Image.jsx | 45 ++++++++++++++++++---------- src/lib/product/components/ProductSlider.jsx | 3 +- 2 files changed, 31 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/core/components/elements/Image/Image.jsx b/src/core/components/elements/Image/Image.jsx index 1562444c..be275e8d 100644 --- a/src/core/components/elements/Image/Image.jsx +++ b/src/core/components/elements/Image/Image.jsx @@ -1,5 +1,6 @@ -import { LazyLoadImage } from 'react-lazy-load-image-component' -import 'react-lazy-load-image-component/src/effects/opacity.css' +import NextImage from 'next/image' +import { useState } from 'react' +import classNames from 'classnames' /** * The `Image` component is used to display lazy-loaded images. @@ -9,20 +10,32 @@ import 'react-lazy-load-image-component/src/effects/opacity.css' * @param {string} props.alt - Alternative text to be displayed if the image is not found. * @returns {JSX.Element} - Rendered `Image` component. */ -const Image = ({ ...props }) => ( - <> - - -) +const Image = ({ ...props }) => { + const [isLoading, setIsLoading] = useState(true) -Image.defaultProps = LazyLoadImage.defaultProps + const imageClassNames = classNames( + 'duration-500 ease-in-out', + { + 'blur-2xl grayscale': isLoading, + 'blur-0 grayscale-0': !isLoading + }, + props.className + ) + + return ( + <> + setIsLoading(false)} + /> + + ) +} export default Image diff --git a/src/lib/product/components/ProductSlider.jsx b/src/lib/product/components/ProductSlider.jsx index dedbd6ab..2f8101b0 100644 --- a/src/lib/product/components/ProductSlider.jsx +++ b/src/lib/product/components/ProductSlider.jsx @@ -10,7 +10,7 @@ import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' const bannerClassName = - 'absolute rounded-r top-0 left-0 h-full w-auto md:w-[20%] idt-transition border border-gray_r-6' + 'absolute rounded-r top-0 left-0 h-full w-auto md:w-[20%] border border-gray_r-6' const ProductSlider = ({ products, simpleTitle = false, bannerMode = false }) => { const bannerRef = useRef('') @@ -52,6 +52,7 @@ const ProductSlider = ({ products, simpleTitle = false, bannerMode = false }) => {bannerMode && (