diff --git a/src/modules/browse/components/ShelfBrowseCarousel/index.js b/src/modules/browse/components/ShelfBrowseCarousel/index.js index 4d9dd305..2c64e9df 100644 --- a/src/modules/browse/components/ShelfBrowseCarousel/index.js +++ b/src/modules/browse/components/ShelfBrowseCarousel/index.js @@ -140,10 +140,12 @@ const ShelfBrowseCarousel = ({ callNumber, items, itemsPerPage, setButtonAction, <>
Book cover
-
diff --git a/src/modules/reusable/components/ImagePlaceholder/index.js b/src/modules/reusable/components/ImagePlaceholder/index.js index b3179c2a..5c305e00 100644 --- a/src/modules/reusable/components/ImagePlaceholder/index.js +++ b/src/modules/reusable/components/ImagePlaceholder/index.js @@ -2,31 +2,33 @@ import './styles.css'; import React, { useState } from 'react'; import PropTypes from 'prop-types'; -const ImagePlaceholder = ({ alt, index, src, ...rest }) => { - const [imageState, setImageState] = useState('loading'); +const ImagePlaceholder = ({ alt = '', altPlaceholder = '', index = 0, src = '', ...rest }) => { + const [imgState, setImgState] = useState('loading'); const [imgSrc, setImgSrc] = useState(src); + const [imgAlt, setImgAlt] = useState(alt); const handleImageLoad = () => { - setImageState('settled'); + setImgState('settled'); }; const handleImageError = () => { // Choosing between 15 placeholder images based on the index's remainder setImgSrc(`/placeholders/placeholder-${index % 15}.svg`); - setImageState('settled'); + setImgState('settled'); + setImgAlt(altPlaceholder); }; return ( <> {alt} - {imageState === 'loading' && ( + {imgState === 'loading' && (
{ ImagePlaceholder.propTypes = { alt: PropTypes.string, + altPlaceholder: PropTypes.string, index: PropTypes.number, src: PropTypes.string };