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

102 lines
4.7 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 ImmutablePropTypes from 'react-immutable-proptypes';
  6. import { connect } from 'react-redux';
  7. import { mountCompose, unmountCompose } from '../../actions/compose';
  8. import Link from 'react-router-dom/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. home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
  17. notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
  18. public: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
  19. community: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
  20. preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
  21. logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
  22. });
  23. const mapStateToProps = state => ({
  24. columns: state.getIn(['settings', 'columns']),
  25. showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
  26. });
  27. @connect(mapStateToProps)
  28. @injectIntl
  29. export default class Compose extends React.PureComponent {
  30. static propTypes = {
  31. dispatch: PropTypes.func.isRequired,
  32. columns: ImmutablePropTypes.list.isRequired,
  33. multiColumn: PropTypes.bool,
  34. showSearch: PropTypes.bool,
  35. intl: PropTypes.object.isRequired,
  36. };
  37. componentDidMount () {
  38. this.props.dispatch(mountCompose());
  39. }
  40. componentWillUnmount () {
  41. this.props.dispatch(unmountCompose());
  42. }
  43. render () {
  44. const { multiColumn, showSearch, intl } = this.props;
  45. let header = '';
  46. if (multiColumn) {
  47. const { columns } = this.props;
  48. header = (
  49. <div className='drawer__header'>
  50. <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>
  51. {!columns.some(column => column.get('id') === 'HOME') && (
  52. <Link to='/timelines/home' className='drawer__tab' title={intl.formatMessage(messages.home_timeline)}><i role='img' className='fa fa-fw fa-home' aria-label={intl.formatMessage(messages.home_timeline)} /></Link>
  53. )}
  54. {!columns.some(column => column.get('id') === 'NOTIFICATIONS') && (
  55. <Link to='/notifications' className='drawer__tab' title={intl.formatMessage(messages.notifications)}><i role='img' className='fa fa-fw fa-bell' aria-label={intl.formatMessage(messages.notifications)} /></Link>
  56. )}
  57. {!columns.some(column => column.get('id') === 'COMMUNITY') && (
  58. <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>
  59. )}
  60. {!columns.some(column => column.get('id') === 'PUBLIC') && (
  61. <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>
  62. )}
  63. <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>
  64. <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>
  65. </div>
  66. );
  67. }
  68. return (
  69. <div className='drawer'>
  70. {header}
  71. <SearchContainer />
  72. <div className='drawer__pager'>
  73. <div className='drawer__inner'>
  74. <NavigationContainer />
  75. <ComposeFormContainer />
  76. </div>
  77. <Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
  78. {({ x }) =>
  79. <div className='drawer__inner darker' style={{ transform: `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
  80. <SearchResultsContainer />
  81. </div>
  82. }
  83. </Motion>
  84. </div>
  85. </div>
  86. );
  87. }
  88. }