Import totalDuration() from lib
This commit is contained in:
@@ -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}%`,
|
||||||
|
|||||||
Reference in New Issue
Block a user