Spaces:
Runtime error
Runtime error
fix img modal
Browse files- components/modal/modal.tsx +14 -4
components/modal/modal.tsx
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11 |
import { useCollection } from "./useCollection";
|
12 |
import { Button } from "../button";
|
13 |
import { useUser } from "@/utils/useUser";
|
14 |
-
import { useKeyPressEvent } from "react-use";
|
15 |
|
16 |
interface Props {
|
17 |
id: string;
|
@@ -37,8 +37,6 @@ const dropIn = {
|
|
37 |
},
|
38 |
};
|
39 |
|
40 |
-
const keys = ["ArrowLeft", "ArrowRight"];
|
41 |
-
|
42 |
export const Modal: React.FC<Props> = ({ id, onClose }) => {
|
43 |
const { collection, updateVisibility, remove, next, previous } =
|
44 |
useCollection(id);
|
@@ -53,10 +51,22 @@ export const Modal: React.FC<Props> = ({ id, onClose }) => {
|
|
53 |
return date.toLocaleDateString();
|
54 |
}, [collection?.createdAt]);
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
return (
|
57 |
<motion.div
|
58 |
onClick={onClose}
|
59 |
-
className="fixed top-0 w-screen h-screen left-0 bg-black/30 backdrop-blur-sm z-50 flex items-
|
60 |
initial={{ opacity: 0 }}
|
61 |
animate={{ opacity: 1 }}
|
62 |
exit={{ opacity: 0 }}
|
|
|
11 |
import { useCollection } from "./useCollection";
|
12 |
import { Button } from "../button";
|
13 |
import { useUser } from "@/utils/useUser";
|
14 |
+
import { useKeyPressEvent, useUpdateEffect } from "react-use";
|
15 |
|
16 |
interface Props {
|
17 |
id: string;
|
|
|
37 |
},
|
38 |
};
|
39 |
|
|
|
|
|
40 |
export const Modal: React.FC<Props> = ({ id, onClose }) => {
|
41 |
const { collection, updateVisibility, remove, next, previous } =
|
42 |
useCollection(id);
|
|
|
51 |
return date.toLocaleDateString();
|
52 |
}, [collection?.createdAt]);
|
53 |
|
54 |
+
useUpdateEffect(() => {
|
55 |
+
if (collection?.id) {
|
56 |
+
document.body.style.overflow = "hidden";
|
57 |
+
document.documentElement.style.overflow = "hidden";
|
58 |
+
} else {
|
59 |
+
document.body.style.overflow = "unset";
|
60 |
+
document.documentElement.style.overflow = "unset";
|
61 |
+
document.documentElement.style.overflowX = "hidden";
|
62 |
+
document.body.style.overflowX = "hidden";
|
63 |
+
}
|
64 |
+
}, [collection]);
|
65 |
+
|
66 |
return (
|
67 |
<motion.div
|
68 |
onClick={onClose}
|
69 |
+
className="fixed top-0 w-screen h-screen left-0 bg-black/30 backdrop-blur-sm z-50 flex items-start justify-center px-6 pb-6 pt-6 lg:pt-20"
|
70 |
initial={{ opacity: 0 }}
|
71 |
animate={{ opacity: 1 }}
|
72 |
exit={{ opacity: 0 }}
|