Skip to content

Commit

Permalink
Merge branch 'master' into nearby-view-support
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-heppner-ibigroup committed Sep 28, 2023
2 parents 016f1d4 + f3cfcb8 commit 97deeb8
Show file tree
Hide file tree
Showing 45 changed files with 3,523 additions and 2,531 deletions.
5,655 changes: 3,300 additions & 2,355 deletions __snapshots__/storybook.test.ts.snap

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/base-map/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentripplanner/base-map",
"version": "3.0.14",
"version": "3.0.15",
"description": "Base Map Component",
"author": "@binh-dam-ibigroup",
"homepage": "https://github.com/opentripplanner/otp-ui/#readme",
Expand All @@ -14,7 +14,7 @@
"react-map-gl": "^7.0.15"
},
"peerDependencies": {
"@opentripplanner/types": "^6.0.0",
"@opentripplanner/types": "^6.1.0",
"react": "^16.14.0",
"styled-components": "^5.3.0"
},
Expand Down
5 changes: 2 additions & 3 deletions packages/core-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentripplanner/core-utils",
"version": "11.0.3",
"version": "11.0.6",
"description": "Core functionality that is shared among numerous UI components",
"engines": {
"node": ">=13"
Expand All @@ -14,10 +14,9 @@
"dependencies": {
"@conveyal/lonlat": "^1.4.1",
"@mapbox/polyline": "^1.1.0",
"@opentripplanner/geocoder": "^1.4.1",
"@opentripplanner/geocoder": "^1.4.2",
"@styled-icons/foundation": "^10.34.0",
"@turf/along": "^6.0.1",
"bowser": "^2.7.0",
"chroma-js": "^2.4.2",
"date-fns": "^2.28.0",
"date-fns-tz": "^1.2.2",
Expand Down
10 changes: 0 additions & 10 deletions packages/core-utils/src/ui.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import bowser from "bowser";

export function isMobile(): boolean {
// TODO: consider using 3rd-party library?
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
);
}

/**
* Returns true if the user is using a [redacted] browser
*/
export function isIE(): boolean {
return bowser.parse(navigator.userAgent).browser === "Internet Explorer";
}

/**
* Enables scrolling for a specified selector, while disabling scrolling for all
* other targets. This is adapted from https://stackoverflow.com/a/41601290/915811
Expand Down
6 changes: 3 additions & 3 deletions packages/endpoints-overlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentripplanner/endpoints-overlay",
"version": "2.0.8",
"version": "2.0.9",
"description": "A map overlay to show the from and to locations of an itinerary",
"main": "lib/index.js",
"module": "esm/index.js",
Expand All @@ -21,15 +21,15 @@
"dependencies": {
"@opentripplanner/base-map": "^3.0.14",
"@opentripplanner/location-icon": "^1.4.1",
"@opentripplanner/core-utils": "^9.0.2",
"@opentripplanner/core-utils": "^11.0.2",
"flat": "^5.0.2",
"@styled-icons/fa-solid": "^10.34.0"
},
"devDependencies": {
"@types/flat": "^5.0.2"
},
"peerDependencies": {
"@opentripplanner/types": "^6.0.0",
"@opentripplanner/types": "^6.1.0",
"react": "^16.14.0",
"react-dom": "^16.8.6",
"react-intl": "^5.24.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/from-to-location-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentripplanner/from-to-location-picker",
"version": "2.1.8",
"version": "2.1.9",
"description": "Location Picker Component",
"author": "@binh-dam-ibigroup",
"homepage": "https://github.com/opentripplanner/otp-ui/#readme",
Expand All @@ -13,7 +13,7 @@
"flat": "^5.0.2"
},
"devDependencies": {
"@opentripplanner/types": "^6.0.0"
"@opentripplanner/types": "^6.1.0"
},
"peerDependencies": {
"react": "^16.14.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/icons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentripplanner/icons",
"version": "2.0.5",
"version": "2.0.6",
"description": "Icons for otp-ui",
"main": "lib/index.js",
"module": "esm/index.js",
Expand All @@ -10,7 +10,7 @@
"license": "MIT",
"private": false,
"dependencies": {
"@opentripplanner/core-utils": "^9.0.2",
"@opentripplanner/core-utils": "^11.0.2",
"prop-types": "^15.7.2"
},
"peerDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/icons/src/trimet-leg-icon.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from "react";

import { getLegRouteLongName } from "@opentripplanner/core-utils/lib/itinerary";
import LegIcon from "./leg-icon";
import TriMetModeIcon from "./trimet-mode-icon";
import BiketownIcon from "./companies/biketown-icon";

const TriMetLegIcon = ({ leg, ...props }) => {
// Custom TriMet icon logic.
if (leg.routeLongName && leg.routeLongName.startsWith("Portland Streetcar")) {
const routeLongName = getLegRouteLongName(leg);
if (routeLongName && routeLongName.startsWith("Portland Streetcar")) {
return <TriMetModeIcon mode="STREETCAR" {...props} />;
}
if (leg.rentedBike) {
Expand Down
8 changes: 4 additions & 4 deletions packages/itinerary-body/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentripplanner/itinerary-body",
"version": "5.0.6",
"version": "5.0.9",
"description": "A component for displaying an itinerary body of a trip planning result",
"main": "lib/index.js",
"module": "esm/index.js",
Expand All @@ -10,9 +10,9 @@
"license": "MIT",
"private": false,
"dependencies": {
"@opentripplanner/core-utils": "^9.0.2",
"@opentripplanner/core-utils": "^11.0.2",
"@opentripplanner/humanize-distance": "^1.2.0",
"@opentripplanner/icons": "^2.0.4",
"@opentripplanner/icons": "^2.0.5",
"@opentripplanner/location-icon": "^1.4.1",
"@styled-icons/fa-solid": "^10.34.0",
"@styled-icons/foundation": "^10.34.0",
Expand All @@ -24,7 +24,7 @@
"string-similarity": "^4.0.4"
},
"devDependencies": {
"@opentripplanner/types": "^7.0.0-alpha.6",
"@opentripplanner/types": "^6.1.0",
"@types/flat": "^5.0.2"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/itinerary-body/src/AccessLegBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class AccessLegBody extends Component<Props, State> {
mapillaryKey,
setLegDiagram,
showElevationProfile,
TransitLegSubheader,
showLegIcon
showLegIcon,
TransitLegSubheader
} = this.props;
const { expanded } = this.state;

Expand Down
2 changes: 2 additions & 0 deletions packages/itinerary-body/src/ItineraryBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const ItineraryBody = ({
mapillaryKey,
PlaceName,
RouteDescription,
RouteDescriptionFooter,
routingType = "ITINERARY",
setActiveLeg,
setLegDiagram,
Expand Down Expand Up @@ -76,6 +77,7 @@ const ItineraryBody = ({
mapillaryKey={mapillaryKey}
PlaceName={PlaceName}
RouteDescription={RouteDescription}
RouteDescriptionFooter={RouteDescriptionFooter}
routingType={routingType}
setActiveLeg={setActiveLeg}
setLegDiagram={setLegDiagram}
Expand Down
2 changes: 2 additions & 0 deletions packages/itinerary-body/src/ItineraryBody/place-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function PlaceRow({
mapillaryKey,
PlaceName,
RouteDescription,
RouteDescriptionFooter,
setActiveLeg,
setLegDiagram,
setViewedTrip,
Expand Down Expand Up @@ -141,6 +142,7 @@ export default function PlaceRow({
LegIcon={LegIcon}
legIndex={legIndex}
RouteDescription={RouteDescription}
RouteDescriptionFooter={RouteDescriptionFooter}
setActiveLeg={setActiveLeg}
setViewedTrip={setViewedTrip}
showAgencyInfo={showAgencyInfo}
Expand Down
4 changes: 4 additions & 0 deletions packages/itinerary-body/src/TransitLegBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Duration } from "../defaults";
import * as S from "../styled";
import {
RouteDescriptionProps,
RouteDescriptionFooterProps,
SetActiveLegFunction,
SetViewedTripFunction,
TransitLegSubheaderProps,
Expand All @@ -42,6 +43,7 @@ interface Props {
LegIcon: LegIconComponent;
legIndex: number;
RouteDescription: FunctionComponent<RouteDescriptionProps>;
RouteDescriptionFooter: FunctionComponent<RouteDescriptionFooterProps>;
setActiveLeg: SetActiveLegFunction;
setViewedTrip: SetViewedTripFunction;
showAgencyInfo: boolean;
Expand Down Expand Up @@ -135,6 +137,7 @@ class TransitLegBody extends Component<Props, State> {
legDestination,
LegIcon,
RouteDescription,
RouteDescriptionFooter,
setViewedTrip,
showAgencyInfo,
showViewTripButton,
Expand Down Expand Up @@ -228,6 +231,7 @@ class TransitLegBody extends Component<Props, State> {
</S.LegClickableButton>
</S.LegDescription>
</S.LegClickable>
{RouteDescriptionFooter && <RouteDescriptionFooter leg={leg} />}
<div
// Creates a group of leg details for screenreaders after the initial leg description.
aria-label={intl.formatMessage({
Expand Down
10 changes: 7 additions & 3 deletions packages/itinerary-body/src/defaults/line-column-content.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
getLegRouteLongName,
getLegRouteShortName
} from "@opentripplanner/core-utils/lib/itinerary";
import LocationIcon from "@opentripplanner/location-icon";
import React, { ReactElement } from "react";
import { IntlShape, useIntl } from "react-intl";
Expand Down Expand Up @@ -52,7 +56,7 @@ export default function LineColumnContent({
LegIcon,
toRouteAbbreviation
}: LineColumnContentProps): ReactElement {
const { mode, route, routeColor, routeLongName, transitLeg } = leg;
const { mode, routeColor, transitLeg } = leg;
const intl = useIntl();
const travelByMessage = intl.formatMessage(
{
Expand All @@ -65,7 +69,7 @@ export default function LineColumnContent({
}
);

const routeShortName = typeof route === "string" ? route : route?.shortName;
const routeShortName = getLegRouteShortName(leg);

return (
<S.LegLine>
Expand All @@ -78,7 +82,7 @@ export default function LineColumnContent({
parseInt(routeShortName, 10) || routeShortName
)}
color={routeColor}
name={routeLongName || ""}
name={getLegRouteLongName(leg) || ""}
/>
)}
{!interline && !isDestination && !transitLeg && (
Expand Down
3 changes: 2 additions & 1 deletion packages/itinerary-body/src/defaults/route-description.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getLegRouteShortName } from "@opentripplanner/core-utils/lib/itinerary";
import React, { ReactElement } from "react";

import * as S from "../styled";
Expand All @@ -8,7 +9,7 @@ import RouteLongName from "./route-long-name";
export default function RouteDescription({
leg
}: RouteDescriptionProps): ReactElement {
const { routeShortName } = leg;
const routeShortName = getLegRouteShortName(leg);
return (
<S.LegDescriptionForTransit>
{routeShortName && (
Expand Down
5 changes: 4 additions & 1 deletion packages/itinerary-body/src/defaults/route-long-name.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getLegRouteLongName } from "@opentripplanner/core-utils/lib/itinerary";
import { Leg } from "@opentripplanner/types";
import React, { HTMLAttributes, ReactElement } from "react";
import { FormattedMessage } from "react-intl";
Expand All @@ -24,7 +25,9 @@ export default function RouteLongName({
leg,
style
}: Props): ReactElement {
const { headsign, routeLongName } = leg;
const { headsign: otp1Headsign, trip } = leg;
const headsign = trip?.tripHeadsign || otp1Headsign;
const routeLongName = getLegRouteLongName(leg);
// Hide route long name if it contains similar information to the headsign
const hideRouteLongName =
compareTwoStrings(headsign || "", routeLongName || "") > 0.25 ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getLegRouteShortName } from "@opentripplanner/core-utils/lib/itinerary";
import React, { ReactElement } from "react";

import RouteLongName from "../defaults/route-long-name";
Expand All @@ -8,7 +9,7 @@ export default function RouteDescription({
leg,
LegIcon
}: RouteDescriptionProps): ReactElement {
const { routeShortName } = leg;
const routeShortName = getLegRouteShortName(leg);
return (
<S.LegDescriptionForTransit>
<S.LegIconAndRouteShortName>
Expand Down
16 changes: 13 additions & 3 deletions packages/itinerary-body/src/stories/OtpRrItineraryBody.story.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { convertGraphQLResponseToLegacy } from "@opentripplanner/core-utils/lib/itinerary";
import { FareProductSelector, Itinerary } from "@opentripplanner/types";
import React, { ReactElement } from "react";
import React, { FunctionComponent, ReactElement } from "react";

import ItineraryBody from "..";
import {
Expand Down Expand Up @@ -33,6 +34,13 @@ const walkTransitWalkTransitWalkA11yItinerary = require("../__mocks__/itinerarie
const otp2ScooterItinerary = require("../__mocks__/itineraries/otp2-scooter.json");
const flexItinerary = require("../__mocks__/itineraries/flex-itinerary.json");

function withLegacyLegs(itinerary) {
return {
...itinerary,
legs: itinerary.legs.map(convertGraphQLResponseToLegacy)
};
}

if (!isRunningJest()) {
// Generate same-day/next day alerts at a fixed time for the walk-transit-walk itinerary
// for illustration outside of the CI environment.
Expand Down Expand Up @@ -136,7 +144,9 @@ export const EScooterRentalTransitItinerary = (): ReactElement => (
);

export const TncTransitItinerary = (): ReactElement => (
<OtpRRItineraryBodyWrapper itinerary={tncTransitTncItinerary} />
<OtpRRItineraryBodyWrapper
itinerary={withLegacyLegs(tncTransitTncItinerary)}
/>
);

export const OTP2ScooterItinerary = (): ReactElement => (
Expand All @@ -153,7 +163,7 @@ export const IndividualLegFareComponents = (): ReactElement => (
mediumId: "orca:cash",
riderCategoryId: "orca:regular"
}}
itinerary={fareProductsItinerary}
itinerary={withLegacyLegs(fareProductsItinerary)}
/>
);

Expand Down
12 changes: 10 additions & 2 deletions packages/itinerary-body/src/stories/OtpUiItineraryBody.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { ReactElement } from "react";
import { Bomb } from "@styled-icons/fa-solid/Bomb";
import { Bolt } from "@styled-icons/fa-solid/Bolt";
import styled from "styled-components";
import RouteDescriptionFooterWithWaitTimes from "./footer-with-wait-times";

import ItineraryBody from "..";
import {
Expand Down Expand Up @@ -47,12 +48,16 @@ export const BikeOnlyItinerary = (): ReactElement => (
);

export const WalkTransitWalkItinerary = (): ReactElement => (
<ItineraryBodyDefaultsWrapper itinerary={walkTransitWalkItinerary} />
<ItineraryBodyDefaultsWrapper
itinerary={walkTransitWalkItinerary}
RouteDescriptionFooter={RouteDescriptionFooterWithWaitTimes}
/>
);

export const WalkTransitTransferWithA11yItinerary = (): ReactElement => (
<ItineraryBodyDefaultsWrapper
itinerary={walkTransitWalkTransitWalkA11yItinerary}
RouteDescriptionFooter={RouteDescriptionFooterWithWaitTimes}
/>
);

Expand Down Expand Up @@ -147,7 +152,10 @@ export const OTP2FlexItinerary = (): ReactElement => (
);

export const IndividualLegFareComponents = (): ReactElement => (
<ItineraryBodyDefaultsWrapper itinerary={fareProductsItinerary} />
<ItineraryBodyDefaultsWrapper
itinerary={fareProductsItinerary}
showRouteFares
/>
);

export const CustomAlertIconsItinerary = (): ReactElement => (
Expand Down
Loading

0 comments on commit 97deeb8

Please sign in to comment.