Add a time estimate
This commit is contained in:
parent
c774725270
commit
6cc58a70bd
@ -9,6 +9,7 @@ import { PlayerControl } from './PlayerControl'
|
|||||||
import styles from './RsvpReader.css'
|
import styles from './RsvpReader.css'
|
||||||
import { PipeMarker, BorderMarker } from './PivotMarker'
|
import { PipeMarker, BorderMarker } from './PivotMarker'
|
||||||
import { Progress } from './Progress'
|
import { Progress } from './Progress'
|
||||||
|
import { TimeCalc } from './TimeCalc'
|
||||||
|
|
||||||
export const RsvpReader = () => {
|
export const RsvpReader = () => {
|
||||||
return (
|
return (
|
||||||
@ -27,6 +28,7 @@ export const RsvpReader = () => {
|
|||||||
</SegmentControl>
|
</SegmentControl>
|
||||||
</div>
|
</div>
|
||||||
<Options></Options>
|
<Options></Options>
|
||||||
|
<TimeCalc />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.item}>
|
<div className={styles.item}>
|
||||||
<TextOutput />
|
<TextOutput />
|
||||||
|
23
src/components/TimeCalc.js
Normal file
23
src/components/TimeCalc.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { useSelector } from 'react-redux'
|
||||||
|
import { selectSegments, selectWpm } from '../store/selectors'
|
||||||
|
|
||||||
|
function formatTime(totalSeconds) {
|
||||||
|
const hours = Math.floor(totalSeconds / 3600)
|
||||||
|
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||||
|
const seconds = Math.floor(totalSeconds % 60)
|
||||||
|
const pad = num => String(num).padStart(2, '0')
|
||||||
|
return `${hours}:${pad(minutes)}:${pad(seconds)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TimeCalc = () => {
|
||||||
|
const wpm = useSelector(selectWpm)
|
||||||
|
const segments = useSelector(selectSegments)
|
||||||
|
const minutesNeeded = segments.length / wpm
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2>Time needed</h2>
|
||||||
|
Time needed for Text: {formatTime(minutesNeeded * 60)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user