import { useSize } from '../../hooks/useSize'; import { SBBDepartureItem } from '../molecules/SBBDepartureItem'; import { SBBDeparture } from '../../types'; import { useAlwaysOn } from '../../contexts/AlwaysOnContext'; const ROW_H = 56; const HEADER_H = 38; export const SBBDepartureList = ({ departures, loading, stationName, }: { departures: SBBDeparture[]; loading: boolean; stationName?: string; }) => { const alwaysOn = useAlwaysOn(); const { h, w, ref } = useSize(); const effectiveH = h || 300; const listH = effectiveH - (stationName ? HEADER_H : 0); const maxRows = Math.max(1, Math.floor(listH / ROW_H)); // Platform column only when the slot is wide enough to show it comfortably const showPlatform = (w || 0) > 320; const visible = departures.slice(0, maxRows); return (
{stationName && (

{stationName}

)} {loading && departures.length === 0 ? (

Loading…

) : visible.length === 0 ? (

No departures

) : ( visible.map((dep, i) => ( )) )}
); };