-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfirmDialogSimple.tsx
34 lines (31 loc) · 1.35 KB
/
ConfirmDialogSimple.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Button } from "@hilla/react-components/Button.js";
import { ConfirmDialog } from "@hilla/react-components/ConfirmDialog.js";
import { HorizontalLayout } from "@hilla/react-components/HorizontalLayout.js";
import { useState } from "react";
export default function ConfirmDialogSimple() {
const [opened, setOpened] = useState(true);
const [status, setStatus] = useState('');
return (
<>
<ConfirmDialog
opened={opened}
onOpenedChanged={({ detail: { value } }) => setOpened(value)}
header='Unsaved changes'
rejectButtonVisible={true}
rejectText='Discard'
onReject={() => setStatus('Discarded')}
cancelButtonVisible={true}
cancelText='Cancel'
onCancel={() => setStatus('Canceled')}
confirmText='Save'
onConfirm={() => setStatus('Saved')}
>
There are unsaved changes. Do you want to discard or save them?
</ConfirmDialog>
<HorizontalLayout style={{ alignItems: 'center', justifyContent: 'center' }} theme='spacing'>
<Button onClick={() => setOpened(!opened)}>Show dialog</Button>
<span hidden={!status}>Status: {status}</span>
</HorizontalLayout>
</>
);
}