PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / common / ConfirmDialog.tsx

ConfirmDialog.tsx in Code Snippets 4.0.0-beta.2, at js/components/common/ConfirmDialog.tsx

45 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react'
2 import { __ } from '@wordpress/i18n'
3 import { Button, Flex, Modal } from '@wordpress/components'
4 import type { ReactNode } from 'react'
5
6 export interface ConfirmDialogProps {
7 open?: boolean
8 title: string
9 onConfirm?: VoidFunction
10 onCancel: VoidFunction
11 confirmLabel?: string
12 cancelLabel?: string
13 children?: ReactNode,
14 confirmButtonClassName?: string
15 }
16
17 export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
18 open,
19 title,
20 onConfirm,
21 onCancel,
22 children,
23 confirmLabel = __('OK', 'code-snippets'),
24 cancelLabel = __('Cancel', 'code-snippets'),
25 confirmButtonClassName
26 }) =>
27 open
28 ? <Modal
29 title={title}
30 onRequestClose={onCancel}
31 closeButtonLabel={__('Close dialog', 'code-snippets')}
32 isDismissible={true}
33 >
34 {children}
35 <Flex direction="row" justify="flex-end">
36 <Button variant="tertiary" onClick={onCancel}>
37 {cancelLabel}
38 </Button>
39 <Button variant="primary" onClick={onConfirm} className={confirmButtonClassName}>
40 {confirmLabel}
41 </Button>
42 </Flex>
43 </Modal>
44 : null
45