<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Button, Slider } from '@blueprintjs/core';
import { twoDigits } from '../../utils/countdown-timer';

export default class CountdownTimer extends Component {
  constructor() {
    super();
    this.state = {
      minutes: 0,
      seconds: 0
    };
  }

  onSliderChange(value) {
    this.setState({ minutes: value });
  }

  render() {
    const { minutes, seconds } = this.state;

    return (
      <div className="count-down">
        <div className="zf-timer">
          <span className="zf-timer-minute">{twoDigits(minutes)}</span>
          <span className="zf-timer-divider">:</span>
          <span className="zf-timer-seconds">{twoDigits(seconds)}</span>
        </div>

        <Slider
          max={60}
          min={0}
          renderLabel={false}
          value={minutes}
          onChange={(v) => this.onSliderChange(v)}
        />

        <Button
          iconName="play"
        />
      </div>
    );
  }
}

CountdownTimer.propTypes = {
  time: PropTypes.number.isRequired
};<commit_msg>feat: Add pause and play functionnality<commit_after>import React, { Component } from 'react';
import { Button, Slider } from '@blueprintjs/core';
import { twoDigits } from '../../utils/countdown-timer';

export default class CountdownTimer extends Component {
  constructor() {
    super();
    this.state = {
      minutes: 0,
      seconds: 0,
      isPlaying: false,
      disableSlider: false
    };
  }

  tick() {
    const { minutes, seconds } = this.state;

    if (seconds > 0) {
      this.setState({ seconds: seconds - 1 });
    } else if (minutes > 0) {
      this.setState({
        minutes: minutes - 1,
        seconds: 59
      });
    }
  }

  pause() {
    this.setState({
      isPlaying: false,
      disableSlider: false
    });

    clearInterval(this.ticker);
  }

  resume() {
    const { minutes, seconds } = this.state;

    if (minutes === 0 && seconds === 0) return;

    this.setState({
      isPlaying: true,
      disableSlider: true
    });

    this.ticker = setInterval(() => this.tick(), 1000);
  }

  onMediaControlClick() {
    const isPlaying = this.state.isPlaying;

    if (isPlaying) {
      this.pause();
    } else {
      this.resume();
    }
  }

  onSliderChange(value) {
    this.setState({ minutes: value, seconds: 0 });
  }

  render() {
    const {
      minutes,
      seconds,
      isPlaying,
      disableSlider
    } = this.state;

    return (
      <div className="count-down">
        <div className="zf-timer">
          <span className="zf-timer-minute">{twoDigits(minutes)}</span>
          <span className="zf-timer-divider">:</span>
          <span className="zf-timer-seconds">{twoDigits(seconds)}</span>
        </div>

        <Slider
          disabled={disableSlider}
          max={60}
          min={0}
          renderLabel={false}
          value={minutes}
          onChange={(v) => this.onSliderChange(v)}
        />

        <div className="text-center mt-3">
          <Button
            active={isPlaying}
            iconName={isPlaying ? 'pause' : 'play'}
            onClick={() => this.onMediaControlClick()}
            className="pt-large"
          />
        </div>
      </div>
    );
  }
}
{'fraction_non_alphanumeric': 0.15036452004860268, 'fraction_numerical': 0.007290400972053463, 'mean_word_length': 2.092018779342723, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, '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': '3624238', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1009, 'n_words': 205}