The code powering m.abunchtell.com https://m.abunchtell.com
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.6 KiB

  1. import React from 'react';
  2. import ComposeFormContainer from './containers/compose_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-dom/Link';
  8. import { injectIntl, defineMessages } from 'react-intl';
  9. import SearchContainer from './containers/search_container';
  10. import Motion from 'react-motion/lib/Motion';
  11. import spring from 'react-motion/lib/spring';
  12. import SearchResultsContainer from './containers/search_results_container';
  13. const messages = defineMessages({
  14. start: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
  15. public: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
  16. community: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
  17. preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
  18. logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
  19. });
  20. const mapStateToProps = state => ({
  21. showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
  22. });
  23. class Compose extends React.PureComponent {
  24. static propTypes = {
  25. dispatch: PropTypes.func.isRequired,
  26. multiColumn: PropTypes.bool,
  27. showSearch: PropTypes.bool,
  28. intl: PropTypes.object.isRequired,
  29. };
  30. componentDidMount () {
  31. this.props.dispatch(mountCompose());
  32. }
  33. componentWillUnmount () {
  34. this.props.dispatch(unmountCompose());
  35. }
  36. render () {
  37. const { multiColumn, showSearch, intl } = this.props;
  38. let header = '';
  39. if (multiColumn) {
  40. header = (
  41. <div className='drawer__header'>
  42. <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>
  43. <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>
  44. <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>
  45. <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>
  46. <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>
  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));