anotation-frontend/src/pages/annotator/components/navigator/ThumbnailStrip.tsx

57 lines
1.9 KiB
TypeScript

import React from 'react'
import clsx from 'clsx'
import { useAnnotatorStore } from '../../annotatorStore'
import { ANNOTATOR_COLORS } from '../../annotatorTheme'
export const ThumbnailStrip: React.FC = () => {
const images = useAnnotatorStore((s) => s.images)
const currentImageIndex = useAnnotatorStore((s) => s.currentImageIndex)
const selectImageByIndex = useAnnotatorStore((s) => s.selectImageByIndex)
return (
<div className="grid grid-cols-6 gap-2.5 px-4 py-2.5">
{images.map((img, index) => {
const isActive = index === currentImageIndex
// Shorten "urban_00124.jpg" -> "..00124.jpg" matching wireframe
const shortName = img.fileName.replace(/^[a-z]+_/, '..')
return (
<button
key={img.id}
type="button"
onClick={() => selectImageByIndex(index)}
className="group flex flex-col items-center gap-1 focus:outline-none"
>
<div
className={clsx(
'relative aspect-video w-full overflow-hidden rounded-lg border-2 transition-all',
isActive
? 'shadow-xs'
: 'border-transparent opacity-85 hover:opacity-100'
)}
style={isActive ? { borderColor: ANNOTATOR_COLORS.selection } : undefined}
>
<img
src={img.thumbnailUrl}
alt={img.fileName}
className="h-full w-full object-cover"
/>
</div>
<span
className={clsx(
'font-mono text-[10px] transition-colors',
isActive
? 'font-semibold'
: 'text-slate-400 group-hover:text-slate-600'
)}
style={isActive ? { color: ANNOTATOR_COLORS.selection } : undefined}
>
{shortName}
</span>
</button>
)
})}
</div>
)
}