-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollback SideBarLayoutContext.tsx and its implementation
- Loading branch information
SeverinoAmmirati
committed
Oct 26, 2023
1 parent
1b382cf
commit 23e729b
Showing
5 changed files
with
42 additions
and
7 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
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,34 @@ | ||
import { createContext, PropsWithChildren, ReactNode, useContext } from "react"; | ||
|
||
interface SideBarLayoutProviderProps { | ||
theme?: "dark" | "light"; | ||
footer?: ReactNode; | ||
brand?: ReactNode; | ||
userDropDownMenuToggle?: ReactNode; | ||
userDropDownMenu?: ReactNode; | ||
} | ||
|
||
interface SideBarLayoutContextProps extends SideBarLayoutProviderProps { | ||
theme: "dark" | "light"; | ||
} | ||
|
||
const SideBarLayoutContext = createContext<SideBarLayoutContextProps | null>(null); | ||
|
||
const SideBarLayoutProvider = (props: PropsWithChildren<SideBarLayoutProviderProps>) => { | ||
const { brand = null, children, footer = null, theme = "dark", userDropDownMenu, userDropDownMenuToggle } = props; | ||
return ( | ||
<SideBarLayoutContext.Provider value={{ brand, footer, theme, userDropDownMenu, userDropDownMenuToggle }}> | ||
{children} | ||
</SideBarLayoutContext.Provider> | ||
); | ||
}; | ||
|
||
const useSideBarLayoutContext = () => { | ||
const context = useContext(SideBarLayoutContext); | ||
if (context === null) { | ||
throw new Error("useSideBarLayoutContext must be used within a SideBarLayoutProvider"); | ||
} | ||
return context; | ||
}; | ||
|
||
export { SideBarLayoutProvider, useSideBarLayoutContext, SideBarLayoutProviderProps }; |