Feat Widgets

This commit is contained in:
2025-09-01 14:04:40 -03:00
parent 608ae655be
commit 12860f2406
30 changed files with 1904 additions and 247 deletions

View File

@@ -0,0 +1,28 @@
// src/components/ImageWithFallback.tsx
import { useState, useEffect } from 'react';
interface Props extends React.ImgHTMLAttributes<HTMLImageElement> {
fallbackSrc: string;
}
export const ImageWithFallback = ({ src, fallbackSrc, ...props }: Props) => {
const [imgSrc, setImgSrc] = useState(src);
const [error, setError] = useState(false);
useEffect(() => {
setError(false);
setImgSrc(src);
}, [src]);
const handleError = () => {
setError(true);
};
return (
<img
src={error || !imgSrc ? fallbackSrc : imgSrc}
onError={handleError}
{...props}
/>
);
};