2016-04-14 00:28:44 +02:00
|
|
|
const inherits = require('util').inherits
|
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
|
|
|
|
|
|
|
|
|
|
|
|
inherits(LoadingIndicator, Component)
|
2016-09-16 05:51:41 +02:00
|
|
|
module.exports = LoadingIndicator
|
|
|
|
|
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 () {
|
2017-01-19 01:45:39 +01:00
|
|
|
const { isLoading, loadingMessage } = this.props
|
2016-04-14 00:28:44 +02:00
|
|
|
|
|
|
|
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',
|
2017-06-15 04:15:50 +02:00
|
|
|
flexDirection: 'column',
|
2016-04-14 00:28:44 +02:00
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
height: '100%',
|
|
|
|
width: '100%',
|
2017-06-15 04:15:50 +02:00
|
|
|
background: 'rgba(255, 255, 255, 0.8)',
|
2016-06-21 22:18:32 +02:00
|
|
|
},
|
2016-04-14 00:28:44 +02:00
|
|
|
}, [
|
|
|
|
h('img', {
|
|
|
|
src: 'images/loading.svg',
|
|
|
|
}),
|
2017-01-19 01:45:39 +01:00
|
|
|
|
2017-06-15 04:15:50 +02:00
|
|
|
h('br'),
|
|
|
|
|
2017-01-19 01:45:39 +01:00
|
|
|
showMessageIfAny(loadingMessage),
|
2016-04-14 00:28:44 +02:00
|
|
|
]) : null,
|
|
|
|
])
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-01-19 01:45:39 +01:00
|
|
|
function showMessageIfAny (loadingMessage) {
|
|
|
|
if (!loadingMessage) return null
|
|
|
|
return h('span', loadingMessage)
|
|
|
|
}
|