Skip to content

Commit a4f29d9

Browse files
authored
Merge pull request #123 from Team-INSERT/refactor/all
모든 페이지 리팩토링
2 parents 9f283eb + acdebcb commit a4f29d9

File tree

419 files changed

+2004
-3499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

419 files changed

+2004
-3499
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"@types/node": "18.16.19",
1818
"@types/react": "18.2.14",
1919
"@types/react-dom": "18.2.6",
20-
"@types/react-infinite-scroll-component": "^5.0.0",
2120
"@types/react-spinner": "^0.2.0",
2221
"@types/styled-components": "^5.1.26",
2322
"@types/tinymce": "^4.6.5",
@@ -38,6 +37,7 @@
3837
"graphql": "^16.8.0",
3938
"graphql-request": "^6.1.0",
4039
"jest": "^29.3.1",
40+
"jotai": "^2.5.1",
4141
"jwt-decode": "^3.1.2",
4242
"msw": "^1.2.3",
4343
"next": "13.5.2",
@@ -47,15 +47,12 @@
4747
"react-circular-progressbar": "^2.1.0",
4848
"react-d3-radar": "^1.0.0-rc6",
4949
"react-dom": "18.2.0",
50-
"react-infinite-scroll-component": "^6.1.0",
51-
"react-responsive-carousel": "^3.2.23",
5250
"react-scroll-horizontal": "^1.6.6",
5351
"react-slick": "^0.29.0",
5452
"react-spinner": "^0.2.7",
5553
"react-spinner-overlay": "^0.1.33",
5654
"react-spinners": "^0.13.8",
5755
"react-toastify": "^9.1.3",
58-
"recoil": "^0.7.7",
5956
"rehype-sanitize": "^6.0.0",
6057
"slick-carousel": "^1.8.1",
6158
"styled-components": "^6.0.8",

src/@modal/context/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as modalContext } from "./modal.context";

src/@modal/context/modal.context.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { atom } from "jotai";
2+
import { ModalState } from "../types";
3+
4+
const modalContext = atom<ModalState>({
5+
component: null,
6+
visible: false,
7+
});
8+
9+
export default modalContext;

src/@modal/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as useModal } from "./useModal";

src/@modal/hooks/useModal.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react";
2+
import { useAtom } from "jotai";
3+
import { ModalState } from "../types";
4+
import { modalContext } from "../context";
5+
6+
const useModal = () => {
7+
const [modal, setModal] = useAtom(modalContext);
8+
9+
const openModal = React.useCallback(
10+
({ component }: ModalState) => {
11+
setModal({ component, visible: true });
12+
},
13+
[setModal],
14+
);
15+
16+
const closeModal = React.useCallback(() => {
17+
setModal({ component: null, visible: false });
18+
}, [setModal]);
19+
20+
return { openModal, closeModal, visible: !!modal.visible };
21+
};
22+
23+
export default useModal;
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import { useRouter } from "next/navigation";
2+
import styled from "styled-components";
13
import { Logo } from "@/assets/icons";
24
import { ROUTER } from "@/constants";
35
import useWindow from "@/hooks/useWindow";
4-
import { color, flex, font } from "@/styles";
5-
import { useRouter } from "next/navigation";
6-
import React from "react";
7-
import styled from "styled-components";
6+
import { theme, flex, font } from "@/styles";
87

98
const LoginModal = () => {
109
const router = useRouter();
@@ -19,7 +18,9 @@ const LoginModal = () => {
1918
return (
2019
<Container>
2120
<Logo width={60} height={60} />
22-
<LoginButton onClick={handleLoginButtonClick} />
21+
<LoginButton onClick={handleLoginButtonClick}>
22+
BSM 계정으로 로그인
23+
</LoginButton>
2324
</Container>
2425
);
2526
};
@@ -28,7 +29,7 @@ const Container = styled.div`
2829
width: fit-content;
2930
height: fit-content;
3031
padding: 40px 30px;
31-
background-color: ${color.white};
32+
background-color: ${theme.white};
3233
border-radius: 6px;
3334
${flex.COLUMN_CENTER};
3435
gap: 5vh;
@@ -38,13 +39,9 @@ const LoginButton = styled.button`
3839
width: fit-content;
3940
border-radius: 4px;
4041
padding: 8px 14px;
41-
background-color: ${color.primary_blue};
42-
color: ${color.white};
42+
background-color: ${theme.primary_blue};
43+
color: ${theme.white};
4344
${font.btn3};
44-
45-
&:after {
46-
content: "BSM 계정으로 로그인";
47-
}
4845
`;
4946

5047
export default LoginModal;

src/components/common/Modal/View.tsx renamed to src/@modal/layouts/ModalView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import styled, { css } from "styled-components";
2-
import { IModalState } from "@/interfaces";
2+
import { flex } from "@/styles";
3+
import { ModalState } from "../types";
34

4-
interface ModalViewProps extends IModalState {
5+
interface ModalViewProps extends ModalState {
56
onClose?: () => void;
67
}
78

@@ -32,8 +33,7 @@ const Background = styled.div<{ hidden: boolean }>`
3233
`;
3334

3435
const ModalContainer = styled.div`
35-
display: flex;
36-
flex-direction: column;
36+
${flex.COLUMN_CENTER};
3737
position: fixed;
3838
top: 50%;
3939
left: 50%;

src/@modal/layouts/index.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useAtomValue } from "jotai";
2+
import { modalContext } from "../context";
3+
import { useModal } from "../hooks";
4+
import ModalView from "./ModalView";
5+
6+
const Modal = () => {
7+
const modal = useAtomValue(modalContext);
8+
const { closeModal } = useModal();
9+
10+
const handleModalClose = () => {
11+
modal.onClose?.();
12+
if (!modal.menualClose) closeModal();
13+
};
14+
15+
return <ModalView {...modal} onClose={handleModalClose} />;
16+
};
17+
18+
export default Modal;

src/interfaces/modal.interface.ts renamed to src/@modal/types/ModalState.type.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import React from "react";
2-
3-
export default interface IModalState {
1+
export default interface ModalState {
42
component: React.ReactNode;
53
visible?: boolean;
64
menualClose?: boolean;

src/@modal/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type { default as ModalState } from "./ModalState.type";

0 commit comments

Comments
 (0)