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 / spacings / index.js

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

76 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import './padding';
2 import './margin';
3
4 import { InspectorControls } from '@wordpress/block-editor';
5 import { hasBlockSupport } from '@wordpress/blocks';
6 import {
7 __experimentalToolsPanel as ExperimentalToolsPanel,
8 __stableToolsPanel as StableToolsPanel,
9 } from '@wordpress/components';
10 import { addFilter } from '@wordpress/hooks';
11 import { __ } from '@wordpress/i18n';
12
13 import ApplyFilters from '../../components/apply-filters';
14 import useStyles from '../../hooks/use-styles';
15 import getIcon from '../../utils/get-icon';
16 import { EXTENSIONS } from '../constants';
17
18 const ToolsPanel = StableToolsPanel || ExperimentalToolsPanel;
19
20 const allSpacings = EXTENSIONS.spacings.styles;
21
22 /**
23 * Add inspector controls.
24 *
25 * @param original
26 * @param root0
27 * @param root0.props
28 */
29 function GhostKitExtensionSpacingsInspector(original, { props }) {
30 const { name } = props;
31
32 const hasSpacingsSupport = hasBlockSupport(name, ['ghostkit', 'spacings']);
33
34 if (!hasSpacingsSupport) {
35 return original;
36 }
37
38 const { resetStyles } = useStyles(props);
39
40 return (
41 <>
42 {original}
43 <InspectorControls group="styles">
44 <ToolsPanel
45 label={
46 <>
47 <span className="ghostkit-ext-icon">
48 {getIcon('extension-spacings')}
49 </span>
50 <span>{__('Spacings', 'ghostkit')}</span>
51 </>
52 }
53 resetAll={() => {
54 resetStyles(allSpacings, true);
55 }}
56 >
57 <div className="ghostkit-tools-panel-spacings">
58 <ApplyFilters
59 name="ghostkit.extension.spacings.tools"
60 props={props}
61 />
62 </div>
63 </ToolsPanel>
64 </InspectorControls>
65 </>
66 );
67 }
68
69 // Init filters.
70 addFilter(
71 'ghostkit.editor.extensions',
72 'ghostkit/extension/spacings/inspector',
73 GhostKitExtensionSpacingsInspector,
74 13
75 );
76