闭社主体 forked from https://github.com/tootsuite/mastodon
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

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