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.

87 lines
3.3 KiB

7 years ago
7 years ago
7 years ago
7 years ago
8 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 PureRenderMixin from 'react-addons-pure-render-mixin';
  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: 'Whole Known Network' },
  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. const Compose = React.createClass({
  23. propTypes: {
  24. dispatch: React.PropTypes.func.isRequired,
  25. withHeader: React.PropTypes.bool,
  26. showSearch: React.PropTypes.bool,
  27. intl: React.PropTypes.object.isRequired
  28. },
  29. mixins: [PureRenderMixin],
  30. componentDidMount () {
  31. this.props.dispatch(mountCompose());
  32. },
  33. componentWillUnmount () {
  34. this.props.dispatch(unmountCompose());
  35. },
  36. render () {
  37. const { withHeader, showSearch, intl } = this.props;
  38. let header = '';
  39. if (withHeader) {
  40. header = (
  41. <div className='drawer__header'>
  42. <Link title={intl.formatMessage(messages.start)} className='drawer__tab' to='/getting-started'><i className='fa fa-fw fa-asterisk' /></Link>
  43. <Link title={intl.formatMessage(messages.community)} className='drawer__tab' to='/timelines/public/local'><i className='fa fa-fw fa-users' /></Link>
  44. <Link title={intl.formatMessage(messages.public)} className='drawer__tab' to='/timelines/public'><i className='fa fa-fw fa-globe' /></Link>
  45. <a title={intl.formatMessage(messages.preferences)} className='drawer__tab' href='/settings/preferences'><i className='fa fa-fw fa-cog' /></a>
  46. <a title={intl.formatMessage(messages.logout)} className='drawer__tab' href='/auth/sign_out' data-method='delete'><i className='fa fa-fw fa-sign-out' /></a>
  47. </div>
  48. );
  49. }
  50. return (
  51. <div className='drawer'>
  52. {header}
  53. <SearchContainer />
  54. <div className='drawer__pager'>
  55. <div className='drawer__inner'>
  56. <NavigationContainer />
  57. <ComposeFormContainer />
  58. </div>
  59. <Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
  60. {({ x }) =>
  61. <div className='drawer__inner darker' style={{ transform: `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
  62. <SearchResultsContainer />
  63. </div>
  64. }
  65. </Motion>
  66. </div>
  67. </div>
  68. );
  69. }
  70. });
  71. export default connect(mapStateToProps)(injectIntl(Compose));