PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
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 / video / save.js

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

146 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useBlockProps } from '@wordpress/block-editor';
2 import { applyFilters } from '@wordpress/hooks';
3
4 import IconPicker from '../../components/icon-picker';
5 import { hasClass } from '../../utils/classes-replacer';
6 import metadata from './block.json';
7
8 const { name } = metadata;
9
10 /**
11 * Block Save Class.
12 *
13 * @param props
14 */
15 export default function BlockSave(props) {
16 const { attributes } = props;
17
18 const {
19 type,
20 video,
21 videoMp4,
22 videoOgv,
23 videoWebm,
24 videoAspectRatio,
25 videoVolume,
26 videoAutoplay,
27 videoAutopause,
28 videoLoop,
29
30 iconPlay,
31 iconLoading,
32
33 posterId,
34 posterUrl,
35 posterAlt,
36 posterWidth,
37 posterHeight,
38
39 clickAction,
40 fullscreenActionCloseIcon,
41 fullscreenVideoBackgroundColor,
42 fullscreenVideoBackgroundGradient,
43 fullscreenBackgroundColor,
44 fullscreenBackgroundGradient,
45
46 className,
47 } = attributes;
48
49 const resultAttrs = {};
50
51 resultAttrs.className = 'ghostkit-video';
52 resultAttrs.className = applyFilters(
53 'ghostkit.blocks.className',
54 resultAttrs.className,
55 {
56 name,
57 ...props,
58 }
59 );
60
61 resultAttrs['data-video-type'] = type;
62
63 resultAttrs['data-video'] = '';
64 if (type === 'video') {
65 if (videoMp4) {
66 resultAttrs['data-video'] += `mp4:${videoMp4}`;
67 }
68 if (videoOgv) {
69 resultAttrs['data-video'] += `${
70 resultAttrs['data-video'].length ? ',' : ''
71 }ogv:${videoOgv}`;
72 }
73 if (videoWebm) {
74 resultAttrs['data-video'] += `${
75 resultAttrs['data-video'].length ? ',' : ''
76 }webm:${videoWebm}`;
77 }
78 } else {
79 resultAttrs['data-video'] = video;
80 }
81
82 resultAttrs['data-video-aspect-ratio'] = videoAspectRatio;
83 resultAttrs['data-video-volume'] = videoVolume;
84 resultAttrs['data-click-action'] = clickAction;
85
86 if (clickAction === 'fullscreen') {
87 resultAttrs['data-fullscreen-video-background-color'] =
88 fullscreenVideoBackgroundColor;
89 resultAttrs['data-fullscreen-video-background-gradient'] =
90 fullscreenVideoBackgroundGradient;
91 resultAttrs['data-fullscreen-background-color'] =
92 fullscreenBackgroundColor;
93 resultAttrs['data-fullscreen-background-gradient'] =
94 fullscreenBackgroundGradient;
95 } else {
96 if (videoAutoplay) {
97 resultAttrs['data-video-autoplay'] = 'true';
98 }
99 if (videoAutopause) {
100 resultAttrs['data-video-autopause'] = 'true';
101 }
102 if (videoLoop) {
103 resultAttrs['data-video-loop'] = 'true';
104 }
105 }
106
107 const blockProps = useBlockProps.save(resultAttrs);
108
109 return (
110 <div {...blockProps}>
111 {posterUrl && !hasClass(className, 'is-style-icon-only') ? (
112 <div className="ghostkit-video-poster">
113 <img
114 src={posterUrl}
115 alt={posterAlt}
116 className={posterId ? `wp-image-${posterId}` : null}
117 width={posterWidth}
118 height={posterHeight}
119 />
120 </div>
121 ) : null}
122 {iconPlay ? (
123 <IconPicker.Render
124 name={iconPlay}
125 tag="div"
126 className="ghostkit-video-play-icon"
127 />
128 ) : null}
129 {iconLoading ? (
130 <IconPicker.Render
131 name={iconLoading}
132 tag="div"
133 className="ghostkit-video-loading-icon"
134 />
135 ) : null}
136 {clickAction === 'fullscreen' && fullscreenActionCloseIcon ? (
137 <IconPicker.Render
138 name={fullscreenActionCloseIcon}
139 tag="div"
140 className="ghostkit-video-fullscreen-close-icon"
141 />
142 ) : null}
143 </div>
144 );
145 }
146