-
Notifications
You must be signed in to change notification settings - Fork 101
/
Image.js
38 lines (29 loc) · 885 Bytes
/
Image.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, {Component} from 'react';
import {MapTo} from '@adobe/aem-react-editable-components';
require('./Image.scss');
export const ImageEditConfig = {
emptyLabel: 'Image',
isEmpty: function(props) {
return !props || !props.src || props.src.trim().length < 1;
}
};
export default class Image extends Component {
get content() {
return <img
className="Image-src"
src={this.props.src}
alt={this.props.alt}
title={this.props.title ? this.props.title : this.props.alt} />;
}
render() {
if(ImageEditConfig.isEmpty(this.props)) {
return null;
}
return (
<div className="Image">
{this.content}
</div>
);
}
}
MapTo('wknd-spa-react/components/image')(Image, ImageEditConfig);