PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.4.1
Block Animations, Motion & Scroll Effects – Ghost Kit v3.4.1
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 / blocks / icon / save.js

save.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.4.1, at gutenberg/blocks/icon/save.js

61 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import classnames from 'classnames/dedupe';
2
3 import IconPicker from '../../components/icon-picker';
4 import metadata from './block.json';
5
6 const { name } = metadata;
7
8 import { useBlockProps } from '@wordpress/block-editor';
9 import { applyFilters } from '@wordpress/hooks';
10
11 /**
12 * Block Save Class.
13 *
14 * @param props
15 */
16 export default function BlockSave(props) {
17 const { attributes } = props;
18 const { flipV, flipH } = attributes;
19
20 let className = classnames('ghostkit-icon', {
21 'ghostkit-icon-flip-vertical': flipV,
22 'ghostkit-icon-flip-horizontal': flipH,
23 });
24
25 className = applyFilters('ghostkit.blocks.className', className, {
26 ...{ name },
27 ...props,
28 });
29
30 const blockProps = useBlockProps.save({ className });
31
32 return (
33 <div {...blockProps}>
34 <Icon attributes={props.attributes} />
35 </div>
36 );
37 }
38
39 function Icon({ attributes }) {
40 const { icon, url, target, ariaLabel, rel } = attributes;
41
42 const tag = url ? 'a' : 'div';
43 const attrs = {};
44
45 if (tag === 'a') {
46 attrs.href = url;
47 attrs.target = target || null;
48 attrs.rel = rel || null;
49 attrs.ariaLabel = ariaLabel || null;
50 }
51
52 return (
53 <IconPicker.Render
54 {...attrs}
55 name={icon}
56 tag={tag}
57 className="ghostkit-icon-inner"
58 />
59 );
60 }
61