diff --git a/src/components/atoms/SBBLineBadge.tsx b/src/components/atoms/SBBLineBadge.tsx new file mode 100644 index 0000000..617d091 --- /dev/null +++ b/src/components/atoms/SBBLineBadge.tsx @@ -0,0 +1,5 @@ +export const SBBLineBadge = ({ name }: { name: string; category?: string }) => ( + + {name} + +); diff --git a/src/components/molecules/SBBDepartureItem.tsx b/src/components/molecules/SBBDepartureItem.tsx new file mode 100644 index 0000000..d09d1b2 --- /dev/null +++ b/src/components/molecules/SBBDepartureItem.tsx @@ -0,0 +1,24 @@ +import { SBBLineBadge } from '../atoms/SBBLineBadge'; +import { SBBDeparture } from '../../types'; +import { useAlwaysOn } from '../../contexts/AlwaysOnContext'; + +export const SBBDepartureItem = ({ departure }: { departure: SBBDeparture }) => { + const alwaysOn = useAlwaysOn(); + const dep = departure.stop.departure ? new Date(departure.stop.departure) : null; + const diffMin = dep ? Math.round((dep.getTime() - Date.now()) / 60000) : null; + const timeText = diffMin === null ? '—' : diffMin <= 0 ? 'Now' : `${diffMin} min`; + const delay = departure.stop.delay; + + return ( +
Loading...
; + if (!loading && departures.length === 0) returnNo departures.
; + return ( +