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

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

85 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';
2
3 import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
4 import { applyFilters } from '@wordpress/hooks';
5
6 import IconPicker from '../../components/icon-picker';
7 import metadata from './block.json';
8 const { name } = metadata;
9
10 /**
11 * Block Save Class.
12 *
13 * @param props
14 */
15 export default function BlockSave(props) {
16 const {
17 effect,
18 speed,
19 autoplay,
20 autoplayHoverPause,
21 slidesPerView,
22 centeredSlides,
23 loop,
24 freeScroll,
25 fadeEdges,
26 showArrows,
27 arrowPrevIcon,
28 arrowNextIcon,
29 showBullets,
30 dynamicBullets,
31 gap,
32 } = props.attributes;
33
34 let className = classNames(
35 'ghostkit-carousel',
36 fadeEdges && 'ghostkit-carousel-fade-edges'
37 );
38
39 className = applyFilters('ghostkit.blocks.className', className, {
40 name,
41 ...props,
42 });
43
44 const dataAttrs = {
45 'data-effect': effect,
46 'data-speed': speed,
47 'data-autoplay': autoplay,
48 'data-autoplay-hover-pause':
49 autoplay && autoplayHoverPause ? 'true' : null,
50 'data-slides-per-view': slidesPerView,
51 'data-centered-slides': centeredSlides ? 'true' : 'false',
52 'data-loop': loop ? 'true' : 'false',
53 'data-free-scroll': freeScroll ? 'true' : 'false',
54 'data-show-arrows': showArrows ? 'true' : 'false',
55 'data-show-bullets': showBullets ? 'true' : 'false',
56 'data-dynamic-bullets': dynamicBullets ? 'true' : 'false',
57 'data-gap': gap,
58 };
59
60 const blockProps = useBlockProps.save({ className, ...dataAttrs });
61 const innerBlockProps = useInnerBlocksProps.save({
62 className: 'ghostkit-carousel-items',
63 });
64
65 return (
66 <div {...blockProps}>
67 <div {...innerBlockProps} />
68 {arrowPrevIcon ? (
69 <IconPicker.Render
70 name={arrowPrevIcon}
71 tag="div"
72 className="ghostkit-carousel-arrow-prev-icon"
73 />
74 ) : null}
75 {arrowNextIcon ? (
76 <IconPicker.Render
77 name={arrowNextIcon}
78 tag="div"
79 className="ghostkit-carousel-arrow-next-icon"
80 />
81 ) : null}
82 </div>
83 );
84 }
85