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 / blocks / icon-box / save.js

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

74 lines 1.5 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, useInnerBlocksProps } 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 {
18 icon,
19 iconPosition,
20 iconAlign,
21 showContent,
22 url,
23 ariaLabel,
24 target,
25 rel,
26 } = props.attributes;
27
28 let className = classnames(
29 'ghostkit-icon-box',
30 url && 'ghostkit-icon-box-with-link'
31 );
32 className = applyFilters('ghostkit.blocks.className', className, {
33 name,
34 ...props,
35 });
36
37 const classNameIcon = classnames(
38 'ghostkit-icon-box-icon',
39 `ghostkit-icon-box-icon-align-${iconPosition || 'left'}`,
40 iconPosition === 'top'
41 ? `ghostkit-icon-box-icon-top-align-${iconAlign || 'center'}`
42 : ''
43 );
44
45 const blockProps = useBlockProps.save({ className });
46 const innerBlockProps = useInnerBlocksProps.save({
47 className: 'ghostkit-icon-box-content',
48 });
49
50 return (
51 <div {...blockProps}>
52 {url ? (
53 <a
54 className="ghostkit-icon-box-link"
55 href={url}
56 target={target || null}
57 rel={rel || null}
58 aria-label={ariaLabel || null}
59 >
60 <span />
61 </a>
62 ) : null}
63 {icon ? (
64 <IconPicker.Render
65 name={icon}
66 tag="div"
67 className={classNameIcon}
68 />
69 ) : null}
70 {showContent ? <div {...innerBlockProps} /> : null}
71 </div>
72 );
73 }
74