Import totalDuration() from lib
This commit is contained in:
parent
9f9c316f30
commit
24b9804c29
|
|
@ -1,6 +1,6 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { Interval, Intensity, IntensityRange, FreeIntensity, Duration } from "make-workout";
|
import { Interval, Intensity, IntensityRange, FreeIntensity, Duration, totalDuration } from "make-workout";
|
||||||
|
|
||||||
type BarProps = {
|
type BarProps = {
|
||||||
width: string;
|
width: string;
|
||||||
|
|
@ -37,9 +37,6 @@ const zoneColor = (intensity: Intensity | IntensityRange | FreeIntensity): strin
|
||||||
return "#7f7f7f";
|
return "#7f7f7f";
|
||||||
}
|
}
|
||||||
|
|
||||||
export const totalDuration = (intervals: Interval[]): Duration =>
|
|
||||||
intervals.reduce((total, interval) => total.add(interval.duration), new Duration(0));
|
|
||||||
|
|
||||||
const toBarProps = (interval: Interval, workoutDuration: Duration): BarProps => ({
|
const toBarProps = (interval: Interval, workoutDuration: Duration): BarProps => ({
|
||||||
background: zoneColor(interval.intensity),
|
background: zoneColor(interval.intensity),
|
||||||
width: `${interval.duration.seconds / workoutDuration.seconds * 100 - 0.1}%`,
|
width: `${interval.duration.seconds / workoutDuration.seconds * 100 - 0.1}%`,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue