gab-social/app/javascript/gabsocial/pages/compose_page.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

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'
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 {
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() {
const { children } = this.props
const { width } = this.state
const isXS = width <= BREAKPOINT_EXTRA_SMALL
2020-11-15 18:48:32 +00:00
return (
<ComposeLayout title='Compose' isXS={isXS}>
<PageTitle path='Compose' />
2020-11-15 18:48:32 +00:00
{children}
</ComposeLayout>
2020-11-15 18:48:32 +00:00
)
}
}
ComposePage.propTypes = {
children: PropTypes.node.isRequired,
}
export default ComposePage