Skip to content

Commit 25b73fb

Browse files
committed
added design: information for the scheduled line
1 parent 4ee4f94 commit 25b73fb

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

src/app/components/scheduled.tsx

+41-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,51 @@ interface ScheduledProps {
77
isEven: boolean
88
}
99

10-
const ScheduledComponent: React.FC<ScheduledProps> = ({ scheduled, isEven }) => {
10+
const ScheduledComponent: React.FC<ScheduledProps> = ({scheduled, isEven}) => {
1111
const backgroundColor = isEven ? "#0a0a0a" : "#1a1a1a";
1212

13+
const isDelayed = () => {
14+
const planned = new Date(scheduled.plannedWhen);
15+
const actual = new Date(scheduled.actualWhen);
16+
return actual > planned;
17+
}
18+
1319
return (
14-
<div
15-
className="p-4 rounded-md text-white hover:cursor-pointer"
16-
style={{ backgroundColor }}
20+
<div className="container mx-auto flex justify-between space-x-4 text-white text-base font-bold border-gray-400"
21+
style={{backgroundColor}}
1722
>
18-
<p className="font-semibold">{scheduled.line.name}</p>
19-
<p className="text-sm">
20-
Richtung: {scheduled.directionName} - Abfahrt: {scheduled.plannedWhen}
21-
</p>
23+
{/* First col */}
24+
<div className={`flex-[1] text-right mr-8 border-t pt-2 space-y-4`}>
25+
{/* Line */}
26+
<span className={`${scheduled.color ? 'p-2 rounded-md' : ''}`}
27+
style={{backgroundColor: scheduled.color?.backgroundColor || 'inherit'}}
28+
>
29+
{scheduled.line.name}
30+
</span>
31+
32+
{/* Departure time */}
33+
<div className="flex flex-row items-center justify-end space-x-4 text-xl">
34+
<span className={`${isDelayed() ? 'line-through text-red-500' : ''}`}>
35+
{new Date(scheduled.plannedWhen).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'})}
36+
</span>
37+
{isDelayed() ? (
38+
<span className="bg-red-500 p-1">
39+
{new Date(scheduled.actualWhen).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'})}
40+
</span>
41+
) : (<></>)}
42+
</div>
43+
</div>
44+
45+
{/* Second col */}
46+
<div className="flex-[4] text-left border-t pt-4">
47+
<p>Über</p>
48+
<p>Ziel</p>
49+
</div>
50+
51+
{/* Third col */}
52+
<div className="flex-[1] flex justify-end items-end text-right border-t pt-4^">
53+
<p>Gleis</p>
54+
</div>
2255
</div>
2356
);
2457
}

0 commit comments

Comments
 (0)