PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
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 / custom-css / cursor / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/extend/custom-css/cursor/index.js

220 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {
2 __experimentalToolsPanelItem as ExperimentalToolsPanelItem,
3 __stableToolsPanelItem as StableToolsPanelItem,
4 SelectControl,
5 } from '@wordpress/components';
6 import { addFilter } from '@wordpress/hooks';
7 import { __ } from '@wordpress/i18n';
8
9 import ResponsiveToggle from '../../../components/responsive-toggle';
10 import useResponsive from '../../../hooks/use-responsive';
11 import useStyles from '../../../hooks/use-styles';
12
13 const ToolsPanelItem = StableToolsPanelItem || ExperimentalToolsPanelItem;
14
15 import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
16
17 function CustomCSSCursorTools(props) {
18 const { getStyle, hasStyle, setStyles, resetStyles } = useStyles(props);
19
20 const { device, allDevices } = useResponsive();
21
22 let hasCursor = false;
23
24 ['', ...Object.keys(allDevices)].forEach((thisDevice) => {
25 hasCursor = hasCursor || hasStyle('cursor', thisDevice);
26 });
27
28 return (
29 <ToolsPanelItem
30 label={__('Cursor', 'ghostkit')}
31 hasValue={() => !!hasCursor}
32 onSelect={() => {
33 if (!hasStyle('cursor')) {
34 setStyles({ cursor: 'default' });
35 }
36 }}
37 onDeselect={() => {
38 resetStyles(['cursor'], true);
39 }}
40 isShownByDefault={false}
41 >
42 <SelectControl
43 label={
44 <>
45 {__('Cursor', 'ghostkit')}
46 <ResponsiveToggle
47 checkActive={(checkMedia) => {
48 return hasStyle('cursor', checkMedia);
49 }}
50 />
51 </>
52 }
53 value={getStyle('cursor', device)}
54 onChange={(val) => {
55 setStyles({ cursor: val }, device);
56 }}
57 options={[
58 {
59 value: 'default',
60 label: __('Default', 'ghostkit'),
61 },
62 {
63 value: 'pointer',
64 label: __('Pointer', 'ghostkit'),
65 },
66 {
67 value: 'not-allowed',
68 label: __('Not Allowed', 'ghostkit'),
69 },
70 {
71 value: 'progress',
72 label: __('Progress', 'ghostkit'),
73 },
74 {
75 value: 'move',
76 label: __('Move', 'ghostkit'),
77 },
78 {
79 value: 'grab',
80 label: __('Grab', 'ghostkit'),
81 },
82 {
83 value: 'grabbing',
84 label: __('Grabbing', 'ghostkit'),
85 },
86 {
87 value: 'zoom-in',
88 label: __('Zoom In', 'ghostkit'),
89 },
90 {
91 value: 'zoom-out',
92 label: __('Zoom Out', 'ghostkit'),
93 },
94 {
95 value: 'copy',
96 label: __('Copy', 'ghostkit'),
97 },
98 {
99 value: 'no-drop',
100 label: __('No Drop', 'ghostkit'),
101 },
102 {
103 value: 'context-menu',
104 label: __('Context Menu', 'ghostkit'),
105 },
106 {
107 value: 'help',
108 label: __('Help', 'ghostkit'),
109 },
110 {
111 value: 'wait',
112 label: __('Wait', 'ghostkit'),
113 },
114 {
115 value: 'cell',
116 label: __('Cell', 'ghostkit'),
117 },
118 {
119 value: 'crosshair',
120 label: __('Crosshair', 'ghostkit'),
121 },
122 {
123 value: 'alias',
124 label: __('Alias', 'ghostkit'),
125 },
126 {
127 value: 'text',
128 label: __('Text', 'ghostkit'),
129 },
130 {
131 value: 'vertical-text',
132 label: __('Vertical Text', 'ghostkit'),
133 },
134 {
135 value: 'copy',
136 label: __('Copy', 'ghostkit'),
137 },
138 {
139 value: 'nw-resize',
140 label: __('NW Resize', 'ghostkit'),
141 },
142 {
143 value: 'n-resize',
144 label: __('N Resize', 'ghostkit'),
145 },
146 {
147 value: 'e-resize',
148 label: __('E Resize', 'ghostkit'),
149 },
150 {
151 value: 'se-resize',
152 label: __('SE Resize', 'ghostkit'),
153 },
154 {
155 value: 's-resize',
156 label: __('S Resize', 'ghostkit'),
157 },
158 {
159 value: 'sw-resize',
160 label: __('SW Resize', 'ghostkit'),
161 },
162 {
163 value: 'w-resize',
164 label: __('W Resize', 'ghostkit'),
165 },
166 {
167 value: 'ew-resize',
168 label: __('EW Resize', 'ghostkit'),
169 },
170 {
171 value: 'ns-resize',
172 label: __('NS Resize', 'ghostkit'),
173 },
174 {
175 value: 'nwse-resize',
176 label: __('NWSE Resize', 'ghostkit'),
177 },
178 {
179 value: 'nesw-resize',
180 label: __('NESW Resize', 'ghostkit'),
181 },
182 {
183 value: 'col-resize',
184 label: __('Col Resize', 'ghostkit'),
185 },
186 {
187 value: 'row-resize',
188 label: __('Row Resize', 'ghostkit'),
189 },
190 {
191 value: 'none',
192 label: __('None', 'ghostkit'),
193 },
194 ]}
195 />
196 </ToolsPanelItem>
197 );
198 }
199
200 addFilter(
201 'ghostkit.extension.customCSS.tools',
202 'ghostkit/extension/customCSS/tools/cursor',
203 (children, { props }) => {
204 const hasCursorSupport =
205 hasBlockSupport(props.name, ['ghostkit', 'customCSS', 'cursor']) ||
206 getBlockSupport(props.name, ['ghostkit', 'customCSS']) === true;
207
208 if (!hasCursorSupport) {
209 return children;
210 }
211
212 return (
213 <>
214 {children}
215 <CustomCSSCursorTools {...props} />
216 </>
217 );
218 }
219 );
220