Skip to content

Commit

Permalink
Merge pull request #779 from ibi-group/transfer-leg-support
Browse files Browse the repository at this point in the history
Transfer leg support
  • Loading branch information
miles-grant-ibigroup authored Oct 3, 2024
2 parents bb30125 + a8594cf commit 17eb758
Show file tree
Hide file tree
Showing 11 changed files with 4,511 additions and 924 deletions.
33 changes: 18 additions & 15 deletions .storybook/react-intl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,25 @@ const messages = {};

// Populate messages if not running snapshots.
// (Message printouts would be unnecessary replicated in snapshots without that check.)
packages.forEach((pkg) => {
locales.forEach((locale) => {
// Chinese-simplified is assigned a special file name by Weblate.
const localeFile = locale === "zh" ? "zh_Hans" : locale;
try {
messages[locale] = {
...messages[locale],
...flatten(require(`../packages/${pkg}/i18n/${localeFile}.yml`).default)
};
} catch (e) {
// There is no yml files for the "unknown" locale,
// so it should fail, and we won't display an error message in that case.
if (locale !== "unknown") console.error(e);
}
if (typeof window !== "undefined") {

packages.forEach((pkg) => {
locales.forEach((locale) => {
// Chinese-simplified is assigned a special file name by Weblate.
const localeFile = locale === "zh" ? "zh_Hans" : locale;
try {
messages[locale] = {
...messages[locale],
...flatten(require(`../packages/${pkg}/i18n/${localeFile}.yml`).default)
};
} catch (e) {
// There is no yml files for the "unknown" locale,
// so it should fail, and we won't display an error message in that case.
if (locale !== "unknown") console.error(e);
}
});
});
});
}

// TODO: place any applicable (date, time, etc) format parameters here.
const formats = {};
Expand Down
1 change: 1 addition & 0 deletions packages/itinerary-body/i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ otpUi:
carHail: Ride
escooter: Ride
walk: Walk
transfer: Transfer{duration, select, undefined {} other {, wait {duration}}}
unnamedPath: Unnamed Path
unnamedRoad: Unnamed Road
vehicleTitle: "{company} {vehicleType}"
Expand Down
3 changes: 3 additions & 0 deletions packages/itinerary-body/i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ otpUi:
carHail: Course en voiture
escooter: Trottinette
walk: Marche
transfer: >-
Correspondance{duration, select, undefined {} other {, attente
{duration}}}
unnamedPath: Chemin sans nom
unnamedRoad: Route sans nom
vehicleTitle: "{vehicleType} {company}"
Expand Down
112 changes: 58 additions & 54 deletions packages/itinerary-body/src/AccessLegBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,63 +125,67 @@ class AccessLegBody extends Component<Props, State> {
onSummaryClick={this.onSummaryClick}
showLegIcon={showLegIcon}
/>
<S.LegDetails>
{hideDrivingDirections ? (
<S.StepsHeaderAndMapLink>
<S.StepsHeaderSpan>
<Duration seconds={leg.duration} />
</S.StepsHeaderSpan>
{mapillary}
</S.StepsHeaderAndMapLink>
) : (
<>
{leg.distance !== 0 && (
<S.LegDetails>
{hideDrivingDirections ? (
<S.StepsHeaderAndMapLink>
<S.StepsHeaderButton
aria-expanded={expanded}
onClick={this.onStepsHeaderClick}
>
<Duration
seconds={leg.duration}
showApproximatePrefix={
showApproximateTravelTime && !isTransit(leg.mode)
}
/>
{leg.steps && leg.steps.length > 0 && (
<S.CaretToggle expanded={expanded} />
)}

<S.InvisibleAdditionalDetails>
<FormattedMessage
defaultMessage={
defaultMessages["otpUi.TransitLegBody.expandDetails"]
}
description="Screen reader text added to expand steps"
id="otpUi.TransitLegBody.expandDetails"
/>
</S.InvisibleAdditionalDetails>
</S.StepsHeaderButton>
<S.StepsHeaderSpan>
<Duration seconds={leg.duration} />
</S.StepsHeaderSpan>
{mapillary}
</S.StepsHeaderAndMapLink>
<AnimateHeight
duration={500}
height={expanded ? "auto" : 0}
style={{ gridColumn: "1 / span 2" }}
>
<AccessLegSteps
mapillaryCallback={mapillaryCallback}
mapillaryKey={mapillaryKey}
steps={leg.steps}
/>
</AnimateHeight>
</>
)}
<LegDiagramPreview
diagramVisible={diagramVisible}
leg={leg}
setLegDiagram={setLegDiagram}
showElevationProfile={showElevationProfile}
/>
</S.LegDetails>
) : (
<>
<S.StepsHeaderAndMapLink>
<S.StepsHeaderButton
aria-expanded={expanded}
onClick={this.onStepsHeaderClick}
>
<Duration
seconds={leg.duration}
showApproximatePrefix={
showApproximateTravelTime && !isTransit(leg.mode)
}
/>
{leg.steps && leg.steps.length > 0 && (
<S.CaretToggle expanded={expanded} />
)}

<S.InvisibleAdditionalDetails>
<FormattedMessage
defaultMessage={
defaultMessages[
"otpUi.TransitLegBody.expandDetails"
]
}
description="Screen reader text added to expand steps"
id="otpUi.TransitLegBody.expandDetails"
/>
</S.InvisibleAdditionalDetails>
</S.StepsHeaderButton>
{mapillary}
</S.StepsHeaderAndMapLink>
<AnimateHeight
duration={500}
height={expanded ? "auto" : 0}
style={{ gridColumn: "1 / span 2" }}
>
<AccessLegSteps
mapillaryCallback={mapillaryCallback}
mapillaryKey={mapillaryKey}
steps={leg.steps}
/>
</AnimateHeight>
</>
)}
<LegDiagramPreview
diagramVisible={diagramVisible}
leg={leg}
setLegDiagram={setLegDiagram}
showElevationProfile={showElevationProfile}
/>
</S.LegDetails>
)}
</S.LegBody>
</>
);
Expand Down
Loading

0 comments on commit 17eb758

Please sign in to comment.