-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ 스크린 크기에 따라 페이지네이션 숫자 개수 변경 (#145)
* fix: 공지목록 웹버전 반응형 깨지던 것 수정 * feat: 모바일 크기 페이지네이션 개수 변동 * fix: 소식탭 페이지네이션 숫자 개수 변경
- Loading branch information
1 parent
9a8848c
commit c02c9ad
Showing
7 changed files
with
62 additions
and
16 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useCallback, useEffect, useState } from 'react'; | ||
|
||
const BREAK_POINT = { | ||
sm: 640 /* mobile min-width: 640px */, | ||
}; | ||
|
||
type ScreenType = 'mobile' | 'desktop'; | ||
|
||
export default function useResponsive() { | ||
const [screenType, setScreenType] = useState<ScreenType>('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 }; | ||
} |