-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥌 no component wrapping, base node renderers now doing tha' thing
- Loading branch information
1 parent
a487a0a
commit 62bc3f7
Showing
6 changed files
with
76 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useContext } from 'react'; | ||
import type { KINDS } from './types'; | ||
|
||
type BlockContextType = { | ||
parent: string; | ||
context: KINDS; | ||
}; | ||
|
||
const BlockContext = React.createContext<BlockContextType | undefined>(undefined); | ||
|
||
export function BlockContextProvider({ | ||
id, | ||
pageKind, | ||
children, | ||
}: React.PropsWithChildren<{ id: string; pageKind: KINDS }>) { | ||
return ( | ||
<BlockContext.Provider value={{ parent: id, context: pageKind }}> | ||
{children} | ||
</BlockContext.Provider> | ||
); | ||
} | ||
|
||
export function useBlockContext() { | ||
const context = useContext(BlockContext); | ||
if (!context) console.debug('useBlockContext used outside of a BlockContextProvider'); | ||
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