summaryrefslogtreecommitdiff
path: root/src/core/components
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-09-26 10:10:35 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-09-26 10:11:39 +0700
commit8402f53f80fe34dc926b9eebaab143884294cdb0 (patch)
treea77a3957e4fea19706f29caa61d8dcdac7bfe3b3 /src/core/components
parente0fde9bb4ef9299d78dae82221e6b16294d6c597 (diff)
Revert Image with Next Image to React Lazy Load
Diffstat (limited to 'src/core/components')
-rw-r--r--src/core/components/elements/Image/Image.jsx37
1 files changed, 11 insertions, 26 deletions
diff --git a/src/core/components/elements/Image/Image.jsx b/src/core/components/elements/Image/Image.jsx
index be275e8d..d7b19821 100644
--- a/src/core/components/elements/Image/Image.jsx
+++ b/src/core/components/elements/Image/Image.jsx
@@ -1,6 +1,5 @@
-import NextImage from 'next/image'
-import { useState } from 'react'
-import classNames from 'classnames'
+import { LazyLoadImage } from 'react-lazy-load-image-component'
+import 'react-lazy-load-image-component/src/effects/opacity.css'
/**
* The `Image` component is used to display lazy-loaded images.
@@ -11,30 +10,16 @@ import classNames from 'classnames'
* @returns {JSX.Element} - Rendered `Image` component.
*/
const Image = ({ ...props }) => {
- const [isLoading, setIsLoading] = useState(true)
-
- const imageClassNames = classNames(
- 'duration-500 ease-in-out',
- {
- 'blur-2xl grayscale': isLoading,
- 'blur-0 grayscale-0': !isLoading
- },
- props.className
- )
-
return (
- <>
- <NextImage
- {...props}
- src={props.src || '/images/noimage.jpeg'}
- alt={props.src ? props.alt : 'Image Not Found - Indoteknik'}
- key={props.src || '/images/noimage.jpeg'}
- className={imageClassNames}
- width={256}
- height={256}
- onLoadingComplete={() => setIsLoading(false)}
- />
- </>
+ <LazyLoadImage
+ {...props}
+ src={props.src || '/images/noimage.jpeg'}
+ placeholderSrc='/images/indoteknik-placeholder.png'
+ effect='opacity'
+ alt={props.src ? props.alt : 'Image Not Found - Indoteknik'}
+ wrapperClassName='bg-white'
+ loading='eager'
+ />
)
}