-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add document action custom dialog component (#4529)
* chore(core): add `DocumentActionCustomDialogComponentProps` to `DocumentActionDialogProps` * feat(desk): add custom dialog component, refactor document pane portal handling * refactor(desk): use custom dialog component in `DeleteAction` * dev(test-studio): add document action with custom dialog component
- Loading branch information
1 parent
c2f98ba
commit d6a841b
Showing
10 changed files
with
79 additions
and
13 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
dev/test-studio/documentActions/actions/TestCustomComponentAction.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,35 @@ | ||
import {Button, Card, Dialog, Stack, Text} from '@sanity/ui' | ||
import {DocumentActionComponent} from 'sanity' | ||
import React, {useCallback, useState} from 'react' | ||
|
||
export const TestCustomComponentAction: DocumentActionComponent = () => { | ||
const [open, setOpen] = useState<boolean>(false) | ||
const toggleOpen = useCallback(() => setOpen((v) => !v), []) | ||
|
||
return { | ||
label: 'Custom modal', | ||
tone: 'primary', | ||
onHandle: toggleOpen, | ||
dialog: { | ||
type: 'custom', | ||
component: open && ( | ||
<Dialog | ||
header="Custom action component" | ||
id="custom-modal" | ||
onClickOutside={toggleOpen} | ||
onClose={toggleOpen} | ||
width={1} | ||
footer={ | ||
<Stack padding={2}> | ||
<Button onClick={toggleOpen} text="Close" /> | ||
</Stack> | ||
} | ||
> | ||
<Card padding={5}> | ||
<Text>This dialog is rendered using a custom dialog component.</Text> | ||
</Card> | ||
</Dialog> | ||
), | ||
}, | ||
} | ||
} |
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
d6a841b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
performance-studio – ./
performance-studio.sanity.build
performance-studio-git-next.sanity.build
d6a841b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
test-studio – ./
test-studio-git-next.sanity.build
test-studio.sanity.build