@@ -27,9 +27,20 @@ export default function NavBar() {
2727 const router = useRouter ( )
2828 const [ search , setSearch ] = useState ( '' )
2929 const [ menuOpen , setMenuOpen ] = useState ( false )
30+ const [ isScrolled , setIsScrolled ] = useState ( false )
3031
3132 const [ profile , setProfile ] = useState < UserProfile | null > ( null )
3233
34+ // Scroll detection
35+ useEffect ( ( ) => {
36+ const handleScroll = ( ) => {
37+ setIsScrolled ( window . scrollY > 20 )
38+ }
39+
40+ window . addEventListener ( 'scroll' , handleScroll )
41+ return ( ) => window . removeEventListener ( 'scroll' , handleScroll )
42+ } , [ ] )
43+
3344 useEffect ( ( ) => {
3445 if ( ! userId ) return
3546 getUserProfile ( userId )
@@ -50,11 +61,33 @@ export default function NavBar() {
5061 }
5162
5263 return (
53- < header className = "bg-gray-50 shadow-md sticky top-0 z-50" >
54- < div className = "md:px-16 p-3 flex justify-between items-center" >
64+ < motion . header
65+ className = "bg-gray-50 sticky top-0 z-50"
66+ initial = { { height : 'auto' , boxShadow : '0 1px 3px 0 rgb(0 0 0 / 0.1)' } }
67+ animate = { {
68+ height : isScrolled ? 56 : 'auto' ,
69+ boxShadow : isScrolled
70+ ? '0 4px 6px -1px rgb(0 0 0 / 0.1)'
71+ : '0 1px 3px 0 rgb(0 0 0 / 0.1)' ,
72+ } }
73+ transition = { { duration : 0.2 , ease : [ 0.4 , 0 , 0.2 , 1 ] } }
74+ >
75+ < div
76+ className = "md:px-16 p-3 flex justify-between items-center transition-all duration-200"
77+ style = { { padding : isScrolled ? '0.5rem 1rem' : undefined } }
78+ >
5579 { /* ๋ก๊ณ */ }
56- < Link href = "/" className = "hidden md:flex items-center mr-16" >
57- < div className = "text-2xl font-bold text-gray-800 font-logo" > Bubblog</ div >
80+ < Link href = "/" className = "flex items-center mr-4 md:mr-16" >
81+ < motion . div
82+ className = "font-bold text-gray-800 font-logo"
83+ animate = { {
84+ fontSize : isScrolled ? '1.25rem' : undefined ,
85+ } }
86+ transition = { { duration : 0.2 } }
87+ >
88+ < span className = "md:hidden" > B</ span >
89+ < span className = "hidden md:inline text-xl md:text-2xl" > Bubblog</ span >
90+ </ motion . div >
5891 </ Link >
5992
6093 { /* ๊ฒ์์ฐฝ */ }
@@ -161,6 +194,6 @@ export default function NavBar() {
161194 ) }
162195 </ nav >
163196 </ div >
164- </ header >
197+ </ motion . header >
165198 )
166199}
0 commit comments