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

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

101 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { getBlockSupport, 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 mouseHover: {
20 label: __('Mouse Hover', 'ghostkit'),
21 },
22 mousePress: {
23 label: __('Mouse Press', 'ghostkit'),
24 },
25 mouseMove: {
26 label: __('Mouse Move', 'ghostkit'),
27 },
28 scroll: {
29 label: __('Scroll', 'ghostkit'),
30 },
31 loop: {
32 label: __('Loop', 'ghostkit'),
33 },
34 };
35
36 function EffectsProTools() {
37 const [selected, setSelected] = useState(false);
38
39 return (
40 <>
41 {selected && (
42 <div style={{ gridColumn: '1 / -1' }}>
43 <ProNote title={__('Advanced Effects', 'ghostkit')}>
44 <p>
45 {__(
46 'Advanced effects are available in the Ghost Kit Pro plugin only.',
47 'ghostkit'
48 )}
49 </p>
50 <ProNote.Button
51 target="_blank"
52 rel="noopener noreferrer"
53 href={`https://www.ghostkit.io/docs/extensions/effects/?utm_source=plugin&utm_medium=block_settings&utm_campaign=pro_effects&utm_content=${version}`}
54 >
55 {__('Read More', 'ghostkit')}
56 </ProNote.Button>
57 </ProNote>
58 </div>
59 )}
60 {Object.keys(PRESETS).map((k) => (
61 <ToolsPanelItem
62 key={k}
63 label={PRESETS[k].label}
64 hasValue={() => false}
65 onDeselect={() => {}}
66 onSelect={() => {
67 setSelected(true);
68 }}
69 isShownByDefault={false}
70 />
71 ))}
72 </>
73 );
74 }
75
76 addFilter(
77 'ghostkit.extension.effects.tools',
78 'ghostkit/extension/effects/pro',
79 (children, { props }) => {
80 if (pro) {
81 return children;
82 }
83
84 const hasOneOfProEffectsSupport =
85 Object.keys(PRESETS).some((k) =>
86 hasBlockSupport(props.name, ['ghostkit', 'effects', k])
87 ) || getBlockSupport(props.name, ['ghostkit', 'effects']) === true;
88
89 if (!hasOneOfProEffectsSupport) {
90 return children;
91 }
92
93 return (
94 <>
95 {children}
96 <EffectsProTools {...props} />
97 </>
98 );
99 }
100 );
101