mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-12 23:36:00 +00:00
fix(source): fix gallery (#213)
* 3.0.82 * version number * fix gallery bug
This commit is contained in:
parent
4d0ffdffc6
commit
924195ce9f
@ -9,26 +9,25 @@ import type { Item } from '#types/Item'
|
|||||||
export const GalleryView = ({ item }: { item: Item }) => {
|
export const GalleryView = ({ item }: { item: Item }) => {
|
||||||
const [index, setIndex] = useState(-1)
|
const [index, setIndex] = useState(-1)
|
||||||
const appState = useAppState()
|
const appState = useAppState()
|
||||||
const images = item.gallery?.map((i, j) => {
|
const images =
|
||||||
return {
|
item.gallery?.map((i, j) => ({
|
||||||
src: appState.assetsApi.url + `${i.directus_files_id.id}.jpg`,
|
src: appState.assetsApi.url + `${i.directus_files_id.id}.jpg`,
|
||||||
width: i.directus_files_id.width,
|
width: i.directus_files_id.width,
|
||||||
height: i.directus_files_id.height,
|
height: i.directus_files_id.height,
|
||||||
index: j,
|
index: j,
|
||||||
}
|
})) ?? []
|
||||||
})
|
|
||||||
|
|
||||||
if (!images) throw new Error('GalleryView: images is undefined')
|
if (images.length > 0)
|
||||||
|
return (
|
||||||
|
<div className='tw:mx-6 tw:mb-6'>
|
||||||
|
<RowsPhotoAlbum
|
||||||
|
photos={images}
|
||||||
|
targetRowHeight={150}
|
||||||
|
onClick={({ index: current }) => setIndex(current)}
|
||||||
|
/>
|
||||||
|
|
||||||
return (
|
<ReactLightbox index={index} slides={images} open={index >= 0} close={() => setIndex(-1)} />
|
||||||
<div className='tw:mx-6 tw:mb-6'>
|
</div>
|
||||||
<RowsPhotoAlbum
|
)
|
||||||
photos={images}
|
else return <></>
|
||||||
targetRowHeight={150}
|
|
||||||
onClick={({ index: current }) => setIndex(current)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ReactLightbox index={index} slides={images} open={index >= 0} close={() => setIndex(-1)} />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user