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.

55 lines
1.6 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import ImmutablePureComponent from 'react-immutable-pure-component';
  5. import HomeTimeline from '../../home_timeline';
  6. import Notifications from '../../notifications';
  7. import PublicTimeline from '../../public_timeline';
  8. import CommunityTimeline from '../../community_timeline';
  9. import HashtagTimeline from '../../hashtag_timeline';
  10. import Compose from '../../compose';
  11. const componentMap = {
  12. 'COMPOSE': Compose,
  13. 'HOME': HomeTimeline,
  14. 'NOTIFICATIONS': Notifications,
  15. 'PUBLIC': PublicTimeline,
  16. 'COMMUNITY': CommunityTimeline,
  17. 'HASHTAG': HashtagTimeline,
  18. };
  19. class ColumnsArea extends ImmutablePureComponent {
  20. static propTypes = {
  21. columns: ImmutablePropTypes.list.isRequired,
  22. singleColumn: PropTypes.bool,
  23. children: PropTypes.node,
  24. };
  25. render () {
  26. const { columns, children, singleColumn } = this.props;
  27. if (singleColumn) {
  28. return (
  29. <div className='columns-area'>
  30. {children}
  31. </div>
  32. );
  33. }
  34. return (
  35. <div className='columns-area'>
  36. {columns.map(column => {
  37. const SpecificComponent = componentMap[column.get('id')];
  38. const params = column.get('params', null) === null ? null : column.get('params').toJS();
  39. return <SpecificComponent key={column.get('uuid')} columnId={column.get('uuid')} params={params} multiColumn />;
  40. })}
  41. {React.Children.map(children, child => React.cloneElement(child, { multiColumn: true }))}
  42. </div>
  43. );
  44. }
  45. }
  46. export default ColumnsArea;