Integrate PlayerControl in SegmentControl

This commit is contained in:
Alfred Melch 2019-12-14 14:08:19 +01:00
parent 61d85838ae
commit 46f3d1f095
4 changed files with 19 additions and 19 deletions

View File

@ -3,7 +3,7 @@ import { useSelector, useDispatch } from 'react-redux'
import { setMaxLength, setWpm } from '../store/actions' import { setMaxLength, setWpm } from '../store/actions'
export const RsvpOptions = () => { export const Options = () => {
const dispatch = useDispatch() const dispatch = useDispatch()
const maxLength = useSelector(state => state.maxLength) const maxLength = useSelector(state => state.maxLength)
const wpm = useSelector(state => state.wpm) const wpm = useSelector(state => state.wpm)

View File

@ -11,7 +11,7 @@ import { FiPlay, FiPause, FiSquare } from 'react-icons/fi'
import { useInterval } from './generics/useInterval' import { useInterval } from './generics/useInterval'
import { IconButton } from '../styles/IconButton' import { IconButton } from '../styles/IconButton'
export const RsvpPlayer = () => { export const PlayerControl = () => {
const dispatch = useDispatch() const dispatch = useDispatch()
const running = useSelector(selectRunning) const running = useSelector(selectRunning)
const hasNext = useSelector(hasNextSegment) const hasNext = useSelector(hasNextSegment)
@ -26,15 +26,13 @@ export const RsvpPlayer = () => {
) )
return ( return (
<div> <>
<div> <IconButton Icon={FiSquare} onClick={() => dispatch(stop())} />
<IconButton Icon={FiSquare} onClick={() => dispatch(stop())} /> <IconButton
<IconButton Icon={running ? FiPause : FiPlay}
Icon={running ? FiPause : FiPlay} onClick={() => dispatch(running ? pause() : start())}
onClick={() => dispatch(running ? pause() : start())} disabled={!hasNext}
disabled={!hasNext} />
/> </>
</div>
</div>
) )
} }

View File

@ -1,10 +1,10 @@
import React from 'react' import React from 'react'
import { TextInput } from './TextInput' import { TextInput } from './TextInput'
import { TextOutput } from './TextOutput' import { TextOutput } from './TextOutput'
import { MainControl } from './MainControl' import { SegmentControl } from './SegmentControl'
import { RsvpSegment } from './RsvpSegment' import { RsvpSegment } from './RsvpSegment'
import { RsvpOptions } from './RsvpOptions' import { Options } from './Options'
import { RsvpPlayer } from './RsvpPlayer' import { PlayerControl } from './PlayerControl'
import styles from './RsvpReader.css' import styles from './RsvpReader.css'
@ -16,9 +16,10 @@ export const RsvpReader = () => {
</div> </div>
<div className={styles.mainItem}> <div className={styles.mainItem}>
<RsvpSegment /> <RsvpSegment />
<MainControl></MainControl> <SegmentControl>
<RsvpOptions></RsvpOptions> <PlayerControl />
<RsvpPlayer /> </SegmentControl>
<Options></Options>
</div> </div>
<div className={styles.item}> <div className={styles.item}>
<TextOutput /> <TextOutput />

View File

@ -16,7 +16,7 @@ import {
decrementWord decrementWord
} from '../store/actions' } from '../store/actions'
export const MainControl = () => { export const SegmentControl = ({ children }) => {
const dispatch = useDispatch() const dispatch = useDispatch()
return ( return (
<div> <div>
@ -30,6 +30,7 @@ export const MainControl = () => {
title="Previous Word" title="Previous Word"
onClick={() => dispatch(decrementWord())} onClick={() => dispatch(decrementWord())}
/> />
{children}
<IconButton <IconButton
Icon={FiSkipForward} Icon={FiSkipForward}
title="Next Word" title="Next Word"