Added transition to the sidebar
This commit is contained in:
parent
989b9e5ae9
commit
e767db6017
2 changed files with 28 additions and 12 deletions
components
|
@ -17,9 +17,9 @@ const Sidebar = () => {
|
|||
const isMobile = useWindowSize();
|
||||
const router = useRouter();
|
||||
const [active, setActive] = useState(isMobile);
|
||||
const { maps, isLoading, isError }:{ maps: ReadyOrNotMap[], isLoading: boolean, isError: boolean} = useNavbar();
|
||||
const { maps, isLoading, isError }: { maps: ReadyOrNotMap[], isLoading: boolean, isError: boolean } = useNavbar();
|
||||
|
||||
if(typeof(isMobile) === "boolean" && typeof(active) === "undefined") {
|
||||
if (typeof (isMobile) === "boolean" && typeof (active) === "undefined") {
|
||||
setActive(!isMobile);
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,15 @@ const Sidebar = () => {
|
|||
return (
|
||||
<>
|
||||
<div className={styles.sidebar} onClick={() => setActive(!active)}>
|
||||
<nav className={[styles.sidebarList, (active ? styles.sl_active : styles.sl_inactive)].join(" ")}>
|
||||
{maps.map((item) => (
|
||||
<Link key={item.name} href={item.href}>
|
||||
<a className={[styles.navElem, (router.query.map == item.href ? styles.ne_active : styles.ne_inactive)].join(" ")} onClick={stopPropagation}>{item.name}</a>
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
<div className={[styles.sl_wrapper, (active ? styles.sl_active : styles.sl_inactive)].join(" ")}>
|
||||
<nav className={styles.sidebarList}>
|
||||
{maps.map((item) => (
|
||||
<Link key={item.name} href={item.href}>
|
||||
<a className={[styles.navElem, (router.query.map == item.href ? styles.ne_active : styles.ne_inactive)].join(" ")} onClick={stopPropagation}>{item.name}</a>
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
<div className={styles.sidebarArrow}>
|
||||
<Image src={active ? "/sidebar_arrow_flipped.webp" : "/sidebar_arrow.webp"} width={32} height={96} alt={active ? ">" : "<"} />
|
||||
</div>
|
||||
|
|
Reference in a new issue