You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.5 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. import ComposeFormContainer from './containers/compose_form_container';
  2. import UploadFormContainer from './containers/upload_form_container';
  3. import NavigationContainer from './containers/navigation_container';
  4. import PropTypes from 'prop-types';
  5. import { connect } from 'react-redux';
  6. import { mountCompose, unmountCompose } from '../../actions/compose';
  7. import { Link } from 'react-router';
  8. import { injectIntl, defineMessages } from 'react-intl';
  9. import SearchContainer from './containers/search_container';
  10. import { Motion, spring } from 'react-motion';
  11. import SearchResultsContainer from './containers/search_results_container';
  12. const messages = defineMessages({
  13. start: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
  14. public: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
  15. community: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
  16. preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
  17. logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' }
  18. });
  19. const mapStateToProps = state => ({
  20. showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden'])
  21. });
  22. class Compose extends React.PureComponent {
  23. componentDidMount () {
  24. this.props.dispatch(mountCompose());
  25. }
  26. componentWillUnmount () {
  27. this.props.dispatch(unmountCompose());
  28. }
  29. render () {
  30. const { withHeader, showSearch, intl } = this.props;
  31. let header = '';
  32. if (withHeader) {
  33. header = (
  34. <div className='drawer__header'>
  35. <Link to='/getting-started' className='drawer__tab' title={intl.formatMessage(messages.start)}><i role="img" aria-label={intl.formatMessage(messages.start)} className='fa fa-fw fa-asterisk' /></Link>
  36. <Link to='/timelines/public/local' className='drawer__tab' title={intl.formatMessage(messages.community)}><i role="img" aria-label={intl.formatMessage(messages.community)} className='fa fa-fw fa-users' /></Link>
  37. <Link to='/timelines/public' className='drawer__tab' title={intl.formatMessage(messages.public)}><i role="img" aria-label={intl.formatMessage(messages.public)} className='fa fa-fw fa-globe' /></Link>
  38. <a href='/settings/preferences' className='drawer__tab' title={intl.formatMessage(messages.preferences)}><i role="img" aria-label={intl.formatMessage(messages.preferences)} className='fa fa-fw fa-cog' /></a>
  39. <a href='/auth/sign_out' className='drawer__tab' data-method='delete' title={intl.formatMessage(messages.logout)}><i role="img" aria-label={intl.formatMessage(messages.logout)} className='fa fa-fw fa-sign-out' /></a>
  40. </div>
  41. );
  42. }
  43. return (
  44. <div className='drawer'>
  45. {header}
  46. <SearchContainer />
  47. <div className='drawer__pager'>
  48. <div className='drawer__inner'>
  49. <NavigationContainer />
  50. <ComposeFormContainer />
  51. </div>
  52. <Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
  53. {({ x }) =>
  54. <div className='drawer__inner darker' style={{ transform: `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
  55. <SearchResultsContainer />
  56. </div>
  57. }
  58. </Motion>
  59. </div>
  60. </div>
  61. );
  62. }
  63. }
  64. Compose.propTypes = {
  65. dispatch: PropTypes.func.isRequired,
  66. withHeader: PropTypes.bool,
  67. showSearch: PropTypes.bool,
  68. intl: PropTypes.object.isRequired
  69. };
  70. export default connect(mapStateToProps)(injectIntl(Compose));