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.

103 lines
2.7 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. propTypes: {
  16. dispatch: React.PropTypes.func.isRequired,
  17. children: React.PropTypes.node
  18. },
  19. getInitialState () {
  20. return {
  21. width: window.innerWidth
  22. };
  23. },
  24. mixins: [PureRenderMixin],
  25. @debounce(500)
  26. handleResize () {
  27. this.setState({ width: window.innerWidth });
  28. },
  29. handleDragOver (e) {
  30. e.preventDefault();
  31. e.stopPropagation();
  32. e.dataTransfer.dropEffect = 'copy';
  33. if (e.dataTransfer.effectAllowed === 'all' || e.dataTransfer.effectAllowed === 'uninitialized') {
  34. //
  35. }
  36. },
  37. handleDrop (e) {
  38. e.preventDefault();
  39. if (e.dataTransfer && e.dataTransfer.files.length === 1) {
  40. this.props.dispatch(uploadCompose(e.dataTransfer.files));
  41. }
  42. },
  43. componentWillMount () {
  44. window.addEventListener('resize', this.handleResize, { passive: true });
  45. window.addEventListener('dragover', this.handleDragOver);
  46. window.addEventListener('drop', this.handleDrop);
  47. },
  48. componentWillUnmount () {
  49. window.removeEventListener('resize', this.handleResize);
  50. window.removeEventListener('dragover', this.handleDragOver);
  51. window.removeEventListener('drop', this.handleDrop);
  52. },
  53. render () {
  54. const layoutBreakpoint = 1024;
  55. let mountedColumns;
  56. if (this.state.width <= layoutBreakpoint) {
  57. mountedColumns = (
  58. <ColumnsArea>
  59. {this.props.children}
  60. </ColumnsArea>
  61. );
  62. } else {
  63. mountedColumns = (
  64. <ColumnsArea>
  65. <Compose withHeader={true} />
  66. <HomeTimeline trackScroll={false} />
  67. <Notifications trackScroll={false} />
  68. {this.props.children}
  69. </ColumnsArea>
  70. );
  71. }
  72. return (
  73. <div style={{ flex: '0 0 auto', display: 'flex', flexDirection: 'column', width: '100%', height: '100%', background: '#1a1c23' }}>
  74. <TabsBar />
  75. {mountedColumns}
  76. <NotificationsContainer />
  77. <LoadingBarContainer style={{ backgroundColor: '#2b90d9', left: '0', top: '0' }} />
  78. <ModalContainer />
  79. </div>
  80. );
  81. }
  82. });
  83. export default connect()(UI);