diff --git a/src/app/(routes)/document/[id]/(main)/@header/default.tsx b/src/app/(routes)/document/[id]/(main)/@header/default.tsx index fc2c469c..4c394a74 100644 --- a/src/app/(routes)/document/[id]/(main)/@header/default.tsx +++ b/src/app/(routes)/document/[id]/(main)/@header/default.tsx @@ -19,15 +19,42 @@ import { useQuery } from '@tanstack/react-query' import { queries } from '@/shared/lib/tanstack-query/query-keys' import ConfirmDialogWidget from '@/widget/confirm-dialog' import { useDeleteDocument } from '@/requests/document/hooks' +import { useEffect, useRef, useState } from 'react' // Header 컴포넌트 const Header = () => { const router = useRouter() const { id } = useParams() + + const [isTitleHidden, setIsTitleHidden] = useState(false) + const titleRef = useRef(null) + const { getPreviousPath } = usePreviousPath({ getCustomPath: true }) const { data } = useQuery(queries.document.item(Number(id))) const { mutate: deleteDocumentMutation } = useDeleteDocument() + useEffect(() => { + const observer = new IntersectionObserver( + ([entry]) => { + setIsTitleHidden(!entry.isIntersecting) + }, + { + root: null, + threshold: 0, + } + ) + + if (titleRef.current) { + observer.observe(titleRef.current) + } + + return () => { + if (titleRef.current) { + observer.unobserve(titleRef.current) + } + } + }, []) + const handleClickCancel = () => { const previousPath = getPreviousPath() previousPath ? router.replace(previousPath) : router.replace('/') @@ -55,8 +82,11 @@ const Header = () => {
- {/* 스크롤을 내려 제목이 뷰포트에서 사라지면 생길 텍스트 */} - {/*

최근 이슈

*/} + {isTitleHidden && ( + + {data?.documentName} + + )}
@@ -159,8 +189,10 @@ const Header = () => {
{/* data: 노트 제목, 문제 수, 글자 수, 마지막 수정 날짜 */} -
-

{data?.documentName}

+
+ + {data?.documentName} +
{data?.totalQuizCount}문제 diff --git a/src/features/document/components/swipeable-document-card/index.tsx b/src/features/document/components/swipeable-document-card/index.tsx index 761a7021..dcad072d 100644 --- a/src/features/document/components/swipeable-document-card/index.tsx +++ b/src/features/document/components/swipeable-document-card/index.tsx @@ -126,7 +126,9 @@ const SwipeableDocumentCard = ({
-

{title}

+

+ {title} +

{reviewCount && 복습 필요 {reviewCount}}