The code powering m.abunchtell.com https://m.abunchtell.com
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

62 Zeilen
1.5 KiB

  1. import React from 'react';
  2. import ColumnHeader from './column_header';
  3. import PropTypes from 'prop-types';
  4. import { debounce } from 'lodash';
  5. import scrollTop from '../../../scroll';
  6. import { isMobile } from '../../../is_mobile';
  7. export default class Column extends React.PureComponent {
  8. static propTypes = {
  9. heading: PropTypes.string,
  10. icon: PropTypes.string,
  11. children: PropTypes.node,
  12. active: PropTypes.bool,
  13. hideHeadingOnMobile: PropTypes.bool,
  14. };
  15. handleHeaderClick = () => {
  16. const scrollable = this.node.querySelector('.scrollable');
  17. if (!scrollable) {
  18. return;
  19. }
  20. this._interruptScrollAnimation = scrollTop(scrollable);
  21. }
  22. handleScroll = debounce(() => {
  23. if (typeof this._interruptScrollAnimation !== 'undefined') {
  24. this._interruptScrollAnimation();
  25. }
  26. }, 200)
  27. setRef = (c) => {
  28. this.node = c;
  29. }
  30. render () {
  31. const { heading, icon, children, active, hideHeadingOnMobile } = this.props;
  32. const showHeading = !hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth));
  33. const columnHeaderId = showHeading && heading.replace(/ /g, '-');
  34. const header = showHeading && (
  35. <ColumnHeader icon={icon} active={active} type={heading} onClick={this.handleHeaderClick} columnHeaderId={columnHeaderId} />
  36. );
  37. return (
  38. <div
  39. ref={this.setRef}
  40. role='region'
  41. aria-labelledby={columnHeaderId}
  42. className='column'
  43. onScroll={this.handleScroll}
  44. >
  45. {header}
  46. {children}
  47. </div>
  48. );
  49. }
  50. }