Files
tkmind_go/ui/desktop/src/components/ImagePreview.tsx
T
Douwe Osinga 589f7c8279 Clean up css (#6944)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 23:07:20 +00:00

33 lines
954 B
TypeScript

import { useState } from 'react';
interface ImagePreviewProps {
src: string;
}
export default function ImagePreview({ src }: ImagePreviewProps) {
const [isExpanded, setIsExpanded] = useState(false);
const [error, setError] = useState(false);
if (error) {
return <div className="text-red-500 text-xs italic mt-1 mb-1">Unable to load image</div>;
}
return (
<div className={`image-preview mt-2 mb-2`}>
<img
src={src}
alt="goose image"
onError={() => setError(true)}
onClick={() => setIsExpanded(!isExpanded)}
className={`rounded border border-border-default cursor-pointer hover:border-border-default transition-all ${
isExpanded ? 'max-w-full max-h-96' : 'max-h-40 max-w-40'
}`}
style={{ objectFit: 'contain' }}
/>
<div className="text-xs text-text-muted mt-1">
Click to {isExpanded ? 'collapse' : 'expand'}
</div>
</div>
);
}