File size: 1,442 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Accept

Accept is a stylized substitute to the browser `confirm` dialog.

![Example](https://cldup.com/FS-PWXvga0-1200x1200.png)

## Arguments

- `message` - A string that gets displayed to the user in the cofirm dialog.
- `callback` - A callback that gets called after confirms or cancels the dialog.
- `confirmButtonText` - Optional confirm button text, defaults to 'OK'.
- `cancelButtonText` - Optional cancel button text, defaults to 'Cancel'.
- `options` - Optional parameters

## Options

- `isScary` - if `true`, confirm button will look scary.

## Usage

While `confirm` returns a value synchronously, Accept must be performed asynchronously. In addition to your message, you must pass a function which will be executed upon a user's selection with the result of the confirmation.

```js
import accept from 'calypso/lib/accept';

accept( 'Are you sure you want to perform this action?', function ( accepted ) {
	if ( accepted ) {
		// User accepted the prompt
	} else {
		// User cancelled or otherwise closed the prompt
	}
} );
```

This will make the confirmation button look scary:

```js
import accept from 'calypso/lib/accept';

accept(
	'Are you sure you want to perform this action?',
	function ( accepted ) {
		if ( accepted ) {
			// User accepted the prompt
		} else {
			// User cancelled or otherwise closed the prompt
		}
	},
	translate( 'Destroy Everything' ),
	translate( 'Nevermind' ),
	{
		isScary: true,
	}
);
```