fix white border AND little tweak

This commit is contained in:
MathieuG-P
2022-12-19 02:41:12 +01:00
parent b8e2bb73f5
commit b8abe30e39
2 changed files with 16 additions and 11 deletions
@@ -15,8 +15,10 @@ export const BsmImage = forwardRef(({className, image, errorImage, placeholder,
const [isLoaded, setIsLoaded] = useState(false);
image = image ? image : (placeholder||errorImage);
const styles: CSSProperties = (() => {
return placeholder && {
return {
...style,
...(!isLoaded && {backgroundImage: `url(${placeholder})`}),
...(!isLoaded && {backgroundSize: "cover"}),
@@ -25,6 +27,7 @@ export const BsmImage = forwardRef(({className, image, errorImage, placeholder,
})();
const handleError = (e: SyntheticEvent<HTMLImageElement, Event>) => {
console.log("ERROR");
e.currentTarget.onerror = null;
e.currentTarget.src = errorImage || "";
}
@@ -35,6 +38,6 @@ export const BsmImage = forwardRef(({className, image, errorImage, placeholder,
return (
// @ts-ignore
<img ref={ref} title={title} className={className} src={image} loading={loading} onLoad={handleLoaded} onError={handleError} style={styles} onClick={(e) => onClick?.(e)}/>
<img ref={ref} title={title} className={className} src={image} loading={loading} onLoad={handleLoaded} onError={handleError} style={styles} onClick={(e) => onClick?.(e)} alt=" "/>
)
})