var React = require('react/addons') module.exports = React.createClass({ propTypes: { articles: React.PropTypes.arrayOf, currentArticle: React.PropTypes.shape({ id: React.PropTypes.number, type: React.PropTypes.string }) }, componentDidUpdate: function () { var index = this.props.articles.indexOf(this.props.currentArticle) var el = React.findDOMNode(this) var li = el.querySelectorAll('li')[index] var overflowBelow = el.clientHeight + el.scrollTop < li.offsetTop + li.clientHeight if (overflowBelow) { el.scrollTop = li.offsetTop + li.clientHeight - el.clientHeight } var overflowAbove = el.scrollTop > li.offsetTop if (overflowAbove) { el.scrollTop = li.offsetTop } }, render: function () { var list = this.props.articles.map(function (article) { if (article == null) { return (
  • Undefined
  • ) } var isActive = this.props.currentArticle != null && (article.type === this.props.currentArticle.type && article.id === this.props.currentArticle.id) if (article.type === 'snippet') { return (
  • {article.callSign} / {article.description.substring(0, 10)}
  • ) } if (article.type === 'blueprint') { return (
  • {article.title}
  • ) } return (
  • Undefined
  • ) }.bind(this)) return (
      {list}
    ) } })