PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 2.25.0
Block Animations, Motion & Scroll Effects – Ghost Kit v2.25.0
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 2.25.0, at gutenberg/components/remove-button/index.js

92 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Internal dependencies
3 */
4 import getIcon from '../../utils/get-icon';
5
6 /**
7 * WordPress dependencies
8 */
9 const { Component } = wp.element;
10
11 const { __ } = wp.i18n;
12
13 const { Button, Popover } = wp.components;
14
15 /**
16 * Component Class
17 */
18 export default class RemoveButton extends Component {
19 constructor(props) {
20 super(props);
21
22 this.state = {
23 confirmed: -1,
24 };
25 }
26
27 render() {
28 const {
29 onRemove,
30 show,
31 style,
32 tooltipText = __('Remove Block?', 'ghostkit'),
33 tooltipRemoveText = __('Remove', 'ghostkit'),
34 tooltipCancelText = __('Cancel', 'ghostkit'),
35 } = this.props;
36
37 const { confirmed } = this.state;
38
39 if (!show) {
40 return null;
41 }
42
43 return (
44 <Button
45 className="ghostkit-component-remove-button"
46 onClick={() => {
47 if (confirmed === -1) {
48 this.setState({
49 confirmed: 0,
50 });
51 }
52 }}
53 style={style}
54 >
55 {confirmed === 0 ? (
56 <Popover
57 className="ghostkit-component-remove-button-confirm"
58 onClose={() => {
59 this.setState({
60 confirmed: -1,
61 });
62 }}
63 onFocusOutside={() => {
64 this.setState({
65 confirmed: -1,
66 });
67 }}
68 >
69 {tooltipText}
70 <Button className="ghostkit-component-remove-button-confirm-yep" onClick={onRemove}>
71 {tooltipRemoveText}
72 </Button>
73 <Button
74 className="ghostkit-component-remove-button-confirm-nope"
75 onClick={() => {
76 this.setState({
77 confirmed: -1,
78 });
79 }}
80 >
81 {tooltipCancelText}
82 </Button>
83 </Popover>
84 ) : (
85 ''
86 )}
87 {getIcon('icon-trash')}
88 </Button>
89 );
90 }
91 }
92