{"size": 1278, "ext": "js", "max_stars_repo_path": "app/components/SideBar/MenuLinks/index.js", "max_stars_repo_name": "hybridnetwork/decrediton", "max_stars_repo_stars_event_min_datetime": "2018-03-09T11:01:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-24T16:32:24.000Z", "max_issues_repo_path": "app/components/SideBar/MenuLinks/index.js", "max_issues_repo_name": "coolsnady/hxGUI", "max_issues_repo_issues_event_min_datetime": "2018-02-20T22:04:52.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-21T23:42:34.000Z", "max_forks_repo_path": "app/components/SideBar/MenuLinks/index.js", "max_forks_repo_name": "coolsnady/hxGUI", "max_forks_repo_forks_event_min_datetime": "2018-02-27T21:13:23.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-13T01:02:56.000Z"}
{"max_stars_count": 7, "max_issues_count": 2, "max_forks_count": 2, "avg_line_length": 26.0816326531, "max_line_length": 97, "alphanum_fraction": 0.6048513302}
import { injectIntl } from "react-intl";
import { spring, Motion } from "react-motion";
import { withRouter } from "react-router";
import { getPage } from "helpers";
import MenuLink from "./MenuLink";
import messages from "messages";
import theme from "theme";

const linkList = [
  "home",
  "accounts",
  "transactions",
  "tickets",
  //// hide for now
  // "security",
  // "settings",
  // "help"
];

@autobind
class MenuLinks extends React.Component {
  constructor (props) { super(props); }
  _nodes = new Map();
  state = { top: 0 };

  componentWillReceiveProps(nextProps) {
    const activeLink = getPage(nextProps.routes);
    const basePage = activeLink.split("/")[0];
    const newTop = this._nodes.get(basePage).offsetTop;
    this.setState({ top: spring(newTop, theme("springs.sideBar")) });
  }

  render () {
    return (
      <Aux>
        { linkList.map(link =>
          <MenuLink to={ "/" + link } linkRef={ ref => this._nodes.set(link, ref) } key={ link }>
            { this.props.intl.formatMessage(messages["menu." + link]) }
          </MenuLink> )}
        <Motion style={ this.state }>
          { style => <div className="menu-caret" {...{ style }}/> }
        </Motion>
      </Aux>
    );
  }
}

export default withRouter(injectIntl(MenuLinks));
