2016-04-14 00:28:44 +02:00
|
|
|
const inherits = require('util').inherits
|
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const connect = require('react-redux').connect
|
|
|
|
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps)(LoadingIndicator)
|
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
function mapStateToProps (state) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
|
|
|
isLoading: state.appState.isLoading,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(LoadingIndicator, Component)
|
2016-06-21 22:18:32 +02:00
|
|
|
function LoadingIndicator () {
|
2016-04-14 00:28:44 +02:00
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
LoadingIndicator.prototype.render = function () {
|
2016-04-14 00:28:44 +02:00
|
|
|
var isLoading = this.props.isLoading
|
|
|
|
|
|
|
|
return (
|
|
|
|
h(ReactCSSTransitionGroup, {
|
2016-05-14 01:28:46 +02:00
|
|
|
className: 'css-transition-group',
|
|
|
|
transitionName: 'loader',
|
2016-04-14 00:28:44 +02:00
|
|
|
transitionEnterTimeout: 150,
|
|
|
|
transitionLeaveTimeout: 150,
|
|
|
|
}, [
|
|
|
|
|
|
|
|
isLoading ? h('div', {
|
|
|
|
style: {
|
2016-09-12 23:37:17 +02:00
|
|
|
zIndex: 10,
|
2016-04-14 00:28:44 +02:00
|
|
|
position: 'absolute',
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
height: '100%',
|
|
|
|
width: '100%',
|
|
|
|
background: 'rgba(255, 255, 255, 0.5)',
|
2016-06-21 22:18:32 +02:00
|
|
|
},
|
2016-04-14 00:28:44 +02:00
|
|
|
}, [
|
|
|
|
h('img', {
|
|
|
|
src: 'images/loading.svg',
|
|
|
|
}),
|
|
|
|
]) : null,
|
|
|
|
])
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|