Skip to content

Commit 1fcc0ec

Browse files
committed
added "responsive design"
1 parent 523f54b commit 1fcc0ec

File tree

1 file changed

+64
-19
lines changed

1 file changed

+64
-19
lines changed

src/app/components/scheduled.tsx

+64-19
Original file line numberDiff line numberDiff line change
@@ -55,40 +55,85 @@ const ScheduledComponent: React.FC<ScheduledProps> = ({trip, isDeparture, isEven
5555
)
5656
}
5757

58-
return (
59-
<div className={`container mx-auto flex justify-between space-x-4 text-[28px] font-medium ${trip.cancelled ? 'border-[#0a0a0a] text-black' : 'border-gray-400' } pb-4`}
60-
style={{ backgroundColor: trip.cancelled ? '#ededed' : backgroundColor }}
58+
return (<>
59+
{/* layout for smaller screens (under md) */}
60+
<div
61+
className={`mx-2 py-4 text-sm md:hidden border-t space-y-2 text-[20px]`}
62+
style={{backgroundColor: trip.cancelled ? '#ededed' : backgroundColor}}
63+
>
64+
{/* first line */}
65+
<span className={`${color ? 'py-2 px-3 rounded-2xl font-bold' : ''} text-sm mx-auto`}
66+
style={{backgroundColor: color?.backgroundColor || 'inherit'}}
67+
>
68+
{trip.lineInformation.fullName}
69+
</span>
70+
71+
{/* second line */}
72+
<div className="flex flex-row items-center space-x-2">
73+
<span
74+
className={`text-base flex items-center justify-center`}
75+
style={{height: '1.5rem'}}
76+
>
77+
{new Date(isDeparture ? trip.departure.plannedTime : trip.arrival.plannedTime).toLocaleTimeString([], {
78+
hour: '2-digit',
79+
minute: '2-digit'
80+
})}
81+
</span>
82+
{isDelayed() ? (
83+
<span
84+
className={`${isDelayed() ? '' : ''} bg-[#ededed] text-[#0a0a0a] flex items-center justify-center`}
85+
style={{height: '1.5rem', padding: '0 0.4rem'}}
86+
>
87+
{new Date(isDeparture ? trip.departure.actualTime : trip.arrival.actualTime).toLocaleTimeString([], {
88+
hour: '2-digit',
89+
minute: '2-digit'
90+
})}
91+
</span>
92+
) : (<></>)}
93+
</div>
94+
95+
{/* Zweite Zeile */}
96+
<div className="flex justify-between mt-2">
97+
<span>{isDeparture ? trip.destination.name : trip.origin.name}</span>
98+
{showPlatform()}
99+
</div>
100+
</div>
101+
102+
{/* layout for greater screens (above md) */}
103+
<div
104+
className={`container mx-auto hidden md:flex justify-between space-x-4 text-[28px] font-medium ${trip.cancelled ? 'border-[#0a0a0a] text-black' : 'border-gray-400'} pb-4`}
105+
style={{backgroundColor: trip.cancelled ? '#ededed' : backgroundColor}}
61106
>
62107
{/* First col */}
63108
<div className={`flex-[1] text-right mr-8 border-t pt-4 space-y-4`}>
64109
{/* Line */}
65110
<span className={`${color ? 'p-2 rounded-2xl px-4 font-bold' : ''} text-xl`}
66111
style={{backgroundColor: color?.backgroundColor || 'inherit'}}
67112
>
68-
{trip.lineInformation.fullName}
69-
</span>
113+
{trip.lineInformation.fullName}
114+
</span>
70115

71116
{/* Departure time */}
72117
<div className="flex flex-row items-center justify-end space-x-2">
73-
<span
74-
className={`${isDelayed() ? '' : ''} flex items-center justify-center`}
75-
style={{height: '2rem'}}
76-
>
77-
{new Date(isDeparture ? trip.departure.plannedTime : trip.arrival.plannedTime).toLocaleTimeString([], {
78-
hour: '2-digit',
79-
minute: '2-digit'
80-
})}
81-
</span>
82-
{isDelayed() ? (
83118
<span
84-
className={`${isDelayed() ? 'font-bold' : ''} bg-[#ededed] text-[#0a0a0a] flex items-center justify-center text-[20px]`}
85-
style={{height: '1.5rem', padding: '0 0.4rem'}}
119+
className={`${isDelayed() ? '' : ''} flex items-center justify-center`}
120+
style={{height: '2rem'}}
86121
>
87-
{new Date(isDeparture ? trip.departure.actualTime : trip.arrival.actualTime).toLocaleTimeString([], {
122+
{new Date(isDeparture ? trip.departure.plannedTime : trip.arrival.plannedTime).toLocaleTimeString([], {
88123
hour: '2-digit',
89124
minute: '2-digit'
90125
})}
91126
</span>
127+
{isDelayed() ? (
128+
<span
129+
className={`${isDelayed() ? 'font-bold' : ''} bg-[#ededed] text-[#0a0a0a] flex items-center justify-center text-[20px]`}
130+
style={{height: '1.5rem', padding: '0 0.4rem'}}
131+
>
132+
{new Date(isDeparture ? trip.departure.actualTime : trip.arrival.actualTime).toLocaleTimeString([], {
133+
hour: '2-digit',
134+
minute: '2-digit'
135+
})}
136+
</span>
92137
) : (<></>)}
93138
</div>
94139
</div>
@@ -103,7 +148,7 @@ const ScheduledComponent: React.FC<ScheduledProps> = ({trip, isDeparture, isEven
103148
{showPlatform()}
104149
</div>
105150
</div>
106-
);
151+
</>);
107152
}
108153

109154
export default ScheduledComponent;

0 commit comments

Comments
 (0)