mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(component): new hook to open confirm modal (#6342)
new exports from `@affine/component`:
```ts
import { ConfirmModalProvider, useConfirmModal } from "@affine/component"
```
Open confirm modal with hook:
```ts
const Component = () => {
const { openConfirmModal } = useConformModal();
const open = () => {
openConfirmModal({
// props of ConfirmModal
/**
* will show loading state when confirm clicked, and close after onConfirm finished
*/
onConfirm: async () => {
await new Promise((r) => setTimeout(r, 2000));
},
});
}
return <Button onClick={open}>Open</Button>
}
```
This commit is contained in:
@@ -65,6 +65,10 @@ export const modalFooter = style({
|
||||
'&.modalFooterWithChildren': {
|
||||
paddingTop: '20px',
|
||||
},
|
||||
'&.reverse': {
|
||||
flexDirection: 'row-reverse',
|
||||
justifyContent: 'flex-start',
|
||||
},
|
||||
},
|
||||
});
|
||||
export const confirmModalContent = style({
|
||||
|
||||
Reference in New Issue
Block a user