diff --git a/app/[locale]/community/news/NewsPageContent.tsx b/app/[locale]/community/news/NewsPageContent.tsx index 3f6cc8819..14da0a337 100644 --- a/app/[locale]/community/news/NewsPageContent.tsx +++ b/app/[locale]/community/news/NewsPageContent.tsx @@ -12,6 +12,7 @@ import { NEWS_TAGS } from '@/constants/tag'; import { NewsPreviewList } from '@/types/news'; import { useCustomSearchParams } from '@/utils/hooks/useCustomSearchParams'; +import useResponsive from '@/utils/hooks/useResponsive'; import { getPath } from '@/utils/page'; import { news } from '@/utils/segmentNode'; @@ -26,6 +27,7 @@ export default function NewsPageContent({ data: NewsPreviewList; }) { const { page, keyword, tags, setSearchParams } = useCustomSearchParams(); + const { screenType } = useResponsive(); const setCurrentPage = (pageNum: number) => { setSearchParams({ purpose: 'navigation', pageNum }); @@ -60,6 +62,7 @@ export default function NewsPageContent({ diff --git a/app/[locale]/community/notice/NoticeListHeader.tsx b/app/[locale]/community/notice/NoticeListHeader.tsx index 145c5ec8a..4eee33099 100644 --- a/app/[locale]/community/notice/NoticeListHeader.tsx +++ b/app/[locale]/community/notice/NoticeListHeader.tsx @@ -5,10 +5,14 @@ export default function NoticeListHeader({ isEditMode }: { isEditMode: boolean } return ( ); } diff --git a/app/[locale]/community/notice/NoticeListRow.tsx b/app/[locale]/community/notice/NoticeListRow.tsx index a518c3bf5..e58f7f8c5 100644 --- a/app/[locale]/community/notice/NoticeListRow.tsx +++ b/app/[locale]/community/notice/NoticeListRow.tsx @@ -19,8 +19,8 @@ interface NoticeListRowProps { export const NOTICE_ROW_CELL_WIDTH = { check: 'sm:w-[3.125rem]', pin: 'sm:w-[3.125rem]', - title: 'sm:w-[35.625rem]', - date: 'sm:w-auto', + title: 'sm:max-w-full', + date: 'sm:w-auto sm:min-w-[7.125rem]', } as const; export default function NoticeListRow({ @@ -80,7 +80,11 @@ function CheckboxCell({ isChecked, toggleCheck }: CheckboxCellProps) { function PrivateOrPinCell({ isPrivate, isPinned }: { isPrivate: boolean; isPinned: boolean }) { return ( - + {isPrivate ? : isPinned && } ); @@ -108,10 +112,10 @@ function TitleCell({ title, hasAttachment, id, isEditMode, isPinned }: TitleCell ); } else { return ( - + ()); const [isEditMode, toggleEditMode] = useReducer((editMode) => { changeSelectedIds({ type: 'RESET' }); @@ -78,6 +80,7 @@ export default function NoticePageContent({ { setSearchParams({ purpose: 'navigation', pageNum }); @@ -43,6 +45,7 @@ export default function SeminarContent({ data: { searchList, total } }: { data: diff --git a/components/common/Pagination.tsx b/components/common/Pagination.tsx index d8a11e738..bc4bb4cad 100644 --- a/components/common/Pagination.tsx +++ b/components/common/Pagination.tsx @@ -1,26 +1,29 @@ interface PaginationProps { totalPostsCount: number; - postsCountPerPage: number; // 한번에 보여줄 글 개수 + /** 한 페이지에 보여줄 글 개수 */ + postsCountPerPage: number; currentPage: number; + /** 페이지네이션 바에 보여줄 페이지 개수 */ + pageLimit?: number; setCurrentPage(pageNum: number): void; disabled?: boolean; } -const PAGE_LIMIT = 10; // 페이지네이션 바에 한번에 보여줄 페이지 개수 const MAX_PAGE = 10000; // totalPostsCount 실제값이 아닌 추정치가 왔을 경우 사용할 마지막 페이지 번호 export default function Pagination({ totalPostsCount, postsCountPerPage, currentPage, + pageLimit = 10, setCurrentPage, disabled = false, }: PaginationProps) { const numPages = Math.ceil((totalPostsCount || 1) / postsCountPerPage); // 전체 페이지 개수 - const firstNum = currentPage - ((currentPage - 1) % PAGE_LIMIT); // 페이지네이션 시작 번호 + const firstNum = currentPage - ((currentPage - 1) % pageLimit); // 페이지네이션 시작 번호 // fetch하는 동안 NUM_PAGES가 1이 되기에 최솟값이 1이도록 처리 - const paginationNumberCnt = Math.max(1, Math.min(PAGE_LIMIT, numPages - firstNum + 1)); + const paginationNumberCnt = Math.max(1, Math.min(pageLimit, numPages - firstNum + 1)); // 페이지 범위 넘어가면 마지막 페이지로 리다이렉트 if (numPages < currentPage) setCurrentPage(numPages); @@ -55,8 +58,8 @@ export default function Pagination({ numPages || disabled} + num={firstNum + pageLimit} + disabled={firstNum + pageLimit > numPages || disabled} movePageNumber={setCurrentPage} /> ('desktop'); + + const handleResize = useCallback(() => { + if (window.innerWidth < BREAK_POINT.sm && screenType !== 'mobile') { + setScreenType('mobile'); + } else if (window.innerWidth >= BREAK_POINT.sm && screenType !== 'desktop') { + setScreenType('desktop'); + } + }, [screenType]); + + useEffect(() => { + window.addEventListener('resize', handleResize); + return () => window.removeEventListener('resize', handleResize); + }, [handleResize]); + + return { screenType }; +}