mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
* Code split using react lazy * Split locales * Move to lodash-es * Import individual icons
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import React from "react";
|
|
import { useFindGallery } from "src/core/StashService";
|
|
import { useLightbox } from "src/hooks";
|
|
import { LoadingIndicator } from "src/components/Shared";
|
|
import "flexbin/flexbin.css";
|
|
|
|
interface IProps {
|
|
galleryId: string;
|
|
}
|
|
|
|
export const GalleryViewer: React.FC<IProps> = ({ galleryId }) => {
|
|
const { data, loading } = useFindGallery(galleryId);
|
|
const images = data?.findGallery?.images ?? [];
|
|
const showLightbox = useLightbox({ images, showNavigation: false });
|
|
|
|
if (loading) return <LoadingIndicator />;
|
|
|
|
const thumbs = images.map((file, index) => (
|
|
<div
|
|
role="link"
|
|
tabIndex={index}
|
|
key={file.checksum ?? index}
|
|
onClick={() => showLightbox(index)}
|
|
onKeyPress={() => showLightbox(index)}
|
|
>
|
|
<img
|
|
src={file.paths.thumbnail ?? ""}
|
|
loading="lazy"
|
|
className="gallery-image"
|
|
alt={file.title ?? index.toString()}
|
|
/>
|
|
</div>
|
|
));
|
|
|
|
return (
|
|
<div className="gallery">
|
|
<div className="flexbin">{thumbs}</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default GalleryViewer;
|