-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd736a5
commit d5e8318
Showing
9 changed files
with
88 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useTheme } from '~/utils/Navbar/ThemeProvider'; | ||
|
||
type Props = { | ||
sidePanelIsShown: boolean; | ||
setSidePanelIsShown: React.Dispatch<React.SetStateAction<boolean>>; | ||
}; | ||
|
||
export default function SidePanel( | ||
{sidePanelIsShown, setSidePanelIsShown} | ||
: Props){ | ||
const [theme, setTheme] = useTheme(); | ||
const toggleTheme = () => { | ||
setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light")); | ||
}; | ||
|
||
return <div | ||
className={(sidePanelIsShown ? "right-0" : "-right-96") + | ||
` fixed h-screen transition-[right] ease-in-out duration-500 | ||
w-96 max-w-full bg-gray-800 flex flex-col items-center` | ||
}> | ||
<button className='btn' | ||
onClick={()=>setSidePanelIsShown(false)}>CLOSE</button> | ||
<button className='btn' onClick={toggleTheme}>Theme: {theme}</button> | ||
</div> | ||
} |
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
File renamed without changes.
File renamed without changes.
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,22 @@ | ||
// navbar behavior: hide/show on scroll down/up | ||
import { useEffect, useState, useRef } from 'react'; | ||
|
||
export default function useScrollBehavior(): ({navIsShown: boolean}){ | ||
const lastScrollY = useRef<number>(0); // useRef allows handler to read updated data | ||
const [navIsShown, setNavIsShown] = useState<boolean>(true); | ||
|
||
const handleScroll = () => { | ||
setNavIsShown(window.scrollY <= lastScrollY.current); | ||
lastScrollY.current = window.scrollY; | ||
}; | ||
|
||
// set up scroll event listener | ||
useEffect(()=>{ | ||
window.addEventListener("scroll", handleScroll); | ||
return () => { | ||
window.removeEventListener("scroll", handleScroll); | ||
}; | ||
}, []) | ||
|
||
return { navIsShown }; | ||
} |