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

98 lines
2.6 KiB

  1. import ColumnsArea from './components/columns_area';
  2. import NotificationsContainer from './containers/notifications_container';
  3. import PureRenderMixin from 'react-addons-pure-render-mixin';
  4. import LoadingBarContainer from './containers/loading_bar_container';
  5. import HomeTimeline from '../home_timeline';
  6. import MentionsTimeline from '../mentions_timeline';
  7. import Compose from '../compose';
  8. import TabsBar from './components/tabs_bar';
  9. import ModalContainer from './containers/modal_container';
  10. import Notifications from '../notifications';
  11. import { debounce } from 'react-decoration';
  12. import { uploadCompose } from '../../actions/compose';
  13. import { connect } from 'react-redux';
  14. const UI = React.createClass({
  15. getInitialState () {
  16. return {
  17. width: window.innerWidth
  18. };
  19. },
  20. mixins: [PureRenderMixin],
  21. @debounce(500)
  22. handleResize () {
  23. this.setState({ width: window.innerWidth });
  24. },
  25. handleDragOver (e) {
  26. e.preventDefault();
  27. e.stopPropagation();
  28. e.dataTransfer.dropEffect = 'copy';
  29. if (e.dataTransfer.effectAllowed === 'all' || e.dataTransfer.effectAllowed === 'uninitialized') {
  30. //
  31. }
  32. },
  33. handleDrop (e) {
  34. e.preventDefault();
  35. if (e.dataTransfer) {
  36. this.props.dispatch(uploadCompose(e.dataTransfer.files));
  37. }
  38. },
  39. componentWillMount () {
  40. window.addEventListener('resize', this.handleResize, { passive: true });
  41. window.addEventListener('dragover', this.handleDragOver);
  42. window.addEventListener('drop', this.handleDrop);
  43. },
  44. componentWillUnmount () {
  45. window.removeEventListener('resize', this.handleResize);
  46. window.removeEventListener('dragover', this.handleDragOver);
  47. window.removeEventListener('drop', this.handleDrop);
  48. },
  49. render () {
  50. const layoutBreakpoint = 1024;
  51. let mountedColumns;
  52. if (this.state.width <= layoutBreakpoint) {
  53. mountedColumns = (
  54. <ColumnsArea>
  55. {this.props.children}
  56. </ColumnsArea>
  57. );
  58. } else {
  59. mountedColumns = (
  60. <ColumnsArea>
  61. <Compose />
  62. <HomeTimeline trackScroll={false} />
  63. <Notifications trackScroll={false} />
  64. {this.props.children}
  65. </ColumnsArea>
  66. );
  67. }
  68. return (
  69. <div style={{ flex: '0 0 auto', display: 'flex', flexDirection: 'column', width: '100%', height: '100%', background: '#1a1c23' }}>
  70. <TabsBar />
  71. {mountedColumns}
  72. <NotificationsContainer />
  73. <LoadingBarContainer style={{ backgroundColor: '#2b90d9', left: '0', top: '0' }} />
  74. <ModalContainer />
  75. </div>
  76. );
  77. }
  78. });
  79. export default connect()(UI);