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

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

91 lines 1.9 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 metadata from './block.json';
4
5 const { name } = metadata;
6
7 import {
8 RichText,
9 useBlockProps,
10 useInnerBlocksProps,
11 } from '@wordpress/block-editor';
12 import { applyFilters } from '@wordpress/hooks';
13
14 /**
15 * Block Save Class.
16 *
17 * @param props
18 */
19 export default function BlockSave(props) {
20 const { attributes } = props;
21 const {
22 number,
23 animateInViewport,
24 numberPosition,
25 numberAlign,
26 showContent,
27 url,
28 ariaLabel,
29 target,
30 rel,
31 } = attributes;
32
33 let { animateInViewportFrom } = attributes;
34
35 animateInViewportFrom = parseFloat(animateInViewportFrom);
36
37 let className = classnames(
38 'ghostkit-counter-box',
39 url && 'ghostkit-counter-box-with-link'
40 );
41 className = applyFilters('ghostkit.blocks.className', className, {
42 name,
43 ...props,
44 });
45
46 const classNameNumber = classnames(
47 'ghostkit-counter-box-number',
48 `ghostkit-counter-box-number-align-${numberPosition || 'left'}`,
49 numberPosition === 'top'
50 ? `ghostkit-counter-box-number-top-align-${numberAlign || 'center'}`
51 : ''
52 );
53
54 const blockProps = useBlockProps.save({ className });
55 const innerBlockProps = useInnerBlocksProps.save({
56 className: 'ghostkit-counter-box-content',
57 });
58
59 return (
60 <div {...blockProps}>
61 {url ? (
62 <a
63 className="ghostkit-counter-box-link"
64 href={url}
65 target={target || null}
66 rel={rel || null}
67 aria-label={ariaLabel || null}
68 >
69 <span />
70 </a>
71 ) : null}
72 <div className={classNameNumber}>
73 <RichText.Content
74 tagName="div"
75 className={`ghostkit-counter-box-number-wrap${
76 animateInViewport ? ' ghostkit-count-up' : ''
77 }`}
78 value={number}
79 {...{
80 'data-count-from':
81 animateInViewport && animateInViewportFrom
82 ? animateInViewportFrom
83 : null,
84 }}
85 />
86 </div>
87 {showContent ? <div {...innerBlockProps} /> : null}
88 </div>
89 );
90 }
91