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'
export const RsvpOptions = () => {
export const Options = () => {
const dispatch = useDispatch()
const maxLength = useSelector(state => state.maxLength)
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 { IconButton } from '../styles/IconButton'
export const RsvpPlayer = () => {
export const PlayerControl = () => {
const dispatch = useDispatch()
const running = useSelector(selectRunning)
const hasNext = useSelector(hasNextSegment)
@ -26,15 +26,13 @@ export const RsvpPlayer = () => {
)
return (
<div>
<div>
<IconButton Icon={FiSquare} onClick={() => dispatch(stop())} />
<IconButton
Icon={running ? FiPause : FiPlay}
onClick={() => dispatch(running ? pause() : start())}
disabled={!hasNext}
/>
</div>
</div>
<>
<IconButton Icon={FiSquare} onClick={() => dispatch(stop())} />
<IconButton
Icon={running ? FiPause : FiPlay}
onClick={() => dispatch(running ? pause() : start())}
disabled={!hasNext}
/>
</>
)
}

View File

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

View File

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