gab-social/app/javascript/gabsocial/components/timeline_compose_block.js

73 lines
2.1 KiB
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
2020-02-21 00:57:29 +00:00
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
import { injectIntl, defineMessages } from 'react-intl'
import { me } from '../initial_state'
2020-05-07 05:03:34 +01:00
import { BREAKPOINT_EXTRA_SMALL } from '../constants'
2020-02-21 00:57:29 +00:00
import ComposeFormContainer from '../features/compose/containers/compose_form_container'
2020-05-06 05:33:54 +01:00
import ResponsiveClassesComponent from '../features/ui/util/responsive_classes_component'
2020-05-07 05:03:34 +01:00
import Responsive from '../features/ui/util/responsive_component'
2020-03-31 17:04:50 +01:00
import Avatar from './avatar'
2020-12-16 00:31:30 +00:00
import Button from './button'
import Text from './text'
2020-02-21 00:57:29 +00:00
2019-08-13 16:54:29 +01:00
class TimelineComposeBlock extends ImmutablePureComponent {
render() {
2020-03-07 04:53:28 +00:00
const {
2020-12-16 00:31:30 +00:00
formLocation,
2020-03-07 04:53:28 +00:00
account,
size,
intl,
2020-12-09 20:02:43 +00:00
isModal,
2020-03-07 04:53:28 +00:00
...rest
} = this.props
2020-12-09 20:02:43 +00:00
if (isModal) {
2020-03-07 04:53:28 +00:00
return (
<section className={_s.d}>
<div className={[_s.d, _s.flexRow].join(' ')}>
2020-12-16 00:31:30 +00:00
<ComposeFormContainer {...rest} isModal={isModal} formLocation={formLocation} />
2020-03-07 04:53:28 +00:00
</div>
</section>
)
}
2019-08-13 16:54:29 +01:00
return (
<section className={[_s.d, _s.mb15].join(' ')}>
2020-05-06 05:33:54 +01:00
<ResponsiveClassesComponent
classNames={[_s.d, _s.boxShadowBlock, _s.bgPrimary, _s.overflowHidden, _s.radiusSmall].join(' ')}
classNamesXS={[_s.d, _s.boxShadowBlock, _s.bgPrimary, _s.overflowHidden].join(' ')}
2020-05-06 05:33:54 +01:00
>
2020-12-16 00:31:30 +00:00
<ComposeFormContainer {...rest} formLocation={formLocation} />
2020-05-06 05:33:54 +01:00
</ResponsiveClassesComponent>
2020-02-08 22:57:09 +00:00
</section>
2019-08-13 16:54:29 +01:00
)
}
}
const messages = defineMessages({
createPost: { id: 'column_header.create_post', defaultMessage: 'Create Post' },
})
const mapStateToProps = (state) => ({
account: state.getIn(['accounts', me]),
})
TimelineComposeBlock.propTypes = {
intl: PropTypes.object.isRequired,
account: ImmutablePropTypes.map.isRequired,
size: PropTypes.number,
2020-12-09 20:02:43 +00:00
isModal: PropTypes.bool,
2020-12-16 00:31:30 +00:00
formLocation: PropTypes.string,
}
TimelineComposeBlock.defaultProps = {
size: 32,
2020-12-16 00:31:30 +00:00
formLocation: 'timeline',
}
export default injectIntl(connect(mapStateToProps)(TimelineComposeBlock))