-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(comments): add optional intent link to comments (#5576)
* feat(comments): add optional intent link to comments * refactor(comments): remove unused prop * feat(comments): only show intent link if intent preview param differs
- Loading branch information
Showing
17 changed files
with
264 additions
and
26 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
7 changes: 7 additions & 0 deletions
7
packages/sanity/src/structure/comments/src/context/intent/CommentsIntentContext.ts
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,7 @@ | ||
import {createContext} from 'react' | ||
|
||
import {type CommentsIntentContextValue} from './types' | ||
|
||
export const CommentsIntentContext = createContext<CommentsIntentContextValue | undefined>( | ||
undefined, | ||
) |
23 changes: 23 additions & 0 deletions
23
packages/sanity/src/structure/comments/src/context/intent/CommentsIntentProvider.tsx
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,23 @@ | ||
import {memo, type ReactNode} from 'react' | ||
|
||
import {type CommentIntentGetter} from '../../types' | ||
import {CommentsIntentContext} from './CommentsIntentContext' | ||
|
||
interface CommentsIntentProviderProps { | ||
children: ReactNode | ||
getIntent: CommentIntentGetter | ||
} | ||
|
||
/** | ||
* @beta | ||
* @hidden | ||
*/ | ||
export const CommentsIntentProvider = memo(function CommentsIntentProvider( | ||
props: CommentsIntentProviderProps, | ||
) { | ||
const {children, getIntent} = props | ||
|
||
return ( | ||
<CommentsIntentContext.Provider value={getIntent}>{children}</CommentsIntentContext.Provider> | ||
) | ||
}) |
2 changes: 2 additions & 0 deletions
2
packages/sanity/src/structure/comments/src/context/intent/index.ts
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,2 @@ | ||
export * from './CommentsIntentContext' | ||
export * from './CommentsIntentProvider' |
7 changes: 7 additions & 0 deletions
7
packages/sanity/src/structure/comments/src/context/intent/types.ts
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,7 @@ | ||
import {type CommentIntentGetter} from '../../types' | ||
|
||
/** | ||
* @beta | ||
* @hidden | ||
*/ | ||
export type CommentsIntentContextValue = CommentIntentGetter |
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.