Stats.res.mjs
1// Generated by ReScript, PLEASE EDIT WITH CARE
2
3import * as Time from "../lib/Time.res.mjs";
4import * as Units from "../lib/Units.res.mjs";
5import * as Waypoint from "../ffi/Waypoint.res.mjs";
6import * as JsxRuntime from "preact/jsx-runtime";
7
8function Stats(props) {
9 let waypoints = props.waypoints;
10 let time = props.time;
11 let dist = props.dist;
12 let getLabel = (id, orElse) => {
13 let wp = Waypoint.findById(waypoints, id);
14 if (wp !== undefined) {
15 return wp.label;
16 } else {
17 return orElse;
18 }
19 };
20 let id = dist.previousID;
21 let previousLabel = id !== undefined ? getLabel(id, "previous waypoint") : "previous waypoint";
22 let id$1 = dist.nextID;
23 let nextLabel = id$1 !== undefined ? getLabel(id$1, "next waypoint") : "next waypoint";
24 let headers = "font-bold col-span-2 flex flex-row items-center h-fit";
25 let stat = "font-mono justify-self-end h-fit leading-none";
26 return JsxRuntime.jsxs("div", {
27 children: [
28 JsxRuntime.jsx("div", {
29 children: "From " + previousLabel,
30 className: headers
31 }),
32 JsxRuntime.jsx("div", {
33 children: Units.distance(dist.fromPreviousWaypoint, "km"),
34 className: stat
35 }),
36 JsxRuntime.jsx("div", {
37 children: Time.humanize(time.fromPreviousWaypoint),
38 className: stat
39 }),
40 JsxRuntime.jsx("div", {
41 children: "To " + nextLabel,
42 className: headers
43 }),
44 JsxRuntime.jsx("div", {
45 children: Units.distance(dist.toNextWaypoint, "km"),
46 className: stat
47 }),
48 JsxRuntime.jsx("div", {
49 children: Time.humanize(time.toNextWaypoint),
50 className: stat
51 })
52 ],
53 className: "grid md:grid-cols-4 grid-cols-2 items-center"
54 });
55}
56
57let make = Stats;
58
59export {
60 make,
61}
62/* preact/jsx-runtime Not a pure module */