Add Overlay/Backdrop for single images
This commit is contained in:
parent
416298e673
commit
705dcd2429
|
|
@ -5,8 +5,8 @@
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:react/recommended",
|
"plugin:react/recommended",
|
||||||
"airbnb",
|
"plugin:prettier/recommended",
|
||||||
"plugin:prettier/recommended"
|
"plugin:import/recommended"
|
||||||
],
|
],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"import/prefer-default-export": "off",
|
||||||
"no-unused-vars": [
|
"no-unused-vars": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { PhotoProps, RenderPhoto } from "react-photo-album";
|
||||||
|
import React from "react";
|
||||||
|
import { Backdrop } from "@mui/material";
|
||||||
|
|
||||||
|
export const Image: RenderPhoto = ({
|
||||||
|
imageProps: { alt, style, ...rest },
|
||||||
|
}: PhotoProps): JSX.Element => {
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const handleClose = () => {
|
||||||
|
setOpen(false);
|
||||||
|
};
|
||||||
|
const handleToggle = () => {
|
||||||
|
setOpen(!open);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<img
|
||||||
|
alt={alt}
|
||||||
|
style={{
|
||||||
|
...style,
|
||||||
|
}}
|
||||||
|
{...rest}
|
||||||
|
onClick={handleToggle}
|
||||||
|
/>
|
||||||
|
<Backdrop
|
||||||
|
sx={{ color: "#fff", zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
||||||
|
open={open}
|
||||||
|
onClick={handleClose}
|
||||||
|
>
|
||||||
|
<img alt={alt} {...rest} />
|
||||||
|
</Backdrop>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import PhotoAlbum, { Photo } from "react-photo-album";
|
import PhotoAlbum, { Photo } from "react-photo-album";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { Image } from "./Image";
|
||||||
|
|
||||||
function ImageGallery({ images }: { images: Photo[] }) {
|
function ImageGallery({ images }: { images: Photo[] }) {
|
||||||
// For all kind of settings see:
|
// For all kind of settings see:
|
||||||
|
|
@ -11,7 +12,7 @@ function ImageGallery({ images }: { images: Photo[] }) {
|
||||||
No images available. You may want to add images in your root directory.
|
No images available. You may want to add images in your root directory.
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<PhotoAlbum layout="masonry" photos={images} />
|
<PhotoAlbum layout="masonry" photos={images} renderPhoto={Image} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue