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

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

151 lines 3.3 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 videoYoutubeNoCookie,
27 videoAutoplay,
28 videoAutopause,
29 videoLoop,
30
31 iconPlay,
32 iconLoading,
33
34 posterId,
35 posterUrl,
36 posterAlt,
37 posterWidth,
38 posterHeight,
39
40 clickAction,
41 fullscreenActionCloseIcon,
42 fullscreenVideoBackgroundColor,
43 fullscreenVideoBackgroundGradient,
44 fullscreenBackgroundColor,
45 fullscreenBackgroundGradient,
46
47 className,
48 } = attributes;
49
50 const resultAttrs = {};
51
52 resultAttrs.className = 'ghostkit-video';
53 resultAttrs.className = applyFilters(
54 'ghostkit.blocks.className',
55 resultAttrs.className,
56 {
57 name,
58 ...props,
59 }
60 );
61
62 resultAttrs['data-video-type'] = type;
63
64 resultAttrs['data-video'] = '';
65 if (type === 'video') {
66 if (videoMp4) {
67 resultAttrs['data-video'] += `mp4:${videoMp4}`;
68 }
69 if (videoOgv) {
70 resultAttrs['data-video'] += `${
71 resultAttrs['data-video'].length ? ',' : ''
72 }ogv:${videoOgv}`;
73 }
74 if (videoWebm) {
75 resultAttrs['data-video'] += `${
76 resultAttrs['data-video'].length ? ',' : ''
77 }webm:${videoWebm}`;
78 }
79 } else {
80 resultAttrs['data-video'] = video;
81 }
82
83 resultAttrs['data-video-aspect-ratio'] = videoAspectRatio;
84 resultAttrs['data-video-volume'] = videoVolume;
85 resultAttrs['data-click-action'] = clickAction;
86
87 if (videoYoutubeNoCookie) {
88 resultAttrs['data-video-youtube-no-cookie'] = 'true';
89 }
90
91 if (clickAction === 'fullscreen') {
92 resultAttrs['data-fullscreen-video-background-color'] =
93 fullscreenVideoBackgroundColor;
94 resultAttrs['data-fullscreen-video-background-gradient'] =
95 fullscreenVideoBackgroundGradient;
96 resultAttrs['data-fullscreen-background-color'] =
97 fullscreenBackgroundColor;
98 resultAttrs['data-fullscreen-background-gradient'] =
99 fullscreenBackgroundGradient;
100 } else {
101 if (videoAutoplay) {
102 resultAttrs['data-video-autoplay'] = 'true';
103 }
104 if (videoAutopause) {
105 resultAttrs['data-video-autopause'] = 'true';
106 }
107 if (videoLoop) {
108 resultAttrs['data-video-loop'] = 'true';
109 }
110 }
111
112 const blockProps = useBlockProps.save(resultAttrs);
113
114 return (
115 <div {...blockProps}>
116 {posterUrl && !hasClass(className, 'is-style-icon-only') ? (
117 <div className="ghostkit-video-poster">
118 <img
119 src={posterUrl}
120 alt={posterAlt}
121 className={posterId ? `wp-image-${posterId}` : null}
122 width={posterWidth}
123 height={posterHeight}
124 />
125 </div>
126 ) : null}
127 {iconPlay ? (
128 <IconPicker.Render
129 name={iconPlay}
130 tag="div"
131 className="ghostkit-video-play-icon"
132 />
133 ) : null}
134 {iconLoading ? (
135 <IconPicker.Render
136 name={iconLoading}
137 tag="div"
138 className="ghostkit-video-loading-icon"
139 />
140 ) : null}
141 {clickAction === 'fullscreen' && fullscreenActionCloseIcon ? (
142 <IconPicker.Render
143 name={fullscreenActionCloseIcon}
144 tag="div"
145 className="ghostkit-video-fullscreen-close-icon"
146 />
147 ) : null}
148 </div>
149 );
150 }
151