-
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.
Merge pull request #191 from microsoft/add-collapsible-menu
Add collapsible menu
- Loading branch information
Showing
7 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
"use client"; | ||
|
||
import { useMenuContext } from "@/features/menu/menu-context"; | ||
|
||
export const ChatMenuContainer = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
const { isMenuOpen } = useMenuContext(); | ||
return <>{isMenuOpen ? children : null}</>; | ||
}; |
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,27 @@ | ||
import React, { createContext, useState } from "react"; | ||
|
||
interface MenuContextProps { | ||
isMenuOpen: boolean; | ||
toggleMenu: () => void; | ||
} | ||
|
||
export const MenuContext = createContext<MenuContextProps>({ | ||
isMenuOpen: true, | ||
toggleMenu: () => {}, | ||
}); | ||
|
||
export const MenuProvider = ({ children }: { children: React.ReactNode }) => { | ||
const [isMenuOpen, setIsMenuOpen] = useState(true); | ||
|
||
const toggleMenu = () => { | ||
setIsMenuOpen(!isMenuOpen); | ||
}; | ||
|
||
return ( | ||
<MenuContext.Provider value={{ isMenuOpen, toggleMenu }}> | ||
{children} | ||
</MenuContext.Provider> | ||
); | ||
}; | ||
|
||
export const useMenuContext = () => React.useContext(MenuContext); |
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,7 +1,12 @@ | ||
"use client"; | ||
|
||
import { SessionProvider } from "next-auth/react"; | ||
import { MenuProvider } from "./menu/menu-context"; | ||
|
||
export const Providers = ({ children }: { children: React.ReactNode }) => { | ||
return <SessionProvider>{children}</SessionProvider>; | ||
return ( | ||
<SessionProvider> | ||
<MenuProvider>{children}</MenuProvider> | ||
</SessionProvider> | ||
); | ||
}; |