Skip to content

Commit

Permalink
fix:#9 모달 스크롤 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
frombozztoang committed Mar 15, 2024
1 parent 049a323 commit 06e1f85
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 168 deletions.
14 changes: 3 additions & 11 deletions src/components/atoms/button/modal/YesButton.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import React from "react";
import React from 'react';

const YesButton = ({
info,
handler,
isOne,
}: {
info: string;
handler: () => void;
isOne: boolean;
}) => {
const YesButton = ({ info, handler, isOne }: { info: string; handler: () => void; isOne: boolean }) => {
return (
<button
className={`transition-opacity duration-500 ease-in-out hover:opacity-50 rounded-8 ${
isOne ? "w-280" : "w-120"
isOne ? 'w-248' : 'w-120'
} h-44 bg-main-point text-white flex items-center justify-center`}
onClick={() => {
handler();
Expand Down
57 changes: 0 additions & 57 deletions src/components/molecules/modal/ModalView.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions src/components/organisms/modal/Modal.stories.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/organisms/modal/Modal.tsx

This file was deleted.

39 changes: 39 additions & 0 deletions src/components/organisms/modal/ModalView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import NoButton from '@/components/atoms/button/modal/NoButton';
import YesButton from '@/components/atoms/button/modal/YesButton';
import useDeviceType from '@/hooks/useDeviceType';
import { container } from '@/styles/animations';
import { ModalViewProps } from '@/types/Modal';
import { motion } from 'framer-motion';
import React from 'react';

const ModalView = ({ children, isOpen, noBtn, yesBtn, ...props }: ModalViewProps) => {
const deviceType = useDeviceType();
return (
<>
<motion.div
variants={container}
initial='hidden'
animate='show'
exit='exit'
className={`fixed h-screen flex items-center justify-center bg-[#00000060] z-modal transition-all ${
deviceType === 'mobile' ? 'w-screen' : 'w-max px-40'
}`}
>
<div className='rounded-16 min-h-fit bg-white'>
{children}
<div className='mb-16 flex items-center justify-center'>
{noBtn && yesBtn && (
<div className=' flex items-center w-full justify-center medium-medium'>
<NoButton info={noBtn.info} handler={() => noBtn.handler()} />
<YesButton isOne={false} info={yesBtn.info} handler={() => yesBtn.handler()} />
</div>
)}
{!noBtn && yesBtn && <YesButton isOne={true} info={yesBtn.info} handler={() => yesBtn.handler()} />}
</div>
</div>
</motion.div>
</>
);
};

export default ModalView;
33 changes: 0 additions & 33 deletions src/components/organisms/modal/auth/AuthCheckingModalContent.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ModalView from "@/components/molecules/modal/ModalView";
import ModalView from "@/components/organisms/modal/ModalView";
import { COLORS } from "@/constants/letterColors";
import React, { useState } from "react";
import LetterModalContent from "./WriteModalContent";
Expand Down
14 changes: 9 additions & 5 deletions src/components/organisms/navigation/navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ import { AnimatePresence } from "framer-motion";

const Navigation = () => {
const [isOpened, setIsOpened] = useState(false);
if (isOpened) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "auto";
}
useEffect(() => {
if (typeof document !== "undefined") {
if (isOpened) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "auto";
}
}
}, [isOpened]);
const handleIsOpened = () => {
setIsOpened(!isOpened);
};
Expand Down
16 changes: 10 additions & 6 deletions src/hooks/useModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";

const useModal = () => {
const [isOpen, setIsOpen] = useState(false);
Expand All @@ -8,11 +8,15 @@ const useModal = () => {
const closeModal = () => {
setIsOpen(false);
};
if (isOpen) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "auto";
}
useEffect(() => {
if (typeof document !== "undefined") {
if (isOpen) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "auto";
}
}
}, [isOpen]);
return {
isOpen,
openModal,
Expand Down

0 comments on commit 06e1f85

Please sign in to comment.