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 / components / image-picker / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.2, at gutenberg/components/image-picker/index.js

51 lines 1.1 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 { BaseControl } from '@wordpress/components';
4
5 /**
6 * Component Class
7 *
8 * @param props
9 */
10 export default function ImagePicker(props) {
11 const { value, options, itemsPerRow = 2, onChange, label } = props;
12
13 return (
14 <BaseControl
15 id={label}
16 label={label}
17 className={classnames(
18 'ghostkit-component-image-picker',
19 `ghostkit-component-image-picker-${itemsPerRow}`
20 )}
21 >
22 {options.map((option) => (
23 <button
24 key={`image-pircker-${option.value}`}
25 onClick={() => {
26 onChange(option.value);
27 }}
28 className={classnames(
29 'ghostkit-component-image-picker-item',
30 value === option.value
31 ? 'ghostkit-component-image-picker-item-active'
32 : '',
33 option.className
34 )}
35 >
36 {option.image && typeof option.image === 'string' ? (
37 <img
38 src={option.image}
39 alt={option.label || option.value}
40 />
41 ) : null}
42 {option.image && typeof option.image !== 'string'
43 ? option.image
44 : ''}
45 {option.label ? <span>{option.label}</span> : ''}
46 </button>
47 ))}
48 </BaseControl>
49 );
50 }
51