summaryrefslogtreecommitdiffhomepage
path: root/app/components/Img.js
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-06-01 16:13:10 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-06-05 12:11:55 +0200
commitca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087 (patch)
treeb1f7754eb50896ab3681e35fa4e08be642b940c9 /app/components/Img.js
parent5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (diff)
downloadmullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.tar.xz
mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.zip
Add formatted source code
Diffstat (limited to 'app/components/Img.js')
-rw-r--r--app/components/Img.js53
1 files changed, 28 insertions, 25 deletions
diff --git a/app/components/Img.js b/app/components/Img.js
index d124eb7f49..fb74ac9fe6 100644
--- a/app/components/Img.js
+++ b/app/components/Img.js
@@ -3,22 +3,21 @@ import * as React from 'react';
import { View, Component, Types } from 'reactxp';
type ImgProps = {
- source: string,
- tintColor?: string,
- hoverStyle?: Types.ViewStyle,
- disabled?: boolean,
- };
+ source: string,
+ tintColor?: string,
+ hoverStyle?: Types.ViewStyle,
+ disabled?: boolean,
+};
type State = { hovered: boolean };
export default class Img extends Component<ImgProps, State> {
-
state = { hovered: false };
- onHoverStart = () => !this.props.disabled ? this.setState({ hovered: true }) : null;
- onHoverEnd = () => !this.props.disabled ? this.setState({ hovered: false }) : null;
+ onHoverStart = () => (!this.props.disabled ? this.setState({ hovered: true }) : null);
+ onHoverEnd = () => (!this.props.disabled ? this.setState({ hovered: false }) : null);
- getHoverStyle = () => this.state.hovered ? this.props.hoverStyle || null : null;
+ getHoverStyle = () => (this.state.hovered ? this.props.hoverStyle || null : null);
render() {
const { source, style, onMouseEnter, onMouseLeave, ...otherProps } = this.props;
@@ -26,31 +25,35 @@ export default class Img extends Component<ImgProps, State> {
const url = './assets/images/' + source + '.svg';
let image;
- if(tintColor) {
+ if (tintColor) {
image = (
- <div style={{
- WebkitMaskImage: `url('${url}')`,
- WebkitMaskRepeat: 'no-repeat',
- backgroundColor: tintColor,
- lineHeight: 0,
- }}>
- <img src={ url } style={{
- visibility: 'hidden',
- }} />
+ <div
+ style={{
+ WebkitMaskImage: `url('${url}')`,
+ WebkitMaskRepeat: 'no-repeat',
+ backgroundColor: tintColor,
+ lineHeight: 0,
+ }}>
+ <img
+ src={url}
+ style={{
+ visibility: 'hidden',
+ }}
+ />
</div>
);
} else {
- image = (
- <img src={ url } />
- );
+ image = <img src={url} />;
}
return (
- <View { ...otherProps }
+ <View
+ {...otherProps}
onMouseEnter={onMouseEnter || this.onHoverStart}
onMouseLeave={onMouseLeave || this.onHoverEnd}
style={[style, this.getHoverStyle()]}>
- { image }
- </View>);
+ {image}
+ </View>
+ );
}
}