Skip to content

Commit b971d84

Browse files
authored
Merge pull request #5224 from HSLdevcom/DT-6582
DT-6582: Wait in vehicle card
2 parents 71cefb5 + 964b159 commit b971d84

File tree

10 files changed

+145
-36
lines changed

10 files changed

+145
-36
lines changed

app/component/itinerary/PlanConnection.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const planConnection = graphql`
117117
}
118118
route {
119119
shortName
120+
longName
120121
color
121122
gtfsId
122123
type
@@ -128,6 +129,7 @@ const planConnection = graphql`
128129
trip {
129130
gtfsId
130131
directionId
132+
tripHeadsign
131133
stoptimesForDate {
132134
stop {
133135
gtfsId

app/component/itinerary/navigator/NaviCard.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const iconMap = {
2323
'BUS-EXPRESS': 'icon-icon_bus-express',
2424
'BUS-LOCAL': 'icon-icon_bus-local',
2525
SPEEDTRAM: 'icon-icon_speedtram',
26+
WAIT_IN_VEHICLE: 'icon-icon_wait',
2627
};
2728

2829
export default function NaviCard(
@@ -51,7 +52,11 @@ export default function NaviCard(
5152
iconName = iconMap[m.toUpperCase()];
5253

5354
instructions = `navileg-in-transit`;
54-
} else if (legType !== LEGTYPE.WAIT && isRental(leg, nextLeg)) {
55+
} else if (
56+
legType !== LEGTYPE.WAIT &&
57+
legType !== LEGTYPE.WAIT_IN_VEHICLE &&
58+
isRental(leg, nextLeg)
59+
) {
5560
if (leg.mode === 'WALK' && nextLeg?.mode === 'SCOOTER') {
5661
instructions = `navileg-rent-scooter`;
5762
} else {
@@ -63,6 +68,8 @@ export default function NaviCard(
6368
iconName = iconMap.WALK;
6469
} else if (legType === LEGTYPE.WAIT) {
6570
iconName = iconMap.WAIT;
71+
} else if (legType === LEGTYPE.WAIT_IN_VEHICLE) {
72+
iconName = iconMap.WAIT_IN_VEHICLE;
6673
}
6774

6875
mainCardContent = (
@@ -92,12 +99,7 @@ export default function NaviCard(
9299
<div className="main-card">
93100
<div className="content">{mainCardContent}</div>
94101
{cardExpanded && (
95-
<NaviCardExtension
96-
legType={legType}
97-
leg={leg}
98-
nextLeg={nextLeg}
99-
time={time}
100-
/>
102+
<NaviCardExtension legType={legType} leg={leg} nextLeg={nextLeg} />
101103
)}
102104
</div>
103105
);

app/component/itinerary/navigator/NaviCardContainer.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ function addMessages(incominMessages, newMessages) {
2727
});
2828
}
2929

30-
const getLegType = (leg, firstLeg, time, countAtLegEnd) => {
30+
const getLegType = (
31+
leg,
32+
firstLeg,
33+
time,
34+
countAtLegEnd,
35+
interlineWithPreviousLeg,
36+
) => {
3137
let legType;
3238
if (time < legTime(firstLeg.start)) {
3339
legType = LEGTYPE.PENDING;
@@ -42,7 +48,7 @@ const getLegType = (leg, firstLeg, time, countAtLegEnd) => {
4248
legType = LEGTYPE.TRANSIT;
4349
}
4450
} else {
45-
legType = LEGTYPE.WAIT;
51+
legType = interlineWithPreviousLeg ? LEGTYPE.WAIT_IN_VEHICLE : LEGTYPE.WAIT;
4652
}
4753
return legType;
4854
};
@@ -230,7 +236,13 @@ function NaviCardContainer(
230236

231237
// LegChange fires animation, we need to keep the old data until card goes out of the view.
232238
const l = legChanging ? previousLeg : currentLeg;
233-
const legType = getLegType(l, firstLeg, time, legEndRef.current);
239+
const legType = getLegType(
240+
l,
241+
firstLeg,
242+
time,
243+
legEndRef.current,
244+
nextLeg?.interlineWithPreviousLeg,
245+
);
234246

235247
const containerTopPosition =
236248
mapLayerRef.current.getBoundingClientRect().top + TOPBAR_PADDING;

app/component/itinerary/navigator/NaviCardExtension.js

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import { FormattedMessage } from 'react-intl';
55
import Icon from '../../Icon';
66
import StopCode from '../../StopCode';
77
import PlatformNumber from '../../PlatformNumber';
8-
import { getZoneLabel, legTime } from '../../../util/legUtils';
8+
import {
9+
getZoneLabel,
10+
getHeadsignFromRouteLongName,
11+
} from '../../../util/legUtils';
912
import ZoneIcon from '../../ZoneIcon';
1013
import { legShape, configShape } from '../../../util/shapes';
1114
import { getDestinationProperties, LEGTYPE } from './NaviUtils';
1215
import { getRouteMode } from '../../../util/modeUtils';
1316

1417
import RouteNumberContainer from '../../RouteNumberContainer';
1518

16-
const NaviCardExtension = ({ legType, leg, nextLeg, time }, { config }) => {
19+
const NaviCardExtension = ({ legType, leg, nextLeg }, { config }) => {
1720
const { stop, name, rentalVehicle, vehicleParking, vehicleRentalStation } =
1821
leg ? leg.to : nextLeg.from;
1922
const { code, platformCode, zoneId, vehicleMode } = stop || {};
@@ -35,34 +38,32 @@ const NaviCardExtension = ({ legType, leg, nextLeg, time }, { config }) => {
3538
}
3639

3740
if (legType === LEGTYPE.TRANSIT) {
38-
const { intermediatePlaces, headsign, trip, realtimeState, route } = leg;
41+
const { intermediatePlaces, headsign, trip, route } = leg;
3942
const hs = headsign || trip.tripHeadsign;
40-
const idx = intermediatePlaces.findIndex(p => legTime(p.arrival) > time);
41-
const count = idx > -1 ? intermediatePlaces.length - idx : 0;
42-
const stopCount = (
43-
<span className={cx('bold', { realtime: realtimeState === 'UPDATED' })}>
44-
{count}
45-
</span>
46-
);
43+
const stopCount = <span className="bold">{intermediatePlaces.length}</span>;
4744
const translationId =
48-
count === 1 ? 'navileg-one-stop-remaining' : 'navileg-stops-remaining';
45+
intermediatePlaces.length === 1
46+
? 'navileg-one-intermediate-stop'
47+
: 'navileg-intermediate-stops';
4948
const mode = getRouteMode(route, config);
50-
49+
const iconColor =
50+
config.colors.iconColors[`mode-${mode}`] || leg.route.color;
5151
return (
5252
<div className="extension">
53-
<div className="extension-divider" />
5453
<div className="extension-routenumber">
5554
<RouteNumberContainer
5655
className={cx('line', mode)}
57-
route={leg.route}
56+
route={route}
5857
mode={mode}
5958
isTransitLeg
6059
vertical
6160
withBar
6261
/>
6362
<div className="headsign">{hs}</div>
6463
</div>
64+
<div className="extension-divider" />
6565
<div className="stop-count">
66+
<Icon img="navi-intermediatestops" color={iconColor} />
6667
<FormattedMessage
6768
id={translationId}
6869
values={{ stopCount }}
@@ -72,9 +73,8 @@ const NaviCardExtension = ({ legType, leg, nextLeg, time }, { config }) => {
7273
</div>
7374
);
7475
}
75-
return (
76-
<div className="extension">
77-
<div className="extension-divider" />
76+
const stopInformation = () => {
77+
return (
7878
<div className="extension-walk">
7979
<Icon img="navi-expand" className="icon-expand" />
8080
<Icon
@@ -104,6 +104,35 @@ const NaviCardExtension = ({ legType, leg, nextLeg, time }, { config }) => {
104104
</div>
105105
</div>
106106
</div>
107+
);
108+
};
109+
110+
if (legType === LEGTYPE.WAIT_IN_VEHICLE) {
111+
const { route, trip } = nextLeg;
112+
return (
113+
<div className="extension">
114+
<div className="extension-divider" />
115+
<div className="wait-in-vehicle">
116+
<FormattedMessage
117+
id="navigation-interline-wait"
118+
values={{
119+
line: <span className="bold">{route.shortName}</span>,
120+
destination: (
121+
<span className="bold">
122+
{trip.tripHeadsign || getHeadsignFromRouteLongName(route)}
123+
</span>
124+
),
125+
}}
126+
/>
127+
</div>
128+
{stopInformation()}
129+
</div>
130+
);
131+
}
132+
return (
133+
<div className="extension">
134+
<div className="extension-divider" />
135+
{stopInformation()}
107136
</div>
108137
);
109138
};
@@ -112,7 +141,6 @@ NaviCardExtension.propTypes = {
112141
leg: legShape,
113142
nextLeg: legShape,
114143
legType: PropTypes.string,
115-
time: PropTypes.number.isRequired,
116144
};
117145

118146
NaviCardExtension.defaultProps = {

app/component/itinerary/navigator/NaviInstructions.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,31 @@ export default function NaviInstructions(
9898
);
9999
}
100100

101+
if (legType === LEGTYPE.WAIT_IN_VEHICLE) {
102+
const totalWait = legTime(nextLeg.start) - time;
103+
return (
104+
<>
105+
<div className="notification-header">
106+
<FormattedMessage
107+
id="wait-in-vehicle"
108+
defaultMessage="Wait in the vehicle"
109+
/>
110+
</div>
111+
<div className="wait-leg">
112+
<FormattedMessage
113+
id="navigation-interline-resume"
114+
values={{
115+
duration: withRealTime(
116+
nextLeg.realtimeState === 'UPDATED',
117+
durationToString(totalWait),
118+
),
119+
}}
120+
/>
121+
</div>
122+
</>
123+
);
124+
}
125+
101126
if (legType === LEGTYPE.TRANSIT) {
102127
const rt = leg.realtimeState === 'UPDATED';
103128
const t = legTime(leg.end);
@@ -117,7 +142,9 @@ export default function NaviInstructions(
117142
duration: withRealTime(rt, remainingDuration),
118143
legTime: withRealTime(rt, legTimeStr(leg.end)),
119144
};
120-
145+
const translationId = nextLeg?.interlineWithPreviousLeg
146+
? 'navileg-in-transit-interline'
147+
: 'navileg-leave-at';
121148
return (
122149
<>
123150
<div className="notification-header">
@@ -129,7 +156,7 @@ export default function NaviInstructions(
129156
</div>
130157
<div className="vehicle-leg">
131158
<FormattedMessage
132-
id="navileg-leave-at"
159+
id={translationId}
133160
defaultMessage="leave from the vehicle at stop {stop} in {duration} minutes at {legTime}"
134161
values={values}
135162
/>

app/component/itinerary/navigator/NaviUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,4 +644,5 @@ export const LEGTYPE = {
644644
TRANSIT: 'TRANSIT',
645645
PENDING: 'PENDING',
646646
END: 'END',
647+
WAIT_IN_VEHICLE: 'WAIT_IN_VEHICLE',
647648
};

app/component/itinerary/navigator/navigator.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ $fixed-width-padding: 16px;
189189
flex-direction: column;
190190
max-height: 250px;
191191
margin-bottom: var(--space-s);
192+
margin-top: var(--space-m);
192193

193194
.extension-divider {
194195
height: 1px;
@@ -202,6 +203,13 @@ $fixed-width-padding: 16px;
202203
.stop-count {
203204
display: flex;
204205
margin-left: 35px;
206+
207+
.icon {
208+
height: 16px;
209+
width: 16px;
210+
margin-right: var(--space-xxs);
211+
margin-top: 2px;
212+
}
205213
}
206214

207215
.extension-routenumber {
@@ -251,6 +259,13 @@ $fixed-width-padding: 16px;
251259
margin-top: var(--space-xs);
252260
}
253261

262+
.wait-in-vehicle {
263+
display: flex;
264+
align-items: flex-start;
265+
text-align: start;
266+
margin-left: var(--space-xl);
267+
}
268+
254269
.icon-expand {
255270
margin-top: 5px;
256271
width: var(--space-m);

0 commit comments

Comments
 (0)