PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / components / remove-button / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.7.2, at gutenberg/components/remove-button/index.js

69 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Button, Popover } from '@wordpress/components';
2 import { useState } from '@wordpress/element';
3 import { __ } from '@wordpress/i18n';
4
5 import getIcon from '../../utils/get-icon';
6
7 /**
8 * Component Class
9 *
10 * @param props
11 */
12 export default function RemoveButton(props) {
13 const [confirmed, setConfirmed] = useState(-1);
14
15 const {
16 onRemove,
17 show,
18 style,
19 tooltipText = __('Remove Block?', 'ghostkit'),
20 tooltipRemoveText = __('Remove', 'ghostkit'),
21 tooltipCancelText = __('Cancel', 'ghostkit'),
22 } = props;
23
24 if (!show) {
25 return null;
26 }
27
28 return (
29 <Button
30 className="ghostkit-component-remove-button"
31 onClick={() => {
32 if (confirmed === -1) {
33 setConfirmed(0);
34 }
35 }}
36 style={style}
37 >
38 {confirmed === 0 ? (
39 <Popover
40 className="ghostkit-component-remove-button-confirm"
41 onClose={() => {
42 setConfirmed(-1);
43 }}
44 onFocusOutside={() => {
45 setConfirmed(-1);
46 }}
47 >
48 {tooltipText}
49 <Button
50 className="ghostkit-component-remove-button-confirm-yep"
51 onClick={onRemove}
52 >
53 {tooltipRemoveText}
54 </Button>
55 <Button
56 className="ghostkit-component-remove-button-confirm-nope"
57 onClick={() => {
58 setConfirmed(-1);
59 }}
60 >
61 {tooltipCancelText}
62 </Button>
63 </Popover>
64 ) : null}
65 {getIcon('icon-trash')}
66 </Button>
67 );
68 }
69