-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show left navbar items below top navbar dropdown (#270)
* Show left navbar items below top navbar dropdown * Add global tooltips provider & context * Update tooltips hook to throw if used outside provider * Update shared/common/hooks/useTooltips.tsx Co-authored-by: James Clarke <[email protected]> --------- Co-authored-by: James Clarke <[email protected]>
- Loading branch information
Showing
5 changed files
with
46 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {createContext, PropsWithChildren, useState, useContext} from "react"; | ||
|
||
const GlobalTooltipsContext = createContext< | ||
[boolean, React.Dispatch<React.SetStateAction<boolean>>] | ||
>(null!); | ||
|
||
export function GlobalTooltipsProvider({children}: PropsWithChildren<{}>) { | ||
const [showTooltips, setShowTooltips] = useState(true); | ||
|
||
return ( | ||
<GlobalTooltipsContext.Provider value={[showTooltips, setShowTooltips]}> | ||
{children} | ||
</GlobalTooltipsContext.Provider> | ||
); | ||
} | ||
|
||
export function useTooltips() { | ||
const context = useContext(GlobalTooltipsContext); | ||
|
||
if (!context) { | ||
throw new Error( | ||
"useTooltips must be used within a GlobalTooltipsProvider" | ||
); | ||
} | ||
|
||
return context; | ||
} |
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