summaryrefslogtreecommitdiff
path: root/src/core/components/elements/Image/Image.jsx
blob: ba6bf50d280b3766c8b9f910d18cf592b35ddbcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.
 *
 * @param {Object} props - Props passed to the `Image` component.
 * @param {string} props.src - URL of the image to be displayed.
 * @param {string} props.alt - Alternative text to be displayed if the image is not found.
 * @returns {JSX.Element} - Rendered `Image` component.
 */
const Image = ({ ...props }) => (
  <>
    <LazyLoadImage
      {...props}
      src={props.src || '/images/noimage.jpeg'}
      placeholderSrc='/images/indoteknik-placeholder.png'
      alt={props.src ? props.alt : 'Image Not Found - Indoteknik'}
      wrapperClassName='bg-white'
    />
  </>
)

Image.defaultProps = LazyLoadImage.defaultProps

export default Image