ilanap | 1965d16 | 2018-01-04 11:34:59 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016-2017 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 3 | * |
| 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 | * |
ilanap | 1965d16 | 2018-01-04 11:34:59 +0200 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
ilanap | 1965d16 | 2018-01-04 11:34:59 +0200 | [diff] [blame] | 12 | * 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. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 15 | */ |
ilanap | 1965d16 | 2018-01-04 11:34:59 +0200 | [diff] [blame] | 16 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 17 | import React from 'react'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 18 | import PropTypes from 'prop-types'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 19 | import {connect} from 'react-redux'; |
| 20 | |
| 21 | const mapStateToProps = ({loader}) => { |
| 22 | return { |
| 23 | isLoading: loader.isLoading |
| 24 | }; |
| 25 | }; |
| 26 | |
| 27 | class Loader extends React.Component { |
| 28 | |
| 29 | static propTypes = { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 30 | isLoading: PropTypes.bool.isRequired |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | static defaultProps = { |
| 34 | isLoading: false |
| 35 | }; |
| 36 | |
ilanap | 1965d16 | 2018-01-04 11:34:59 +0200 | [diff] [blame] | 37 | shouldComponentUpdate(nextProps) { |
| 38 | return (nextProps.isLoading !== this.props.isLoading); |
| 39 | } |
| 40 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 41 | render() { |
| 42 | let {isLoading} = this.props; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 43 | return ( |
| 44 | <div className='onboarding-loader'> |
| 45 | { |
| 46 | isLoading && <div className='onboarding-loader-backdrop'> |
| 47 | <div className='tlv-loader large'></div> |
| 48 | </div> |
| 49 | } |
| 50 | </div> |
| 51 | ); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | export default connect(mapStateToProps) (Loader); |