-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d6a7fc
commit f467e1d
Showing
43 changed files
with
28,957 additions
and
28,540 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
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
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createContext, useContext } from '@wordpress/element'; | ||
|
||
interface PostContextProps { | ||
/** | ||
* The ID of the post. | ||
*/ | ||
postId?: number; | ||
|
||
/** | ||
* The type of the post. | ||
*/ | ||
postType?: string; | ||
|
||
/** | ||
* Whether the post is editable. | ||
*/ | ||
isEditable?: boolean; | ||
} | ||
|
||
export const DEFAULT_POST_CONTEXT = { | ||
postId: undefined, | ||
postType: undefined, | ||
isEditable: undefined, | ||
}; | ||
|
||
export const PostContext = createContext<PostContextProps>(DEFAULT_POST_CONTEXT); | ||
|
||
export const usePostContext = () => { | ||
return useContext(PostContext); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useMemo } from '@wordpress/element'; | ||
import { PostContext as PostContextContext } from './context'; | ||
|
||
interface PostContextProps { | ||
/** | ||
* The ID of the post. | ||
*/ | ||
postId: number; | ||
|
||
/** | ||
* The type of the post. | ||
*/ | ||
postType: string; | ||
|
||
/** | ||
* Whether the post is editable. | ||
*/ | ||
isEditable?: boolean; | ||
|
||
/** | ||
* The children to render. | ||
*/ | ||
children: React.ReactNode; | ||
} | ||
|
||
export const PostContext = ({ | ||
children, | ||
postId, | ||
postType, | ||
isEditable = false, | ||
}: PostContextProps) => { | ||
const value = useMemo( | ||
() => ({ | ||
postId, | ||
postType, | ||
isEditable, | ||
}), | ||
[postId, postType, isEditable], | ||
); | ||
|
||
return <PostContextContext.Provider value={value}>{children}</PostContextContext.Provider>; | ||
}; |
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
Oops, something went wrong.