Refactor image rendering in ResultGrid with CSS enhancements

Simplified image rendering logic in `ResultGrid` by removing hover state management within JavaScript. Added `SampleImage.css` to handle hover effects for images and tooltips with scalable zoom. Cleaned up unnecessary comments and improved code readability.
This commit is contained in:
GotthardG 2025-02-27 15:24:28 +01:00
parent 37fe820f4a
commit da79115ba4
10 changed files with 36 additions and 47 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 KiB

View File

@ -71,56 +71,45 @@ const ResultGrid: React.FC<ResultGridProps> = ({ activePgroup }) => {
width: 300,
renderCell: (params) => {
const imageList: ImageInfo[] = params.value;
if (imageList && imageList.length) {
const primaryImage = imageList[0];
const imageUrl = basePath + primaryImage.filepath;
if (!imageList || imageList.length === 0) {
return null;
}
// Filter the images to include only the two bb_raster images
const filteredImages = imageList.filter(
(img) =>
img.filepath.includes("bb_raster_0") ||
img.filepath.includes("bb_raster_90")
);
if (filteredImages.length === 0) {
return null;
}
return (
<div style={{ display: 'flex', alignItems: 'center', position: 'relative' }}>
<img
src={imageUrl}
alt="sample"
className="zoom-image"
style={{ width: 40, height: 40, marginRight: 5, borderRadius: 4 }}
/>
{imageList.length > 1 && (
<div className="tooltip" style={{ position: 'relative', cursor: 'pointer' }}>
<span>+{imageList.length - 1}</span>
<div
className="tooltip-content"
style={{
display: 'none',
position: 'absolute',
top: '60px',
left: 0,
background: '#fff',
padding: '5px',
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
zIndex: 100,
}}
>
{imageList.slice(1).map((img) => {
<div style={{ display: 'flex', alignItems: 'center' }}>
{filteredImages.map((img) => {
const url = basePath + img.filepath;
return (
<img
key={img.id}
src={url}
alt={img.comment || 'additional sample'}
alt={img.comment || 'sample'}
className="zoom-image"
style={{ width: 40, height: 40, marginRight: 5, borderRadius: 4 }}
style={{
width: 40,
height: 40,
marginRight: 5,
borderRadius: 4,
}}
/>
);
})}
</div>
</div>
)}
</div>
);
}
return null;
},
},
];
return (