diff --git a/src/components/home.jsx b/src/components/home.jsx index 513b17d..a43b607 100644 --- a/src/components/home.jsx +++ b/src/components/home.jsx @@ -38,9 +38,21 @@ function Home({ isDark, toggleDarkMode }) { }) const [waveSvg, setWaveSvg] = useState(() => waveInit(wave)) - + const [scrolled, setScrolled] = useState(false) + const handleScroll = () => { + const offset = window.scrollY + if (offset > 10) { + setScrolled(true) + } else { + setScrolled(false) + } + } useEffect(() => { setWaveSvg(waveInit(wave)) + window.addEventListener('scroll', handleScroll) + return () => { + window.removeEventListener('scroll', handleScroll) + } }, [wave]) const { height, xmlns, path, animatedPath } = waveSvg.svg @@ -155,7 +167,7 @@ function Home({ isDark, toggleDarkMode }) { return (
- + )} -
+
+

Svg @@ -49,4 +55,4 @@ function Navbar({ isDark, toggleDarkMode, color }) { ) } -export default Navbar +export default Navbar \ No newline at end of file diff --git a/src/styles/nav.css b/src/styles/nav.css index 46c3ef3..32a8c40 100644 --- a/src/styles/nav.css +++ b/src/styles/nav.css @@ -1,3 +1,23 @@ +.mydiv{ + display: flex; + flex-direction: column; +} + +.fixed { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 64px; + transition: background-color 0.3s, box-shadow 0.3s; +} + +.scrolled { + background-color: rgba(255, 255, 255, 0.8); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + z-index: 999999; +} + .nav-logo { /* font-family: 'Charmonman', cursive; */ font-size: 1.1rem; @@ -59,4 +79,4 @@ .not-mobile { display: none; } -} +} \ No newline at end of file