PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.0
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.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 / extend / transform / pro-transforms / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.7.0, at gutenberg/extend/transform/pro-transforms/index.js

104 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { hasBlockSupport } from '@wordpress/blocks';
2 import {
3 __experimentalToolsPanelItem as ExperimentalToolsPanelItem,
4 __stableToolsPanelItem as StableToolsPanelItem,
5 } from '@wordpress/components';
6 import { useState } from '@wordpress/element';
7 import { addFilter } from '@wordpress/hooks';
8 import { __ } from '@wordpress/i18n';
9
10 import ProNote from '../../../components/pro-note';
11
12 const ToolsPanelItem = StableToolsPanelItem || ExperimentalToolsPanelItem;
13
14 const { pro } = window.GHOSTKIT;
15
16 const { version } = window.ghostkitVariables;
17
18 const PRESETS = {
19 translate: {
20 label: __('Translate', 'ghostkit'),
21 },
22 scale: {
23 label: __('Scale', 'ghostkit'),
24 },
25 rotate: {
26 label: __('Rotate', 'ghostkit'),
27 },
28 skew: {
29 label: __('Skew', 'ghostkit'),
30 },
31 perspective: {
32 label: __('Perspective', 'ghostkit'),
33 },
34 origin: {
35 label: __('Origin', 'ghostkit'),
36 },
37 };
38
39 function TransformProTools() {
40 const [selected, setSelected] = useState(false);
41
42 return (
43 <>
44 {selected && (
45 <div style={{ gridColumn: '1 / -1' }}>
46 <ProNote title={__('Pro Transformations', 'ghostkit')}>
47 <p>
48 {__(
49 'Adding transformations for normal and hover state are available in the Ghost Kit Pro plugin only.',
50 'ghostkit'
51 )}
52 </p>
53 <ProNote.Button
54 target="_blank"
55 rel="noopener noreferrer"
56 href={`https://www.ghostkit.io/docs/extensions/transform/?utm_source=plugin&utm_medium=block_settings&utm_campaign=pro_transform&utm_content=${version}`}
57 >
58 {__('Read More', 'ghostkit')}
59 </ProNote.Button>
60 </ProNote>
61 </div>
62 )}
63 {Object.keys(PRESETS).map((k) => (
64 <ToolsPanelItem
65 key={k}
66 label={PRESETS[k].label}
67 hasValue={() => false}
68 onDeselect={() => {}}
69 onSelect={() => {
70 setSelected(true);
71 }}
72 isShownByDefault={false}
73 />
74 ))}
75 </>
76 );
77 }
78
79 addFilter(
80 'ghostkit.extension.transform.tools',
81 'ghostkit/extension/transform/pro',
82 (children, { props }) => {
83 if (pro) {
84 return children;
85 }
86
87 const hasTransformSupport = hasBlockSupport(props.name, [
88 'ghostkit',
89 'transform',
90 ]);
91
92 if (!hasTransformSupport) {
93 return children;
94 }
95
96 return (
97 <>
98 {children}
99 <TransformProTools {...props} />
100 </>
101 );
102 }
103 );
104