PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.11.0
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.11.0
3.1.0 3.0.0 2.13.2 2.13.1 2.13.0 trunk 1.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.1 2.5.3 2.5.4 2.5.5 2.6.1 All 56 releases
slider-blocks / src / controls / preview / index.js

index.js in GutSlider – All in One Slider and Carousel Blocks for Gutenberg 2.11.0, at src/controls/preview/index.js

62 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 import { MediaUpload } from '@wordpress/block-editor';
5 import { Button, FocalPointPicker, TextControl, BaseControl } from '@wordpress/components';
6 import { __ } from '@wordpress/i18n';
7
8 /**
9 * External dependencies
10 */
11 import classnames from 'classnames';
12
13 const Preview = ({
14 url,
15 id,
16 alt = '',
17 label = '',
18 onSelect,
19 onClick,
20 focalPoint = false,
21 focalValue,
22 onFocalPointChange,
23 videoType = false,
24 editing = true
25 }) => {
26 return (
27 <BaseControl label={label} id="gutslider-image-preview">
28 <div
29 className={classnames('gutslider-image-preview', {
30 'has-focal-point': focalPoint,
31 'has-video': videoType
32 })}
33 >
34 {videoType ? (
35 <TextControl label={__('Video URL', 'slider-blocks')} value={url} readonly={true} />
36 ) : (
37 <>
38 {focalPoint ? (
39 <FocalPointPicker url={url} value={focalValue} onChange={v => onFocalPointChange(v)} />
40 ) : (
41 <img src={url} alt={alt || 'placeholder alt'} />
42 )}
43 </>
44 )}
45 {editing && (
46 <>
47 <MediaUpload
48 onSelect={media => onSelect(media)}
49 allowedTypes={videoType ? '*' : ['image']}
50 value={id}
51 render={({ open }) => <Button onClick={open} className="edit-btn" icon="edit" />}
52 />
53 <Button className="remove-btn" icon="no-alt" onClick={() => onClick()} />
54 </>
55 )}
56 </div>
57 </BaseControl>
58 );
59 };
60
61 export default Preview;
62