import { Component } from 'react' 
import { Motion, spring } from 'react-motion'
import style from './Compteur.module.scss'

export class Nombre extends Component {
  _getNumbers() {
    let numbers = []
    let i = 0
    
    while (i < 10) {
      numbers.push(<div>{i}</div>)
      i++
    }
    
    return numbers
  }
  
  render() {
    const { current } = this.props
    
    return (
      <div className={style.vote__column}>
        <Motion
          style={{y: spring(current * 10)}}
        >
          {({y}) =>
            <div
              style={{
                transform: `translateY(${-y}%)`
              }}
            >
              {this._getNumbers()}
            </div>
          }
        </Motion>
      </div>
    )
  }
}
