<commit_before>import React, { Component, PropTypes } from 'react';
import {districtColors, partyData} from './Constants';

class Precinct extends Component {
  renderDots(dots, party) {
    const color = party ? partyData[party].color: "black";
    // TODO(benkraft): make dots clickable too
    return dots && dots.map(({x, y}, i) => <circle fill={color} key={i} cx={x} cy={y} r={0.03} />);
  }

  render() {
    const {district, dots, party, ...props} = this.props;
    return <g>
      <rect stroke="black" strokeWidth="0.01" fill={districtColors[district]} {...props} />
      {this.renderDots(dots, party)}
    </g>;
  }
}

Precinct.propTypes = {
  x: PropTypes.number.isRequired,
  y: PropTypes.number.isRequired,
  width: PropTypes.number.isRequired,
  height: PropTypes.number.isRequired,
  district: PropTypes.number.isRequired,
  party: PropTypes.string,
  dots: PropTypes.arrayOf(PropTypes.shape({
    x: PropTypes.number.isRequired,
    y: PropTypes.number.isRequired,
  })),
};

export default Precinct;<commit_msg>Fix clicking on dots bug<commit_after>import React, { Component, PropTypes } from 'react';
import {districtColors, partyData} from './Constants';

class Precinct extends Component {
  renderDots(dots, party) {
    const color = party ? partyData[party].color: "black";
    // TODO(benkraft): make dots clickable too
    return dots && dots.map(({x, y}, i) => <circle fill={color} key={i} cx={x} cy={y} r={0.03} />);
  }

  render() {
    const {
        district, dots, party,
        onMouseDown, onMouseEnter, onMouseUp, onContextMenu,
        ...props} = this.props;
    return <g {...{onMouseDown, onMouseEnter, onMouseUp, onContextMenu}}>
      <rect stroke="black" strokeWidth="0.01" fill={districtColors[district]} {...props} />
      {this.renderDots(dots, party)}
    </g>;
  }
}

Precinct.propTypes = {
  x: PropTypes.number.isRequired,
  y: PropTypes.number.isRequired,
  width: PropTypes.number.isRequired,
  height: PropTypes.number.isRequired,
  district: PropTypes.number.isRequired,
  party: PropTypes.string,
  dots: PropTypes.arrayOf(PropTypes.shape({
    x: PropTypes.number.isRequired,
    y: PropTypes.number.isRequired,
  })),
  onMouseDown: PropTypes.func.isRequired,
  onMouseEnter: PropTypes.func.isRequired,
  onMouseUp: PropTypes.func.isRequired,
  onContextMenu: PropTypes.func.isRequired,
};

export default Precinct;
{'fraction_non_alphanumeric': 0.15242105263157896, 'fraction_numerical': 0.0050526315789473685, 'mean_word_length': 4.002105263157895, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1149913', 'n_tokens_mistral': 782, 'n_tokens_neox': 782, 'n_words': 173}