blob: 076351bf7a13f88bc59f1bdbb65f639306949628 [file] [log] [blame]
ilanap1965d162018-01-04 11:34:59 +02001/*
2 * Copyright © 2016-2017 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
ilanap1965d162018-01-04 11:34:59 +02008 * http://www.apache.org/licenses/LICENSE-2.0
AviZi280f8012017-06-09 02:39:56 +03009 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
ilanap1965d162018-01-04 11:34:59 +020012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
AviZi280f8012017-06-09 02:39:56 +030015 */
ilanap1965d162018-01-04 11:34:59 +020016
Michael Landoefa037d2017-02-19 12:57:33 +020017import React from 'react';
talig8e9c0652017-12-20 14:30:43 +020018import PropTypes from 'prop-types';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020019import { connect } from 'react-redux';
Michael Landoefa037d2017-02-19 12:57:33 +020020
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020021const mapStateToProps = ({ loader }) => {
22 return {
23 isLoading: loader.isLoading
24 };
Michael Landoefa037d2017-02-19 12:57:33 +020025};
26
27class Loader extends React.Component {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020028 static propTypes = {
29 isLoading: PropTypes.bool.isRequired
30 };
Michael Landoefa037d2017-02-19 12:57:33 +020031
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020032 static defaultProps = {
33 isLoading: false
34 };
Michael Landoefa037d2017-02-19 12:57:33 +020035
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020036 shouldComponentUpdate(nextProps) {
37 return nextProps.isLoading !== this.props.isLoading;
38 }
Michael Landoefa037d2017-02-19 12:57:33 +020039
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020040 render() {
41 let { isLoading } = this.props;
42 return (
43 <div className="onboarding-loader">
44 {isLoading && (
45 <div className="onboarding-loader-backdrop">
46 <div className="tlv-loader large" />
47 </div>
48 )}
49 </div>
50 );
51 }
Michael Landoefa037d2017-02-19 12:57:33 +020052}
53
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020054export default connect(mapStateToProps)(Loader);