From 13b9ca34323327b82181a88c8c01a0d522fb23c8 Mon Sep 17 00:00:00 2001 From: "damian.przygodzki" Date: Mon, 26 Jun 2017 14:08:34 +0200 Subject: [PATCH] #935 Loader for image widget --- src/components/widget/Image.js | 47 +++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/src/components/widget/Image.js b/src/components/widget/Image.js index 166448ada..a3ae6120a 100644 --- a/src/components/widget/Image.js +++ b/src/components/widget/Image.js @@ -1,5 +1,16 @@ import React, { Component } from 'react'; import { getImageAction, postImageAction } from '../../actions/AppActions'; +import Loader from '../app/Loader'; + +const Placeholder = (props) => ( +
+
+ {props.children} +
+
+); class Image extends Component{ constructor(props){ @@ -185,6 +196,26 @@ class Image extends Component{ Take from camera } + + renderImagePreview() { + const {isLoading, imageSrc} = this.state; + const {fields} = this.props; + + if(isLoading) + return + else if(imageSrc) + return ( +
+ image +
+ ); + else + return {fields[0].emptyText} + } render(){ const { imageSrc, usingCamera } = this.state; @@ -196,21 +227,7 @@ class Image extends Component{ onKeyDown={this.handleKeyDown} tabIndex={0} > - {imageSrc ? -
- image -
- : -
-
{fields[0].emptyText}
-
- } + {this.renderImagePreview()} {usingCamera && this.renderVideoPreview()}