blob: c4fb7637d550fabe3f0a2a7b04b650f2aea9656f (
plain)
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
39
40
41
|
// @flow
import React from 'react';
import { View, Component } from 'reactxp';
export default class Img extends Component {
props: {
source: string,
tintColor?: string
};
render() {
const { source, ...otherProps } = this.props;
const tintColor = this.props.tintColor;
const url = './assets/images/' + source + '.svg';
let image;
if(tintColor) {
image = (
<div style={{
WebkitMaskImage: `url('${url}')`,
WebkitMaskRepeat: 'no-repeat',
backgroundColor: tintColor,
lineHeight: 0,
}}>
<img src={ url } style={{
visibility: 'hidden',
}} />
</div>
);
} else {
image = (
<img src={ url } />
);
}
return (
<View { ...otherProps }>
{ image }
</View>);
}
}
|