-
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.
refactor: fix cookie modal height, revert sidebar, separate context
- Loading branch information
Showing
18 changed files
with
268 additions
and
182 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
import SidebarContextProvider from "@/context/sidebar"; | ||
import MenuBtnRefContextProvider from "@/context/sidebar/btnRef"; | ||
|
||
import Nav from "./nav"; | ||
import TopBar from "./topbar"; | ||
import BackDrop from "./util/backdrop"; | ||
import InnerWrapper from "./util/innerWrapper"; | ||
import { MenuButton } from "./util/menuButton"; | ||
import MenuButton from "./util/menuButton"; | ||
|
||
export default function Sidebar() { | ||
return ( | ||
<> | ||
<div className="-mr-6 block h-[4.5rem] lg:hidden"> | ||
<MenuButton /> | ||
|
||
{/* <SwipeArea /> */} | ||
<InnerWrapper> | ||
<TopBar /> | ||
<Nav /> | ||
</InnerWrapper> | ||
<BackDrop /> | ||
</div> | ||
<SidebarContextProvider> | ||
<MenuBtnRefContextProvider> | ||
<div className="-mr-6 block h-[4.5rem] lg:hidden"> | ||
<MenuButton /> | ||
<BackDrop /> | ||
{/* <SwipeArea /> */} | ||
<InnerWrapper> | ||
<TopBar /> | ||
<Nav /> | ||
</InnerWrapper> | ||
</div> | ||
</MenuBtnRefContextProvider> | ||
</SidebarContextProvider> | ||
</> | ||
); | ||
} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,30 @@ | ||
"use client"; | ||
import { forwardRef } from "react"; | ||
|
||
import { useHeaderAPIContext } from "@/context/sidebar"; | ||
import { useSidebarContext } from "@/context/sidebar"; | ||
import { useMenuBtnRefContext } from "@/context/sidebar/btnRef"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
type Props = JSX.IntrinsicElements["button"]; | ||
|
||
type Ref = HTMLButtonElement; | ||
export const MenuButton = forwardRef<Ref, Props>(function MenuButton() { | ||
const { toggleSidebarDialog } = useHeaderAPIContext(); | ||
export default function MenuButton() { | ||
const { isExpanded, toggle } = useSidebarContext(); | ||
const { mainMenuBtnRef } = useMenuBtnRefContext(); | ||
return ( | ||
<> | ||
<button | ||
aria-expanded={false} | ||
aria-label={"open menu"} | ||
onClick={toggleSidebarDialog} | ||
aria-expanded={isExpanded} | ||
aria-label={isExpanded ? "Close menu" : "Open menu"} | ||
onClick={toggle} | ||
className={cn("relative z-[30] fill-[inherit] p-6")} | ||
aria-haspopup="menu" | ||
aria-controls="sidebarMenuNav" | ||
onKeyDown={(e) => { | ||
if (e.code === "Escape") toggle(); | ||
}} | ||
ref={mainMenuBtnRef} | ||
> | ||
<div className={cn("menuBtn h-6 w-6")}> | ||
<div className={cn("menuBtn h-6 w-6", isExpanded ? "opened" : "")}> | ||
<span></span> | ||
<span></span> | ||
<span></span> | ||
</div> | ||
</button> | ||
</> | ||
); | ||
}); | ||
} |
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,36 @@ | ||
"use client"; | ||
import { useEffect } from "react"; | ||
import { useInView } from "react-intersection-observer"; | ||
|
||
import { useHeaderContext } from "@/context/header"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
export default function HeaderWrapper({ children }: { children: React.ReactNode }) { | ||
const { setIsAtTop } = useHeaderContext(); | ||
const { ref, inView } = useInView({ | ||
threshold: 0, | ||
initialInView: true, | ||
fallbackInView: false, | ||
}); | ||
|
||
useEffect(() => { | ||
setIsAtTop(inView); | ||
}, [inView]); | ||
return ( | ||
<> | ||
<div ref={ref} className="absolute left-0 right-0 top-0 h-[1px] w-full"></div> | ||
<header | ||
className={cn( | ||
"fixed left-0 right-0 top-0 z-10", //position | ||
"flex items-center justify-center", //display | ||
"h-[8rem] w-full", //size | ||
"border-b-[1px] border-[transparent] bg-[initial]", //color | ||
"transition-all duration-300", //transition | ||
inView === true || undefined || null ? "" : "scrolled" | ||
)} | ||
> | ||
{children} | ||
</header> | ||
</> | ||
); | ||
} |
Oops, something went wrong.