💄 Fix passage delay format when waiting time > 1h
When waiting time is less than 1h, the duration shall be displayed, the arrival time otherwise.
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import { VoidComponent, createResource, onMount, ParentComponent, ParentProps, Show, useContext, For } from 'solid-js';
|
import { VoidComponent, createResource, onMount, ParentComponent, ParentProps, Show, useContext, For } from 'solid-js';
|
||||||
import { createDateNow, getTime } from '@solid-primitives/date';
|
import { createDateNow, getTime } from '@solid-primitives/date';
|
||||||
|
|
||||||
import { timeline } from '@motionone/dom';
|
import { timeline } from '@motionone/dom';
|
||||||
import { AnimationOptions } from '@motionone/types';
|
import { AnimationOptions } from '@motionone/types';
|
||||||
import { Motion } from "@motionone/solid";
|
import { Motion } from "@motionone/solid";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
|
||||||
import { Line, TrafficStatus } from './types';
|
import { Line, TrafficStatus } from './types';
|
||||||
import { renderLineTransportMode, renderLinePicto } from './utils';
|
import { renderLineTransportMode, renderLinePicto } from './utils';
|
||||||
@@ -43,6 +43,7 @@ const TtwPassage: VoidComponent<{ line: Line, destination: string, index: number
|
|||||||
|
|
||||||
const refTs = passage !== undefined ? (passage.expectedDepartTs !== null ? passage.expectedDepartTs : passage.expectedArrivalTs) : 0;
|
const refTs = passage !== undefined ? (passage.expectedDepartTs !== null ? passage.expectedDepartTs : passage.expectedArrivalTs) : 0;
|
||||||
const ttwSec = refTs - (getTime(dateNow()) / 1000);
|
const ttwSec = refTs - (getTime(dateNow()) / 1000);
|
||||||
|
const ttwRepr = ttwSec < 3600 ? `${Math.floor(ttwSec / 60)} min` : format(refTs * 1000, "HH:mm");
|
||||||
const isApproaching = ttwSec <= 60;
|
const isApproaching = ttwSec <= 60;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -56,7 +57,7 @@ const TtwPassage: VoidComponent<{ line: Line, destination: string, index: number
|
|||||||
initial={isApproaching ? undefined : false}
|
initial={isApproaching ? undefined : false}
|
||||||
animate={{ opacity: [1, 0, 1] }}
|
animate={{ opacity: [1, 0, 1] }}
|
||||||
transition={transition}>
|
transition={transition}>
|
||||||
{Math.floor(ttwSec / 60)} min
|
{ttwRepr}
|
||||||
</Motion.text>
|
</Motion.text>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user