Skip to content

Commit f950c7f

Browse files
authored
Feat : 스크롤 내렸을때 맨 위로 버튼 추가 / Chore : 모달 이름 prop 삭제
Feat : 스크롤 내렸을때 맨 위로 버튼 추가 / Chore : 모달 이름 prop 삭제
2 parents fa6f135 + 66421a3 commit f950c7f

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

components/Layout/Container.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
import React from "react";
1+
import React, { useEffect, useState } from "react";
2+
import ToTopBtn from "@/components/toTopBtn/ToTopBtn";
23

34
interface ContainerProps {
45
children: React.ReactNode;
56
}
67

78
const Container = ({ children }: ContainerProps) => {
9+
const [showBtn, setShowBtn] = useState(false);
10+
11+
useEffect(() => {
12+
const handleScroll = () => {
13+
if (window.scrollY > 300) {
14+
setShowBtn(true);
15+
} else {
16+
setShowBtn(false);
17+
}
18+
};
19+
window.addEventListener("scroll", handleScroll);
20+
21+
return () => {
22+
window.removeEventListener("scroll", handleScroll);
23+
};
24+
}, []);
25+
826
return (
927
<div className="w-full max-w-[1125px] mx-auto p-[10px] md:p-10 lg:p-10 px-[32.5px]">
1028
{children}
29+
{showBtn && <ToTopBtn />}
1130
</div>
1231
);
1332
};

components/modal/AddFolderModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const AddFolderModal = ({ folderName }: { folderName: string }) => {
3737
return (
3838
<ModalContainer title="폴더 추가">
3939
<ModalInput
40-
placeholder="내용 입력"
40+
placeholder="이름을 입력해주세요"
4141
name={folderName}
4242
value={value}
4343
onChange={handleChange}

components/modal/SNSModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import ModalContainer from "./modalComponents/ModalContainer";
22
import ModalShare from "./modalComponents/ModalShare";
33

4-
const SNSModal = ({ folderName }: { folderName: string }) => {
4+
const SNSModal = () => {
55
return (
6-
<ModalContainer title="폴더 공유" subtitle={folderName}>
6+
<ModalContainer title="폴더 공유">
77
<ModalShare />
88
</ModalContainer>
99
);

components/modal/modalManager/ModalManager.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ export const Modal = () => {
5252
/>
5353
);
5454
case "SNSModal":
55-
return <SNSModal folderName={props.folderName || "폴더이름"} />;
55+
return (
56+
<SNSModal
57+
// folderName={props.folderName || "폴더이름"}
58+
/>
59+
);
5660
case "EditLink":
5761
return (
5862
<EditLink

components/toTopBtn/ToTopBtn.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { FaAngleUp } from "react-icons/fa6";
2+
3+
const ToTopBtn = () => {
4+
const handleClickToTop = () => {
5+
window.scrollTo({ top: 0 });
6+
};
7+
8+
return (
9+
<>
10+
<button
11+
type="button"
12+
onClick={handleClickToTop}
13+
className="fixed bottom-10 right-10 rounded-full border bg-white opacity-70 border-purple100 size-[40px] flex items-center justify-center"
14+
>
15+
<FaAngleUp fill="purple100" />
16+
</button>
17+
</>
18+
);
19+
};
20+
export default ToTopBtn;

pages/link/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const LinkPage = ({
6969
<div className="bg-gray100 w-full h-[219px] flex justify-center items-center">
7070
<AddLinkInput folderList={folderList} />
7171
</div>
72-
<main className="mt-[40px]">
72+
<main className="mt-[40px] relative">
7373
<Container>
7474
<SearchInput />
7575
{search && <SearchResultMessage message={search} />}

0 commit comments

Comments
 (0)