<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

import Badge from '../Badge';
import BaseButton from '../Button';

class Button extends React.Component {
  static displayName = "Menu.Button";

  static propTypes = {
    children: PropTypes.node.isRequired,
    badge: PropTypes.number,
    href: PropTypes.string,
    active: PropTypes.bool,
    link: PropTypes.string
  };

  render() {
    return (
      <BaseButton className={classNames(`block hover-lime focus-lime truncate`, { "lime": this._isActive() })}
        theme={false}
        href={this.props.href}
        link={this.props.link}
      >
        <div className="flex">
          <div className="flex-auto">{this.props.children}</div>
          <div className="flex-none">{this._renderBadge()}</div>
        </div>
      </BaseButton>
    );
  }

  _isActive() {
    if (this.props.active !== undefined) {
      return this.props.active;
    } else {
      // Use a super simple way of figuring out if the current href is active
      return window.location.pathname.indexOf(this.props.link || this.props.href) === 0;
    }
  }<commit_msg>Make sure menu buttons truncate contents if neccessary<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

import Badge from '../Badge';
import BaseButton from '../Button';

class Button extends React.Component {
  static displayName = "Menu.Button";

  static propTypes = {
    children: PropTypes.node.isRequired,
    badge: PropTypes.number,
    href: PropTypes.string,
    active: PropTypes.bool,
    link: PropTypes.string
  };

  render() {
    return (
      <BaseButton className={classNames(`block hover-lime focus-lime truncate`, { "lime": this._isActive() })}
        theme={false}
        href={this.props.href}
        link={this.props.link}
      >
        <div className="flex">
          <div className="flex-auto truncate">{this.props.children}</div>
          <div className="flex-none">{this._renderBadge()}</div>
        </div>
      </BaseButton>
    );
  }

  _isActive() {
    if (this.props.active !== undefined) {
      return this.props.active;
    } else {
      // Use a super simple way of figuring out if the current href is active
      return window.location.pathname.indexOf(this.props.link || this.props.href) === 0;
    }
  }
{'fraction_non_alphanumeric': 0.13700918964076858, 'fraction_numerical': 0.000835421888053467, 'mean_word_length': 2.881685575364668, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2474507', 'n_tokens_mistral': 709, 'n_tokens_neox': 709, 'n_words': 176}