import "./Misc.sass"; import {WithChildren} from "../Shared"; import {Values} from "../../models/Shared"; export function TitleLine({children}: WithChildren) { return (
{children}
); } 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 <>{minutes}'{seconds}"; } if (valueKey === "calories") { return <>{actual} kcal; } if (valueKey === "distance") { const km = actual / 1000; return <>{km.toFixed(1)} km; } if (valueKey === "level") { return <>{actual} lvl; } } return null; }