-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from U2DJ2/frontend/refactor
refactor: 로그인 부분 코드 리팩토링 진행
- Loading branch information
Showing
11 changed files
with
158 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { HiOutlineExclamationCircle } from "react-icons/hi"; | ||
import { Modal } from "flowbite-react"; | ||
import ModalTheme from "../AlertModal/modalTheme.js"; | ||
|
||
export default function AlertModal({show, onClose, message}) { | ||
return( | ||
<> | ||
<Modal show={show} size="lg" onClose={onClose} theme={ModalTheme} popup> | ||
<Modal.Header /> | ||
<Modal.Body> | ||
<div className="text-center"> | ||
<HiOutlineExclamationCircle className="mx-auto mb-4 h-14 w-14 text-gray-400 dark:text-gray-200" /> | ||
<h3 className="mb-5 text-base font-Pretendard_Normal text-black"> | ||
{message} | ||
</h3> | ||
<div className="flex justify-center gap-4"> | ||
<button | ||
className="py-3 px-5 w-fit text-base font-Pretendard_Normal text-white bg-scarlet rounded-[50px] hover:cursor-pointer" | ||
onClick={onClose} | ||
> | ||
다시 입력하기 | ||
</button> | ||
</div> | ||
</div> | ||
</Modal.Body> | ||
</Modal> | ||
</> | ||
) | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
frontend/moim_front/src/components/AlertModal/modalTheme.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const modalTheme = { | ||
"root": { | ||
"base": "fixed inset-x-0 top-0 z-50 h-screen overflow-y-auto overflow-x-hidden md:inset-0 md:h-full", | ||
"show": { | ||
"on": "flex bg-gray-900 bg-opacity-50 dark:bg-opacity-80", | ||
"off": "hidden" | ||
}, | ||
"sizes": { | ||
"sm": "max-w-sm", | ||
"md": "max-w-md", | ||
"lg": "max-w-lg", | ||
"xl": "max-w-xl", | ||
"2xl": "max-w-2xl", | ||
"3xl": "max-w-3xl", | ||
"4xl": "max-w-4xl", | ||
"5xl": "max-w-5xl", | ||
"6xl": "max-w-6xl", | ||
"7xl": "max-w-7xl" | ||
}, | ||
"positions": { | ||
"top-left": "items-start justify-start", | ||
"top-center": "items-start justify-center", | ||
"top-right": "items-start justify-end", | ||
"center-left": "items-center justify-start", | ||
"center": "items-center justify-center", | ||
"center-right": "items-center justify-end", | ||
"bottom-right": "items-end justify-end", | ||
"bottom-center": "items-end justify-center", | ||
"bottom-left": "items-end justify-start" | ||
} | ||
}, | ||
"content": { | ||
"base": "relative h-full w-full p-4 md:h-auto", | ||
"inner": "relative flex max-h-[90dvh] flex-col rounded-xl bg-white shadow dark:bg-gray-700" | ||
}, | ||
"body": { | ||
"base": "flex-1 overflow-auto p-6", | ||
"popup": "pt-0" | ||
}, | ||
"header": { | ||
"base": "flex items-start justify-between rounded-t border-b mt-0.5 p-5 dark:border-gray-600", | ||
"popup": "border-b-0 p-2", | ||
"title": "pt-0.5 text-xl font-Pretendard_SemiBold text-gray-900 dark:text-white", | ||
"close": { | ||
"base": "ml-auto inline-flex items-center rounded-lg bg-transparent p-1.5 text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white", | ||
"icon": "h-5 w-5" | ||
} | ||
}, | ||
"footer": { | ||
"base": "flex items-center space-x-2 rounded-b border-gray-200 p-6 dark:border-gray-600", | ||
"popup": "border-t" | ||
} | ||
} | ||
export default modalTheme; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
..._front/src/components/Modal/ModalTest.jsx → .../components/CloseModal/CloseModalTest.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useState, useCallback } from "react"; | ||
|
||
export default function useModal () { | ||
const [showModal, setShowModal] = useState(false); | ||
const [message, setMessage] = useState(""); | ||
|
||
const openModal = useCallback((newMessage) => { | ||
setMessage(newMessage); | ||
setShowModal(true) | ||
},[]); | ||
|
||
const closeModal = useCallback(()=>{ | ||
setShowModal(false); | ||
setMessage(""); | ||
},[]) | ||
|
||
return {showModal, setShowModal, message, openModal, closeModal} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {useState, useEffect} from 'react' | ||
|
||
/** | ||
* 화면 크기가 작은지 여부를 반환하는 커스텀 훅 | ||
* @param {number} breakpoint - 기준 화면 크기 (픽셀) | ||
* @returns {boolean} isSmall - 화면 크기가 작은지 여부 | ||
*/ | ||
|
||
export default function useResize(breakpoint){ | ||
const [isSmall, setIsSmall] = useState(false); | ||
|
||
useEffect(()=>{ | ||
const handleResize = () => { | ||
setIsSmall(window.innerWidth < breakpoint); | ||
} | ||
|
||
window.addEventListener("resize", handleResize); | ||
handleResize(); | ||
|
||
return () => { | ||
window.removeEventListener("resize", handleResize); | ||
} | ||
}, [breakpoint]); | ||
return isSmall; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters