2020-11-15 18:48:32 +00:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import PageTitle from '../features/ui/util/page_title'
|
2020-12-09 04:15:33 +00:00
|
|
|
import ComposeLayout from '../layouts/compose_layout'
|
|
|
|
import { BREAKPOINT_EXTRA_SMALL } from '../constants'
|
|
|
|
import { getWindowDimension } from '../utils/is_mobile'
|
|
|
|
|
|
|
|
const initialState = getWindowDimension()
|
2020-11-15 18:48:32 +00:00
|
|
|
|
|
|
|
class ComposePage extends React.PureComponent {
|
|
|
|
|
2020-12-09 04:15:33 +00:00
|
|
|
state = {
|
|
|
|
width: initialState.width,
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.handleResize()
|
|
|
|
window.addEventListener('keyup', this.handleKeyUp, false)
|
|
|
|
window.addEventListener('resize', this.handleResize, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
handleResize = () => {
|
|
|
|
const { width } = getWindowDimension()
|
|
|
|
|
|
|
|
this.setState({ width })
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
window.removeEventListener('keyup', this.handleKeyUp)
|
|
|
|
window.removeEventListener('resize', this.handleResize, false)
|
|
|
|
}
|
|
|
|
|
2020-11-15 18:48:32 +00:00
|
|
|
render() {
|
2020-12-09 04:15:33 +00:00
|
|
|
const { children } = this.props
|
|
|
|
const { width } = this.state
|
|
|
|
|
|
|
|
const isXS = width <= BREAKPOINT_EXTRA_SMALL
|
2020-11-15 18:48:32 +00:00
|
|
|
|
|
|
|
return (
|
2020-12-09 04:15:33 +00:00
|
|
|
<ComposeLayout title='Compose' isXS={isXS}>
|
|
|
|
<PageTitle path='Compose' />
|
2020-11-15 18:48:32 +00:00
|
|
|
{children}
|
2020-12-09 04:15:33 +00:00
|
|
|
</ComposeLayout>
|
2020-11-15 18:48:32 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ComposePage.propTypes = {
|
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ComposePage
|