2017-12-24 07:16:45 +01:00
|
|
|
import React from 'react';
|
2019-04-21 19:07:48 +02:00
|
|
|
import ComposeFormContainer from './containers/compose_form_container';
|
|
|
|
import NavigationContainer from './containers/navigation_container';
|
2019-04-19 20:14:32 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2017-12-24 07:16:45 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2019-04-21 19:07:48 +02:00
|
|
|
import { connect } from 'react-redux';
|
2019-06-14 12:59:59 +02:00
|
|
|
import { mountCompose, unmountCompose } from 'flavours/glitch/actions/compose';
|
2019-04-19 20:14:32 +02:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
2018-01-08 17:40:34 +01:00
|
|
|
import classNames from 'classnames';
|
2019-04-20 17:50:12 +02:00
|
|
|
import SearchContainer from './containers/search_container';
|
2022-10-11 10:51:33 +02:00
|
|
|
import Motion from '../ui/util/optional_motion';
|
2019-04-20 18:21:11 +02:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2019-04-21 19:07:48 +02:00
|
|
|
import SearchResultsContainer from './containers/search_results_container';
|
2022-10-11 10:17:04 +02:00
|
|
|
import { me, mascot } from 'flavours/glitch/initial_state';
|
2019-04-21 19:07:48 +02:00
|
|
|
import { cycleElefriendCompose } from 'flavours/glitch/actions/compose';
|
|
|
|
import HeaderContainer from './containers/header_container';
|
2022-10-04 20:13:23 +02:00
|
|
|
import Column from 'flavours/glitch/components/column';
|
2022-10-20 14:35:29 +02:00
|
|
|
import { Helmet } from 'react-helmet';
|
2017-12-24 07:16:45 +01:00
|
|
|
|
2018-08-28 12:01:04 +02:00
|
|
|
const messages = defineMessages({
|
2022-05-03 10:59:23 +02:00
|
|
|
compose: { id: 'navigation_bar.compose', defaultMessage: 'Compose new post' },
|
2018-08-28 12:01:04 +02:00
|
|
|
});
|
|
|
|
|
2019-04-20 18:21:11 +02:00
|
|
|
const mapStateToProps = (state, ownProps) => ({
|
2018-01-14 04:22:37 +01:00
|
|
|
elefriend: state.getIn(['compose', 'elefriend']),
|
2022-10-23 23:37:58 +02:00
|
|
|
showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : false,
|
2017-12-24 07:16:45 +01:00
|
|
|
});
|
|
|
|
|
2018-07-23 16:03:30 +02:00
|
|
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
|
|
|
onClickElefriend () {
|
|
|
|
dispatch(cycleElefriendCompose());
|
|
|
|
},
|
2019-06-14 12:59:59 +02:00
|
|
|
|
|
|
|
onMount () {
|
|
|
|
dispatch(mountCompose());
|
|
|
|
},
|
|
|
|
|
|
|
|
onUnmount () {
|
|
|
|
dispatch(unmountCompose());
|
|
|
|
},
|
2018-07-23 16:03:30 +02:00
|
|
|
});
|
2017-12-24 07:16:45 +01:00
|
|
|
|
2019-06-13 12:50:52 +02:00
|
|
|
export default @connect(mapStateToProps, mapDispatchToProps)
|
2019-04-19 20:14:32 +02:00
|
|
|
@injectIntl
|
|
|
|
class Compose extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
multiColumn: PropTypes.bool,
|
2019-04-20 18:21:11 +02:00
|
|
|
showSearch: PropTypes.bool,
|
2019-04-19 20:14:32 +02:00
|
|
|
elefriend: PropTypes.number,
|
|
|
|
onClickElefriend: PropTypes.func,
|
2019-06-14 12:59:59 +02:00
|
|
|
onMount: PropTypes.func,
|
|
|
|
onUnmount: PropTypes.func,
|
2019-04-21 19:07:48 +02:00
|
|
|
intl: PropTypes.object.isRequired,
|
2019-04-19 20:14:32 +02:00
|
|
|
};
|
2017-12-24 07:16:45 +01:00
|
|
|
|
2019-06-14 12:59:59 +02:00
|
|
|
componentDidMount () {
|
2022-10-23 23:37:58 +02:00
|
|
|
this.props.onMount();
|
2019-06-14 12:59:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
2022-10-23 23:37:58 +02:00
|
|
|
this.props.onUnmount();
|
2019-06-14 12:59:59 +02:00
|
|
|
}
|
|
|
|
|
2017-12-27 01:54:28 +01:00
|
|
|
render () {
|
|
|
|
const {
|
2018-01-14 04:22:37 +01:00
|
|
|
elefriend,
|
2017-12-27 01:54:28 +01:00
|
|
|
intl,
|
|
|
|
multiColumn,
|
2018-01-14 10:35:25 +01:00
|
|
|
onClickElefriend,
|
2019-04-20 18:21:11 +02:00
|
|
|
showSearch,
|
2017-12-27 01:54:28 +01:00
|
|
|
} = this.props;
|
2018-01-15 00:31:00 +01:00
|
|
|
const computedClass = classNames('drawer', `mbstobon-${elefriend}`);
|
2018-01-08 17:40:34 +01:00
|
|
|
|
2022-10-04 20:13:23 +02:00
|
|
|
if (multiColumn) {
|
|
|
|
return (
|
|
|
|
<div className={computedClass} role='region' aria-label={intl.formatMessage(messages.compose)}>
|
|
|
|
<HeaderContainer />
|
2019-04-20 21:28:03 +02:00
|
|
|
|
2022-10-23 23:37:58 +02:00
|
|
|
{multiColumn && <SearchContainer />}
|
2019-05-23 01:35:22 +02:00
|
|
|
|
2022-10-04 20:13:23 +02:00
|
|
|
<div className='drawer__pager'>
|
2022-10-23 23:37:58 +02:00
|
|
|
<div className='drawer__inner'>
|
2022-10-04 20:13:23 +02:00
|
|
|
<NavigationContainer />
|
2019-05-23 01:35:22 +02:00
|
|
|
|
2022-10-04 20:13:23 +02:00
|
|
|
<ComposeFormContainer />
|
2018-12-19 19:09:04 +01:00
|
|
|
|
2022-10-04 20:13:23 +02:00
|
|
|
<div className='drawer__inner__mastodon'>
|
|
|
|
{mascot ? <img alt='' draggable='false' src={mascot} /> : <button className='mastodon' onClick={onClickElefriend} />}
|
2019-04-20 18:21:11 +02:00
|
|
|
</div>
|
2022-10-23 23:37:58 +02:00
|
|
|
</div>
|
2022-10-04 20:13:23 +02:00
|
|
|
|
2022-10-23 23:37:58 +02:00
|
|
|
<Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
|
2022-10-04 20:13:23 +02:00
|
|
|
{({ x }) => (
|
|
|
|
<div className='drawer__inner darker' style={{ transform: `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
|
|
|
|
<SearchResultsContainer />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
2017-12-29 23:55:06 +01:00
|
|
|
</div>
|
2022-10-04 20:13:23 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Column>
|
|
|
|
<NavigationContainer />
|
|
|
|
<ComposeFormContainer />
|
2022-10-20 14:35:29 +02:00
|
|
|
|
|
|
|
<Helmet>
|
|
|
|
<meta name='robots' content='noindex' />
|
|
|
|
</Helmet>
|
2022-10-04 20:13:23 +02:00
|
|
|
</Column>
|
2017-12-27 01:54:28 +01:00
|
|
|
);
|
|
|
|
}
|
2019-04-20 21:28:03 +02:00
|
|
|
|
2017-12-24 07:16:45 +01:00
|
|
|
}
|