You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
import "./Misc.sass";
|
|
import {WithChildren} from "../Shared";
|
|
import {Values} from "../../models/Shared";
|
|
|
|
export function TitleLine({children}: WithChildren) {
|
|
return (
|
|
<div className="TitleLine">{children}</div>
|
|
);
|
|
}
|
|
|
|
interface ValueProps {
|
|
raw: Values | number
|
|
valueKey: keyof Values
|
|
}
|
|
|
|
export function Value({raw, valueKey}: ValueProps): JSX.Element | null {
|
|
const actual = typeof raw === "number" ? raw : (raw[valueKey]);
|
|
|
|
if (actual !== null && actual !== undefined) {
|
|
if (valueKey === "time") {
|
|
const minutes = Math.floor(actual / 60).toString(10).padStart(2, "0");
|
|
const seconds = (actual % 60).toString(10).padStart(2, "0");
|
|
|
|
return <><strong>{minutes}</strong>'<strong>{seconds}</strong>"</>;
|
|
}
|
|
|
|
if (valueKey === "calories") {
|
|
return <><strong>{actual}</strong> kcal</>;
|
|
}
|
|
|
|
if (valueKey === "distance") {
|
|
const km = actual / 1000;
|
|
const kmStr = km > 9.95 ? km.toFixed(1) : km.toFixed(2);
|
|
|
|
return <><strong>{kmStr}</strong> km</>;
|
|
}
|
|
|
|
if (valueKey === "level") {
|
|
return <><strong>{actual}</strong> lvl</>;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|