2019-12-14 20:02:56 +01:00
|
|
|
import React from 'react'
|
2019-12-13 00:16:53 +01:00
|
|
|
import { useSelector, useDispatch } from 'react-redux'
|
2019-12-14 18:29:17 +01:00
|
|
|
import { debounce } from 'debounce'
|
2019-12-13 00:16:53 +01:00
|
|
|
|
2019-12-13 02:05:04 +01:00
|
|
|
import { setMaxLength, setWpm } from '../store/actions'
|
2019-12-14 18:29:17 +01:00
|
|
|
import { Slider } from './Slider'
|
2019-12-13 00:16:53 +01:00
|
|
|
|
2019-12-14 14:08:19 +01:00
|
|
|
export const Options = () => {
|
2019-12-13 00:16:53 +01:00
|
|
|
const dispatch = useDispatch()
|
2019-12-13 02:05:04 +01:00
|
|
|
const maxLength = useSelector(state => state.maxLength)
|
|
|
|
const wpm = useSelector(state => state.wpm)
|
|
|
|
|
2019-12-13 00:16:53 +01:00
|
|
|
return (
|
|
|
|
<div>
|
2019-12-14 20:02:56 +01:00
|
|
|
<h2>Options</h2>
|
2019-12-14 18:29:17 +01:00
|
|
|
<Slider
|
|
|
|
title={'Maximum segment length'}
|
|
|
|
min={3}
|
2019-12-14 19:22:18 +01:00
|
|
|
max={15}
|
2019-12-13 00:16:53 +01:00
|
|
|
value={maxLength}
|
2019-12-14 20:02:56 +01:00
|
|
|
onChange={debounce(val => dispatch(setMaxLength(val)), 100)}
|
2019-12-13 00:16:53 +01:00
|
|
|
/>
|
2019-12-14 18:29:17 +01:00
|
|
|
<Slider
|
|
|
|
title={'Words per minute'}
|
|
|
|
min={100}
|
|
|
|
max={1000}
|
2019-12-13 02:05:04 +01:00
|
|
|
value={wpm}
|
2019-12-14 19:22:18 +01:00
|
|
|
onChange={debounce(val => dispatch(setWpm(val)), 50)}
|
2019-12-13 02:05:04 +01:00
|
|
|
/>
|
2019-12-13 00:16:53 +01:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|