mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Confirmation Dialogs
This commit is contained in:
16
src-web/hooks/Confirm.tsx
Normal file
16
src-web/hooks/Confirm.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Button } from '../components/core/Button';
|
||||
import { HStack } from '../components/core/Stacks';
|
||||
|
||||
interface Props {
|
||||
hide: () => void;
|
||||
}
|
||||
export function Confirm({ hide }: Props) {
|
||||
return (
|
||||
<HStack space={2} justifyContent="end">
|
||||
<Button color="gray" onClick={hide}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button color="primary">Confirm</Button>
|
||||
</HStack>
|
||||
);
|
||||
}
|
||||
14
src-web/hooks/useConfirm.tsx
Normal file
14
src-web/hooks/useConfirm.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useDialog } from '../components/DialogContext';
|
||||
import { Confirm } from './Confirm';
|
||||
|
||||
export function useConfirm() {
|
||||
const dialog = useDialog();
|
||||
return ({ title, description }: { title: string; description?: string }) => {
|
||||
dialog.show({
|
||||
title,
|
||||
description,
|
||||
hideX: true,
|
||||
render: Confirm,
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user