Skip to content

Commit

Permalink
Merge pull request #5121 from HSLdevcom/car-ferry-changes
Browse files Browse the repository at this point in the history
DT-5921 Add car ferry functionality
  • Loading branch information
vesameskanen authored Dec 19, 2024
2 parents 7095485 + c60bdaf commit 4f7f67b
Show file tree
Hide file tree
Showing 37 changed files with 981 additions and 285 deletions.
16 changes: 15 additions & 1 deletion app/component/RouteNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const LONG_ROUTE_NUMBER_LENGTH = 6;

function RouteNumber(props, context) {
const mode = props.mode.toLowerCase();
const { alertSeverityLevel, color, withBicycle, text } = props;
const { alertSeverityLevel, color, withBicycle, withCar, text } = props;
const isScooter = mode === TransportMode.Scooter.toLowerCase();
const textIsText = typeof text === 'string'; // can be also react node
const longText =
Expand Down Expand Up @@ -57,6 +57,12 @@ function RouteNumber(props, context) {
className="itinerary-icon_with-bicycle"
/>
)}
{withCar && (
<Icon
img="icon-icon_car-withoutBox"
className="itinerary-icon_with-car"
/>
)}
</React.Fragment>
);
}
Expand All @@ -83,6 +89,12 @@ function RouteNumber(props, context) {
className="itinerary-icon_with-bicycle"
/>
)}
{withCar && (
<Icon
img="icon-icon_car-withoutBox"
className="itinerary-icon_with-car"
/>
)}
</React.Fragment>
);
};
Expand Down Expand Up @@ -206,6 +218,7 @@ RouteNumber.propTypes = {
duration: PropTypes.number,
isTransitLeg: PropTypes.bool,
withBicycle: PropTypes.bool,
withCar: PropTypes.bool,
card: PropTypes.bool,
appendClass: PropTypes.string,
occupancyStatus: PropTypes.string,
Expand All @@ -228,6 +241,7 @@ RouteNumber.defaultProps = {
isTransitLeg: false,
renderModeIcons: false,
withBicycle: false,
withCar: false,
color: undefined,
duration: undefined,
occupancyStatus: undefined,
Expand Down
11 changes: 6 additions & 5 deletions app/component/RouteNumberContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const RouteNumberContainer = (
className,
route,
isCallAgency,
withBicycle,
occupancyStatus,
mode,
...props
Expand All @@ -25,8 +24,12 @@ const RouteNumberContainer = (
isCallAgency={isCallAgency}
color={route.color ? `#${route.color}` : null}
mode={mode !== undefined ? mode : route.mode}
text={getLegText(route, config, interliningWithRoute)}
withBicycle={withBicycle}
text={
config.disabledLegTextModes?.includes(route.mode) &&
className.includes('line')
? ''
: getLegText(route, config, interliningWithRoute)
}
occupancyStatus={occupancyStatus}
{...props}
/>
Expand All @@ -40,7 +43,6 @@ RouteNumberContainer.propTypes = {
vertical: PropTypes.bool,
className: PropTypes.string,
fadeLong: PropTypes.bool,
withBicycle: PropTypes.bool,
occupancyStatus: PropTypes.string,
mode: PropTypes.string,
};
Expand All @@ -52,7 +54,6 @@ RouteNumberContainer.defaultProps = {
vertical: false,
fadeLong: false,
className: '',
withBicycle: false,
occupancyStatus: undefined,
mode: undefined,
};
Expand Down
11 changes: 11 additions & 0 deletions app/component/itinerary/AlternativeItineraryBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function AlternativeItineraryBar(
bikePlan,
bikePublicPlan,
carPlan,
carPublicPlan,
parkRidePlan,
loading,
},
Expand Down Expand Up @@ -69,6 +70,14 @@ export default function AlternativeItineraryBar(
onClick={selectStreetMode}
/>
)}
{carPublicPlan?.edges?.length > 0 && (
<StreetModeSelectorButton
icon="icon-icon_car-withoutBox"
name={streetHash.carAndVehicle}
plan={carPublicPlan}
onClick={selectStreetMode}
/>
)}
{config.emphasizeOneWayJourney && (
<div style={{ alignSelf: 'center' }}>
<FormattedMessage
Expand All @@ -90,6 +99,7 @@ AlternativeItineraryBar.propTypes = {
bikePublicPlan: planShape,
parkRidePlan: planShape,
carPlan: planShape,
carPublicPlan: planShape,
weatherData: PropTypes.shape({
temperature: PropTypes.number,
windSpeed: PropTypes.number,
Expand All @@ -105,6 +115,7 @@ AlternativeItineraryBar.defaultProps = {
bikePublicPlan: undefined,
parkRidePlan: undefined,
carPlan: undefined,
carPublicPlan: undefined,
loading: undefined,
};

Expand Down
179 changes: 96 additions & 83 deletions app/component/itinerary/BicycleLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@ export default function BicycleLeg(
/>
);
} else if (bicycleWalkLeg) {
const modeClassNames = bicycleWalkLeg.to?.stop
? [modeClassName, bicycleWalkLeg.mode.toLowerCase()]
: [bicycleWalkLeg.mode.toLowerCase(), modeClassName];
circleLine = (
<ItineraryCircleLineLong index={index} modeClassNames={modeClassNames} />
<ItineraryCircleLineLong
index={index}
modeClassName={modeClassName}
boardingLeg={bicycleWalkLeg}
/>
);
} else if (mode === 'BICYCLE') {
circleLine = (
Expand Down Expand Up @@ -315,42 +316,46 @@ export default function BicycleLeg(
</div>
)}
{bicycleWalkLeg?.from.stop && (
<div className={cx('itinerary-leg-action', 'bicycle')}>
<div className="itinerary-leg-action-content">
{bicycleWalkLeg.distance === -1 ? (
<FormattedMessage
id="bicycle-walk-from-transit-no-duration"
values={{
transportMode: (
<FormattedMessage
id={`from-${bicycleWalkLeg.from.stop.vehicleMode.toLowerCase()}`}
/>
),
}}
/>
) : (
<FormattedMessage
id="bicycle-walk-from-transit"
values={{
transportMode: (
<FormattedMessage
id={`from-${bicycleWalkLeg.from.stop.vehicleMode.toLowerCase()}`}
/>
),
duration: durationToString(bicycleWalkLeg.duration * 1000),
distance: displayDistance(
parseInt(bicycleWalkLeg.distance, 10),
config,
intl.formatNumber,
),
}}
/>
)}
<ItineraryMapAction
target={leg.from.name || ''}
focusAction={focusAction}
<div
className={cx(
'itinerary-leg-action',
'bicycle',
'itinerary-leg-action-content',
)}
>
{bicycleWalkLeg.distance === -1 ? (
<FormattedMessage
id="bicycle-walk-from-transit-no-duration"
values={{
transportMode: (
<FormattedMessage
id={`from-${bicycleWalkLeg.from.stop.vehicleMode.toLowerCase()}`}
/>
),
}}
/>
</div>
) : (
<FormattedMessage
id="bicycle-walk-from-transit"
values={{
transportMode: (
<FormattedMessage
id={`from-${bicycleWalkLeg.from.stop.vehicleMode.toLowerCase()}`}
/>
),
duration: durationToString(bicycleWalkLeg.duration * 1000),
distance: displayDistance(
parseInt(bicycleWalkLeg.distance, 10),
config,
intl.formatNumber,
),
}}
/>
)}
<ItineraryMapAction
target={leg.from.name || ''}
focusAction={focusAction}
/>
</div>
)}
{isScooter && !scooterSettingsOn && (
Expand Down Expand Up @@ -401,53 +406,61 @@ export default function BicycleLeg(
</div>
</div>
)}
<div className={cx('itinerary-leg-action', 'bike')}>
<div className="itinerary-leg-action-content">
{stopsDescription}
<ItineraryMapAction
target=""
ariaLabelId="itinerary-summary-row.clickable-area-description"
focusAction={focusToLeg}
/>
</div>
<div
className={cx(
'itinerary-leg-action',
'bike',
'itinerary-leg-action-content',
)}
>
{stopsDescription}
<ItineraryMapAction
target=""
ariaLabelId="itinerary-summary-row.clickable-area-description"
focusAction={focusToLeg}
/>
</div>
{bicycleWalkLeg && bicycleWalkLeg?.to.stop && (
<div className={cx('itinerary-leg-action', 'bicycle')}>
<div className="itinerary-leg-action-content">
{bicycleWalkLeg.distance === -1 ? (
<FormattedMessage
id="bicycle-walk-to-transit-no-duration"
values={{
transportMode: (
<FormattedMessage
id={`to-${bicycleWalkLeg.to.stop?.vehicleMode.toLowerCase()}`}
/>
),
}}
/>
) : (
<FormattedMessage
id="bicycle-walk-to-transit"
values={{
transportMode: (
<FormattedMessage
id={`to-${bicycleWalkLeg.to.stop.vehicleMode.toLowerCase()}`}
/>
),
duration: durationToString(bicycleWalkLeg.duration * 1000),
distance: displayDistance(
parseInt(bicycleWalkLeg.distance, 10),
config,
intl.formatNumber,
),
}}
/>
)}
<ItineraryMapAction
target={leg.from.name || ''}
focusAction={focusAction}
<div
className={cx(
'itinerary-leg-action',
'bicycle',
'itinerary-leg-action-content',
)}
>
{bicycleWalkLeg.distance === -1 ? (
<FormattedMessage
id="bicycle-walk-to-transit-no-duration"
values={{
transportMode: (
<FormattedMessage
id={`to-${bicycleWalkLeg.to.stop?.vehicleMode.toLowerCase()}`}
/>
),
}}
/>
</div>
) : (
<FormattedMessage
id="bicycle-walk-to-transit"
values={{
transportMode: (
<FormattedMessage
id={`to-${bicycleWalkLeg.to.stop.vehicleMode.toLowerCase()}`}
/>
),
duration: durationToString(bicycleWalkLeg.duration * 1000),
distance: displayDistance(
parseInt(bicycleWalkLeg.distance, 10),
config,
intl.formatNumber,
),
}}
/>
)}
<ItineraryMapAction
target={leg.from.name || ''}
focusAction={focusAction}
/>
</div>
)}
{isScooter && (
Expand Down
28 changes: 16 additions & 12 deletions app/component/itinerary/BikeParkLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,22 @@ const BikeParkLeg = (
focusAction={focusAction}
/>
</div>
<div className={cx('itinerary-leg-action', 'bike')}>
<div className="itinerary-leg-action-content">
<FormattedMessage
id="walk-distance-duration"
values={{ distance, duration }}
defaultMessage="Walk {distance} ({duration})"
/>
<ItineraryMapAction
target={leg.from.name || ''}
focusAction={focusAction}
/>
</div>
<div
className={cx(
'itinerary-leg-action',
'bike',
'itinerary-leg-action-content',
)}
>
<FormattedMessage
id="walk-distance-duration"
values={{ distance, duration }}
defaultMessage="Walk {distance} ({duration})"
/>
<ItineraryMapAction
target={leg.from.name || ''}
focusAction={focusAction}
/>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 4f7f67b

Please sign in to comment.