Confirmation Dialogs

This commit is contained in:
Gregory Schier
2023-03-26 12:02:20 -07:00
parent 11b719955b
commit b2dcc38982
12 changed files with 150 additions and 43 deletions

16
src-web/hooks/Confirm.tsx Normal file
View 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>
);
}

View 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,
});
};
}