<commit_before>/*!
 * Description:
 *
 *
 * Author:  <NAME>
 * File:
 * Version: 0.0.1
 * Created on 2016-10-16
 */
import React from 'react';

export const History = (props) => {
  const { past, present, future, undo, redo, gotoState } = props;
  const styles = {
    container: {
      marginLeft: '20px',
      cursor: 'pointer',
    },

    link: { textDecoration: 'none' },
    input: { cursor: 'pointer' },
  };

  const RightArrow = () => (
    <a
      href="#"
      style={styles.link}
      onClick={() => redo()}
    >
      &#8594;
    </a>
  );

  const LeftArrow = () => (
    <a
      href="#"
      style={styles.link}
      onClick={() => undo()}
    >
      &#8592;
    </a>
  );

  const max = () =>
    (past ? past.length : 0) +
    (present ? 1 : 0) +
    (future ? future.length : 0) - 1;

  const value = () =>
    past ? past.length : 0;

  return (
    <span style={styles.container}>
      History

      <input
        type="range"
        style={styles.input}
        min={0}
        max={max()}
        value={value()}
        onChange={event => gotoState(event.target.value)}
      />

      {(past && past.length > 0) ? <LeftArrow /> : null}
      {(future && future.length > 0) ? <RightArrow /> : null}
    </span>
  );
};

History.propTypes = {
  past: React.PropTypes.array.isRequired,
  present: React.PropTypes.object.isRequired,
  future: React.PropTypes.array.isRequired,
<commit_msg>Updated documentation<commit_after>/*!
 * Description: History component
 *
 * The app component hierarchy looks like this:
 *
 * App
 *  - ControlsContainer
 *   - TopicSelectorContainer
 *    - TopicSelector
 *   - DisplayModeContainer
 *    - DisplayMode
 *   - HistoryContainer
 *    - History (*)
 *  - BooksContainer
 *   - Book
 *   - Book
 *   - ...
 *  - StateViewerContainer
 *
 * The component gets props from the HistoryContainer component;
 * - past, array of past states
 * - present, current state
 * - future, array of future states
 * - undo(), state history method to undo last change in the state
 * - redo(), state history method to redo next change in the state
 * - gotState(), state history method to go to a specific state.
 *
 * Author:  <NAME>
 * File:
 * Version: 0.0.1
 * Created on 2016-10-16
 */
import React from 'react';


/**
 * History component
 * @param past
 * @param present
 * @param future
 * @param undo
 * @param redo
 * @param gotoState
 * @returns {XML}
 * @constructor
 */
export const History = ({past,present,future,undo,redo,gotoState}) => {
  const styles = {
    container: {
      marginLeft: '20px',
      cursor: 'pointer',
    },

    link: { textDecoration: 'none' },
    input: { cursor: 'pointer' },
  };

  const RightArrow = () => (
    <a
      href="#"
      style={styles.link}
      onClick={() => redo()}
    >
      &#8594;
    </a>
  );

  const LeftArrow = () => (
    <a
      href="#"
      style={styles.link}
      onClick={() => undo()}
    >
      &#8592;
    </a>
  );

  const max = () =>
    (past ? past.length : 0) +
    (present ? 1 : 0) +
    (future ? future.length : 0) - 1;

  const value = () =>
    past ? past.length : 0;

  return (
    <span style={styles.container}>
      History

      <input
        type="range"
        style={styles.input}
        min={0}
        max={max()}
        value={value()}
        onChange={event => gotoState(event.target.value)}
      />

      {(past && past.length > 0) ? <LeftArrow /> : null}
      {(future && future.length > 0) ? <RightArrow /> : null}
    </span>
  );
};

/**
 * History component props
 * @type {{past: *, present: *, future: *, undo: *, redo: *, gotoState: *}}
 */
History.propTypes = {
  past: React.PropTypes.array.isRequired,
  present: React.PropTypes.object.isRequired,
  future: React.PropTypes.array.isRequired,
{'fraction_non_alphanumeric': 0.16754617414248021, 'fraction_numerical': 0.0158311345646438, 'mean_word_length': 2.2794117647058822, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 43, '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': '5792079', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1235, 'n_words': 302}