2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-07-28 21:06:45 +01:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import ContentLoader from 'react-content-loader'
|
|
|
|
import { DEFAULT_THEME } from '../../constants'
|
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class PlaceholderLayout extends React.PureComponent {
|
2020-07-28 21:06:45 +01:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
theme,
|
|
|
|
viewBox,
|
2020-12-03 04:22:51 +00:00
|
|
|
preserveAspectRatio,
|
2020-07-28 21:06:45 +01:00
|
|
|
} = this.props
|
|
|
|
|
2020-11-04 19:52:15 +00:00
|
|
|
const isLight = ['light', 'white', ''].indexOf(theme) > -1
|
2020-07-28 21:06:45 +01:00
|
|
|
const title = intl.formatMessage(messages.loading)
|
2020-11-03 21:12:24 +00:00
|
|
|
const backgroundColor = !isLight ? '#555' : '#f3f3f3'
|
|
|
|
const foregroundColor = !isLight ? '#888' : '#ecebeb'
|
2020-07-28 21:06:45 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ContentLoader
|
|
|
|
title={title}
|
|
|
|
speed={1.25}
|
|
|
|
viewBox={viewBox}
|
|
|
|
backgroundColor={backgroundColor}
|
|
|
|
foregroundColor={foregroundColor}
|
2020-12-03 04:22:51 +00:00
|
|
|
preserveAspectRatio={preserveAspectRatio}
|
2020-07-28 21:06:45 +01:00
|
|
|
>
|
|
|
|
{this.props.children}
|
|
|
|
</ContentLoader>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-14 18:44:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
loading: { id: 'loading_indicator.label', defaultMessage: 'Loading...' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
theme: state.getIn(['settings', 'displayOptions', 'theme'], DEFAULT_THEME),
|
|
|
|
})
|
|
|
|
|
|
|
|
PlaceholderLayout.propTypes = {
|
|
|
|
children: PropTypes.node,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
theme: PropTypes.string.isRequired,
|
2020-11-05 03:02:59 +00:00
|
|
|
viewBox: PropTypes.string.isRequired,
|
2020-12-03 04:22:51 +00:00
|
|
|
preserveAspectRatio: PropTypes.string,
|
2020-08-14 18:44:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps)(PlaceholderLayout))
|