闭社主体 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.

86 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
8 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 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. @connect(mapStateToProps)
  24. @injectIntl
  25. export default class Compose extends React.PureComponent {
  26. static propTypes = {
  27. dispatch: PropTypes.func.isRequired,
  28. multiColumn: PropTypes.bool,
  29. showSearch: PropTypes.bool,
  30. intl: PropTypes.object.isRequired,
  31. };
  32. componentDidMount () {
  33. this.props.dispatch(mountCompose());
  34. }
  35. componentWillUnmount () {
  36. this.props.dispatch(unmountCompose());
  37. }
  38. render () {
  39. const { multiColumn, showSearch, intl } = this.props;
  40. let header = '';
  41. if (multiColumn) {
  42. header = (
  43. <div className='drawer__header'>
  44. <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>
  45. <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>
  46. <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>
  47. <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>
  48. <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>
  49. </div>
  50. );
  51. }
  52. return (
  53. <div className='drawer'>
  54. {header}
  55. <SearchContainer />
  56. <div className='drawer__pager'>
  57. <div className='drawer__inner'>
  58. <NavigationContainer />
  59. <ComposeFormContainer />
  60. </div>
  61. <Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
  62. {({ x }) =>
  63. <div className='drawer__inner darker' style={{ transform: `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
  64. <SearchResultsContainer />
  65. </div>
  66. }
  67. </Motion>
  68. </div>
  69. </div>
  70. );
  71. }
  72. }