mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-14 01:18:15 -05:00
* improvement: panel tabs handler on click * fix: output break words * feat: keyboard navigation; improvement: SEO/GEO; refactor: file structure, unused fonts; fix: chat streaming, notification stack * feat: unresolved value handling on error; fix: layout refresh; refactor: delete old panel * refactor: control bar delete; improvement: workflow constants; fix: clear notifications keyboard shortcut * update developers count * fixed relative imports --------- Co-authored-by: waleed <walif6@gmail.com>
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
import NextImage, { type ImageProps as NextImageProps } from 'next/image'
|
|
import { Lightbox } from '@/components/ui/lightbox'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
interface ImageProps extends Omit<NextImageProps, 'className'> {
|
|
className?: string
|
|
enableLightbox?: boolean
|
|
}
|
|
|
|
export function Image({
|
|
className = 'w-full',
|
|
enableLightbox = true,
|
|
alt = '',
|
|
src,
|
|
...props
|
|
}: ImageProps) {
|
|
const [isLightboxOpen, setIsLightboxOpen] = useState(false)
|
|
|
|
const handleImageClick = () => {
|
|
if (enableLightbox) {
|
|
setIsLightboxOpen(true)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<NextImage
|
|
className={cn(
|
|
'overflow-hidden rounded-xl border border-border object-cover shadow-sm',
|
|
enableLightbox && 'cursor-pointer transition-opacity hover:opacity-90',
|
|
className
|
|
)}
|
|
alt={alt}
|
|
src={src}
|
|
onClick={handleImageClick}
|
|
{...props}
|
|
/>
|
|
|
|
{enableLightbox && (
|
|
<Lightbox
|
|
isOpen={isLightboxOpen}
|
|
onClose={() => setIsLightboxOpen(false)}
|
|
src={typeof src === 'string' ? src : String(src)}
|
|
alt={alt}
|
|
type='image'
|
|
/>
|
|
)}
|
|
</>
|
|
)
|
|
}
|