@opentripplanner/trip-details 9.2.1 → 9.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/departure-date.js +18 -8
- package/esm/components/departure-date.js.map +1 -1
- package/esm/components/time-active.js +2 -2
- package/esm/components/time-active.js.map +1 -1
- package/esm/components/transit-time.js +36 -0
- package/esm/components/transit-time.js.map +1 -0
- package/esm/index.js +15 -4
- package/esm/index.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/i18n/en-US.yml +6 -0
- package/i18n/fr.yml +6 -0
- package/lib/components/departure-date.d.ts +3 -2
- package/lib/components/departure-date.d.ts.map +1 -1
- package/lib/components/departure-date.js +18 -8
- package/lib/components/departure-date.js.map +1 -1
- package/lib/components/time-active.d.ts +3 -3
- package/lib/components/time-active.d.ts.map +1 -1
- package/lib/components/time-active.js +2 -2
- package/lib/components/time-active.js.map +1 -1
- package/lib/components/transit-time.d.ts +7 -0
- package/lib/components/transit-time.d.ts.map +1 -0
- package/lib/components/transit-time.js +40 -0
- package/lib/components/transit-time.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -4
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +10 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +3 -3
- package/src/TripDetails.story.tsx +28 -5
- package/src/__snapshots__/TripDetails.story.tsx.snap +313 -0
- package/src/components/departure-date.tsx +24 -13
- package/src/components/time-active.tsx +4 -4
- package/src/components/transit-time.tsx +40 -0
- package/src/index.tsx +14 -3
- package/src/types.ts +15 -5
- package/tsconfig.tsbuildinfo +1 -1
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.default = void 0;
|
|
|
16
16
|
var _react = _interopRequireDefault(require("react"));
|
|
17
17
|
var _reactIntl = require("react-intl");
|
|
18
18
|
var _flat = require("flat");
|
|
19
|
+
var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
|
|
19
20
|
var S = _interopRequireWildcard(require("./styled"));
|
|
20
21
|
exports.Styled = S;
|
|
21
22
|
var _flexBookingInfo = _interopRequireDefault(require("./components/flex-booking-info"));
|
|
@@ -24,6 +25,7 @@ var _emissions = _interopRequireDefault(require("./components/emissions"));
|
|
|
24
25
|
var _fares = _interopRequireDefault(require("./components/fares"));
|
|
25
26
|
var _timeActive = _interopRequireWildcard(require("./components/time-active"));
|
|
26
27
|
var _departureDate = _interopRequireDefault(require("./components/departure-date"));
|
|
28
|
+
var _transitTime = _interopRequireDefault(require("./components/transit-time"));
|
|
27
29
|
var _enUS = _interopRequireDefault(require("../i18n/en-US.yml"));
|
|
28
30
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
29
31
|
// Load the default messages.
|
|
@@ -49,8 +51,12 @@ function TripDetails({
|
|
|
49
51
|
itinerary,
|
|
50
52
|
mediumRiderWhitelist,
|
|
51
53
|
showApproximateMinutesActive,
|
|
52
|
-
|
|
54
|
+
showTransitTime = false,
|
|
55
|
+
TimeActiveDetails = _timeActive.DefaultTimeActiveDetails,
|
|
56
|
+
transitOnly = false
|
|
53
57
|
}) {
|
|
58
|
+
var _timing$legs$;
|
|
59
|
+
const timing = _coreUtils.default.itinerary.getItinerarySummaryTiming(itinerary, transitOnly);
|
|
54
60
|
return /*#__PURE__*/_react.default.createElement(S.TripDetails, {
|
|
55
61
|
className: cn(className, "trip-details")
|
|
56
62
|
}, /*#__PURE__*/_react.default.createElement(S.TripDetailsHeader, {
|
|
@@ -60,15 +66,18 @@ function TripDetails({
|
|
|
60
66
|
description: "Title (heading) text of the component.",
|
|
61
67
|
id: "otpUi.TripDetails.title"
|
|
62
68
|
})), /*#__PURE__*/_react.default.createElement(S.TripDetailsBody, null, /*#__PURE__*/_react.default.createElement(_departureDate.default, {
|
|
63
|
-
|
|
64
|
-
DepartureDetails: DepartureDetails
|
|
69
|
+
startTime: timing.startTime,
|
|
70
|
+
DepartureDetails: DepartureDetails,
|
|
71
|
+
isBoarding: transitOnly && ((_timing$legs$ = timing.legs[0]) === null || _timing$legs$ === void 0 ? void 0 : _timing$legs$.transitLeg) === true
|
|
72
|
+
}), showTransitTime && /*#__PURE__*/_react.default.createElement(_transitTime.default, {
|
|
73
|
+
legs: itinerary.legs
|
|
65
74
|
}), /*#__PURE__*/_react.default.createElement(_fares.default, {
|
|
66
75
|
itinerary: itinerary,
|
|
67
76
|
FareDetails: FareDetails,
|
|
68
77
|
defaultFareType: defaultFareType,
|
|
69
78
|
mediumRiderWhitelist: mediumRiderWhitelist
|
|
70
79
|
}), /*#__PURE__*/_react.default.createElement(_timeActive.default, {
|
|
71
|
-
|
|
80
|
+
legs: timing.legs,
|
|
72
81
|
TimeActiveDetails: TimeActiveDetails,
|
|
73
82
|
showApproximateMinutesActive: showApproximateMinutesActive
|
|
74
83
|
}), /*#__PURE__*/_react.default.createElement(_flexBookingInfo.default, {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_reactIntl","_flat","S","_interopRequireWildcard","exports","Styled","_flexBookingInfo","_faresV2Table","_emissions","_fares","_timeActive","_departureDate","_enUS","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","defaultMessages","flatten","defaultEnglishMessages","cn","className","arg1","TripDetails","co2Config","defaultFareType","DepartureDetails","FareDetails","itinerary","mediumRiderWhitelist","showApproximateMinutesActive","TimeActiveDetails","DefaultTimeActiveDetails","createElement","TripDetailsHeader","id","FormattedMessage","defaultMessage","description","TripDetailsBody","_default"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { ReactElement } from \"react\";\nimport { FormattedMessage } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport { TripDetailsProps } from \"./types\";\nimport FlexBookingInfo from \"./components/flex-booking-info\";\nimport FaresV2Table from \"./components/fares-v2-table\";\nimport Emissions from \"./components/emissions\";\nimport Fares from \"./components/fares\";\nimport TimeActive, { DefaultTimeActiveDetails } from \"./components/time-active\";\nimport DepartureDate from \"./components/departure-date\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nconst defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);\n\nfunction cn(className: string, arg1: string): string {\n return className ? `${className} ${arg1}` : arg1;\n}\n\n/**\n * Renders trip details such as departure instructions, fare amount, and minutes active.\n */\nexport function TripDetails({\n className = \"\",\n co2Config,\n defaultFareType,\n DepartureDetails = null,\n FareDetails = null,\n itinerary,\n mediumRiderWhitelist,\n showApproximateMinutesActive,\n TimeActiveDetails = DefaultTimeActiveDetails\n}: TripDetailsProps): ReactElement {\n return (\n <S.TripDetails className={cn(className, \"trip-details\")}>\n {/* this can be presentation as S.TripDetails is already labeled by this */}\n <S.TripDetailsHeader id=\"trip-details-header\">\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.title\"]}\n description=\"Title (heading) text of the component.\"\n id=\"otpUi.TripDetails.title\"\n />\n </S.TripDetailsHeader>\n\n <S.TripDetailsBody>\n <DepartureDate\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_reactIntl","_flat","_coreUtils","S","_interopRequireWildcard","exports","Styled","_flexBookingInfo","_faresV2Table","_emissions","_fares","_timeActive","_departureDate","_transitTime","_enUS","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","defaultMessages","flatten","defaultEnglishMessages","cn","className","arg1","TripDetails","co2Config","defaultFareType","DepartureDetails","FareDetails","itinerary","mediumRiderWhitelist","showApproximateMinutesActive","showTransitTime","TimeActiveDetails","DefaultTimeActiveDetails","transitOnly","_timing$legs$","timing","coreUtils","getItinerarySummaryTiming","createElement","TripDetailsHeader","id","FormattedMessage","defaultMessage","description","TripDetailsBody","startTime","isBoarding","legs","transitLeg","_default"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { ReactElement } from \"react\";\nimport { FormattedMessage } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport * as S from \"./styled\";\nimport { TripDetailsProps } from \"./types\";\nimport FlexBookingInfo from \"./components/flex-booking-info\";\nimport FaresV2Table from \"./components/fares-v2-table\";\nimport Emissions from \"./components/emissions\";\nimport Fares from \"./components/fares\";\nimport TimeActive, { DefaultTimeActiveDetails } from \"./components/time-active\";\nimport DepartureDate from \"./components/departure-date\";\nimport TransitTime from \"./components/transit-time\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nconst defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);\n\nfunction cn(className: string, arg1: string): string {\n return className ? `${className} ${arg1}` : arg1;\n}\n\n/**\n * Renders trip details such as departure instructions, fare amount, and minutes active.\n */\nexport function TripDetails({\n className = \"\",\n co2Config,\n defaultFareType,\n DepartureDetails = null,\n FareDetails = null,\n itinerary,\n mediumRiderWhitelist,\n showApproximateMinutesActive,\n showTransitTime = false,\n TimeActiveDetails = DefaultTimeActiveDetails,\n transitOnly = false\n}: TripDetailsProps): ReactElement {\n const timing = coreUtils.itinerary.getItinerarySummaryTiming(\n itinerary,\n transitOnly\n );\n\n return (\n <S.TripDetails className={cn(className, \"trip-details\")}>\n {/* this can be presentation as S.TripDetails is already labeled by this */}\n <S.TripDetailsHeader id=\"trip-details-header\">\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.title\"]}\n description=\"Title (heading) text of the component.\"\n id=\"otpUi.TripDetails.title\"\n />\n </S.TripDetailsHeader>\n\n <S.TripDetailsBody>\n <DepartureDate\n startTime={timing.startTime}\n DepartureDetails={DepartureDetails}\n isBoarding={transitOnly && timing.legs[0]?.transitLeg === true}\n />\n {showTransitTime && <TransitTime legs={itinerary.legs} />}\n <Fares\n itinerary={itinerary}\n FareDetails={FareDetails}\n defaultFareType={defaultFareType}\n mediumRiderWhitelist={mediumRiderWhitelist}\n />\n <TimeActive\n legs={timing.legs}\n TimeActiveDetails={TimeActiveDetails}\n showApproximateMinutesActive={showApproximateMinutesActive}\n />\n <FlexBookingInfo itinerary={itinerary} />\n <Emissions itinerary={itinerary} co2Config={co2Config} />\n </S.TripDetailsBody>\n </S.TripDetails>\n );\n}\n\nexport default TripDetails;\n\n// Rename styled components for export.\nexport { S as Styled, FaresV2Table };\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,CAAA,GAAAC,uBAAA,CAAAL,OAAA;AAA8BM,OAAA,CAAAC,MAAA,GAAAH,CAAA;AAE9B,IAAAI,gBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,aAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,UAA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B;IACnCqB,UAAU,EAAEb,WAAW,IAAI,EAAAC,aAAA,GAAAC,MAAM,CAACY,IAAI,CAAC,CAAC,CAAC,cAAAb,aAAA,uBAAdA,aAAA,CAAgBc,UAAU,MAAK;EAAK,CAChE,CAAC,EACDlB,eAAe,iBAAInD,MAAA,CAAA4B,OAAA,CAAA+B,aAAA,CAAC3C,YAAA,CAAAY,OAAW;IAACwC,IAAI,EAAEpB,SAAS,CAACoB;EAAK,CAAE,CAAC,eACzDpE,MAAA,CAAA4B,OAAA,CAAA+B,aAAA,CAAC9C,MAAA,CAAAe,OAAK;IACJoB,SAAS,EAAEA,SAAU;IACrBD,WAAW,EAAEA,WAAY;IACzBF,eAAe,EAAEA,eAAgB;IACjCI,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC,eACFjD,MAAA,CAAA4B,OAAA,CAAA+B,aAAA,CAAC7C,WAAA,CAAAc,OAAU;IACTwC,IAAI,EAAEZ,MAAM,CAACY,IAAK;IAClBhB,iBAAiB,EAAEA,iBAAkB;IACrCF,4BAA4B,EAAEA;EAA6B,CAC5D,CAAC,eACFlD,MAAA,CAAA4B,OAAA,CAAA+B,aAAA,CAACjD,gBAAA,CAAAkB,OAAe;IAACoB,SAAS,EAAEA;EAAU,CAAE,CAAC,eACzChD,MAAA,CAAA4B,OAAA,CAAA+B,aAAA,CAAC/C,UAAA,CAAAgB,OAAS;IAACoB,SAAS,EAAEA,SAAU;IAACJ,SAAS,EAAEA;EAAU,CAAE,CACvC,CACN,CAAC;AAEpB;AAAC,IAAA0B,QAAA,GAAA9D,OAAA,CAAAoB,OAAA,GAEce,WAAW,EAE1B","ignoreList":[]}
|
package/lib/types.d.ts
CHANGED
|
@@ -53,9 +53,19 @@ export interface TripDetailsProps {
|
|
|
53
53
|
* show the '~' symbol in the trip details panel
|
|
54
54
|
*/
|
|
55
55
|
showApproximateMinutesActive?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Show time on board transit vehicles, excluding transfers and waiting.
|
|
58
|
+
*/
|
|
59
|
+
showTransitTime?: boolean;
|
|
56
60
|
/**
|
|
57
61
|
* Slot for a custom component to render the expandable section for time active.
|
|
58
62
|
*/
|
|
59
63
|
TimeActiveDetails?: React.ElementType<TimeActiveDetailsProps>;
|
|
64
|
+
/**
|
|
65
|
+
* Use the first transit departure and count only transfer activity between
|
|
66
|
+
* the first and last transit legs.
|
|
67
|
+
* Defaults to false. Trips without transit retain their full-journey timing.
|
|
68
|
+
*/
|
|
69
|
+
transitOnly?: boolean;
|
|
60
70
|
}
|
|
61
71
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,GAAG,EACH,cAAc,EACd,oBAAoB,EACpB,KAAK,EACL,MAAM,wBAAwB,CAAC;AAEjC,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,IAAI,CAAC;CACrB;AAID,MAAM,MAAM,UAAU,GAAG,CAAC,mBAAmB,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,EAAE,CAAA;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG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AG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACjB;;KAEC;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC5D;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAClD;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C;;OAEG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAC9D;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// Prettier does not recognize the import type syntax.\n// eslint-disable-next-line prettier/prettier\nimport type {
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// Prettier does not recognize the import type syntax.\n// eslint-disable-next-line prettier/prettier\nimport type {\n FareProductSelector,\n Itinerary,\n Leg,\n MassUnitOption,\n MediumRiderWhitelist,\n Money\n } from \"@opentripplanner/types\";\n\nexport interface TimeActiveDetailsProps {\n bikeMinutes: number;\n minutesActive?: number;\n walkMinutes: number;\n}\n\nexport interface CO2ConfigType {\n carbonIntensity?: Record<string, number>;\n units?: MassUnitOption;\n enabled?: boolean;\n}\n\nexport interface DepartureDetailsProps {\n departureDate: Date;\n}\n\n\n// Total fare amount corresponding to a fare key\nexport type FareTotals = (FareProductSelector & { price: Money })[]\n\nexport interface FareDetailsProps {\n legs: Leg[];\n maxTNCFare: number;\n minTNCFare: number;\n}\n\nexport interface TripDetailsProps {\n /**\n * Used for additional styling with styled components for example.\n */\n className?: string;\n /**\n * Object containing the CO₂ config.\n */\n co2Config?: CO2ConfigType;\n /**\n * Determines which transit fare should be displayed by default, should there be multiple transit fare types.\n */\n defaultFareType?: FareProductSelector;\n /**\n * Slot for a custom component to render the expandable section for departure.\n */\n DepartureDetails?: React.ElementType<DepartureDetailsProps>;\n /**\n * Slot for a custom component to render the expandable section for fares.\n */\n FareDetails?: React.ElementType<FareDetailsProps>;\n /**\n * Itinerary that the user has selected to view, contains multiple legs.\n */\n itinerary: Itinerary;\n /**\n * A whitelist of medium-rider pairs to be shown. All others will be hidden.\n */\n mediumRiderWhitelist?: MediumRiderWhitelist;\n /**\n * show the '~' symbol in the trip details panel\n */\n showApproximateMinutesActive?: boolean;\n /**\n * Show time on board transit vehicles, excluding transfers and waiting.\n */\n showTransitTime?: boolean;\n /**\n * Slot for a custom component to render the expandable section for time active.\n */\n TimeActiveDetails?: React.ElementType<TimeActiveDetailsProps>;\n /**\n * Use the first transit departure and count only transfer activity between\n * the first and last transit legs.\n * Defaults to false. Trips without transit retain their full-journey timing.\n */\n transitOnly?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentripplanner/trip-details",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0-alpha.1",
|
|
4
4
|
"description": "A component for displaying details about a trip planning itinerary",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"@styled-icons/fa-solid": "^10.34.0",
|
|
19
19
|
"flat": "^5.0.2",
|
|
20
20
|
"react-animate-height": "^3.0.4",
|
|
21
|
-
"@opentripplanner/core-utils": "^
|
|
21
|
+
"@opentripplanner/core-utils": "^17.0.0-alpha.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@opentripplanner/types": "^
|
|
24
|
+
"@opentripplanner/types": "^9.0.0-alpha.4"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "^18.2.0",
|
|
@@ -92,7 +92,9 @@ function createTripDetailsTemplate(
|
|
|
92
92
|
itinerary,
|
|
93
93
|
mediumRiderWhitelist,
|
|
94
94
|
showApproximateMinutesActive,
|
|
95
|
-
|
|
95
|
+
showTransitTime,
|
|
96
|
+
TimeActiveDetails,
|
|
97
|
+
transitOnly
|
|
96
98
|
}: TripDetailsProps): ReactElement => {
|
|
97
99
|
return (
|
|
98
100
|
<Component
|
|
@@ -103,7 +105,9 @@ function createTripDetailsTemplate(
|
|
|
103
105
|
itinerary={itinerary}
|
|
104
106
|
mediumRiderWhitelist={mediumRiderWhitelist}
|
|
105
107
|
showApproximateMinutesActive={showApproximateMinutesActive}
|
|
108
|
+
showTransitTime={showTransitTime}
|
|
106
109
|
TimeActiveDetails={TimeActiveDetails}
|
|
110
|
+
transitOnly={transitOnly}
|
|
107
111
|
/>
|
|
108
112
|
);
|
|
109
113
|
};
|
|
@@ -125,14 +129,27 @@ function makeStory(
|
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
export default {
|
|
132
|
+
args: {
|
|
133
|
+
showTransitTime: false,
|
|
134
|
+
transitOnly: false
|
|
135
|
+
},
|
|
136
|
+
argTypes: {
|
|
137
|
+
showTransitTime: {
|
|
138
|
+
control: "boolean",
|
|
139
|
+
description:
|
|
140
|
+
"Show time on board transit vehicles, excluding transfers and waiting."
|
|
141
|
+
},
|
|
142
|
+
transitOnly: {
|
|
143
|
+
control: "boolean",
|
|
144
|
+
description:
|
|
145
|
+
"Use the first transit departure and count active time only between the first and last transit legs."
|
|
146
|
+
}
|
|
147
|
+
},
|
|
128
148
|
component: TripDetails,
|
|
129
149
|
parameters: {
|
|
130
150
|
date: new Date("March 10, 2021 10:00:00"),
|
|
131
|
-
// Hide all controls
|
|
132
|
-
// (there are no args that the user can interactively change for this component).
|
|
133
151
|
controls: {
|
|
134
|
-
|
|
135
|
-
include: []
|
|
152
|
+
include: ["showTransitTime", "transitOnly"]
|
|
136
153
|
}
|
|
137
154
|
},
|
|
138
155
|
title: "TripDetails"
|
|
@@ -155,6 +172,12 @@ export const WalkTransitWalkItinerary = makeStory({
|
|
|
155
172
|
itinerary: walkTransitWalkItinerary
|
|
156
173
|
});
|
|
157
174
|
|
|
175
|
+
export const TransitTimingItinerary = makeStory({
|
|
176
|
+
itinerary: walkTransitWalkTransitWalkItinerary,
|
|
177
|
+
showTransitTime: true,
|
|
178
|
+
transitOnly: true
|
|
179
|
+
});
|
|
180
|
+
|
|
158
181
|
export const StyledItinerary = makeStory(
|
|
159
182
|
{
|
|
160
183
|
itinerary: walkTransitWalkItinerary
|
|
@@ -3751,6 +3751,319 @@ exports[`TripDetails TncTransitItineraryWithCustomMessages smoke-test 1`] = `
|
|
|
3751
3751
|
</div>
|
|
3752
3752
|
`;
|
|
3753
3753
|
|
|
3754
|
+
exports[`TripDetails TransitTimingItinerary smoke-test 1`] = `
|
|
3755
|
+
<div class="styled__TripDetails-sc-6q2ok2-17 bkRgZI trip-details">
|
|
3756
|
+
<h2 id="trip-details-header"
|
|
3757
|
+
class="styled__TripDetailsHeader-sc-6q2ok2-19 fxsUFT"
|
|
3758
|
+
>
|
|
3759
|
+
Trip Details
|
|
3760
|
+
</h2>
|
|
3761
|
+
<div class="styled__TripDetailsBody-sc-6q2ok2-18 ljKmZo">
|
|
3762
|
+
<div role="group"
|
|
3763
|
+
class="styled__TripDetail-sc-6q2ok2-14 gNQyHU departure-date"
|
|
3764
|
+
>
|
|
3765
|
+
<div role="presentation"
|
|
3766
|
+
class="styled__TripDetailIcon-sc-6q2ok2-16 hauLWc"
|
|
3767
|
+
>
|
|
3768
|
+
<svg viewbox="0 0 448 512"
|
|
3769
|
+
height="17"
|
|
3770
|
+
width="17"
|
|
3771
|
+
aria-hidden="true"
|
|
3772
|
+
focusable="false"
|
|
3773
|
+
fill="currentColor"
|
|
3774
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3775
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3776
|
+
>
|
|
3777
|
+
<path fill="currentColor"
|
|
3778
|
+
d="M128 0c17.7 0 32 14.3 32 32v32h128V32c0-17.7 14.3-32 32-32s32 14.3 32 32v32h48c26.5 0 48 21.5 48 48v48H0v-48c0-26.5 21.5-48 48-48h48V32c0-17.7 14.3-32 32-32zM0 192h448v272c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V192zm64 80v32c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16zm128 0v32c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16zm144-16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16h-32zM64 400v32c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16zm144-16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16h-32zm112 16v32c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16z"
|
|
3779
|
+
>
|
|
3780
|
+
</path>
|
|
3781
|
+
</svg>
|
|
3782
|
+
</div>
|
|
3783
|
+
<div class="styled__TripDetailSummary-sc-6q2ok2-20 jMnFLu">
|
|
3784
|
+
<span class="styled__Timing-sc-6q2ok2-10 QXYlJ">
|
|
3785
|
+
Board
|
|
3786
|
+
<strong>
|
|
3787
|
+
November 13, 2019
|
|
3788
|
+
</strong>
|
|
3789
|
+
at
|
|
3790
|
+
<strong>
|
|
3791
|
+
3:47 PM
|
|
3792
|
+
</strong>
|
|
3793
|
+
</span>
|
|
3794
|
+
</div>
|
|
3795
|
+
<div aria-hidden="true"
|
|
3796
|
+
class="rah-static rah-static--height-zero "
|
|
3797
|
+
style="height: 0px; overflow: hidden;"
|
|
3798
|
+
>
|
|
3799
|
+
<div style="display: none;">
|
|
3800
|
+
<div aria-labelledby="expand-button"
|
|
3801
|
+
id="mocked_id"
|
|
3802
|
+
class="styled__TripDetailDescription-sc-6q2ok2-15 emGeSO"
|
|
3803
|
+
>
|
|
3804
|
+
<button role="presentation"
|
|
3805
|
+
class="styled__BaseButton-sc-6q2ok2-2 styled__HideButton-sc-6q2ok2-7 bZXrLi fABSVY"
|
|
3806
|
+
>
|
|
3807
|
+
<svg viewbox="0 0 512 512"
|
|
3808
|
+
height="0.92em"
|
|
3809
|
+
width="0.92em"
|
|
3810
|
+
aria-hidden="true"
|
|
3811
|
+
focusable="false"
|
|
3812
|
+
fill="currentColor"
|
|
3813
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3814
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3815
|
+
>
|
|
3816
|
+
<path fill="currentColor"
|
|
3817
|
+
d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0 0 114.6 0 256s114.6 256 256 256zm-81-337c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"
|
|
3818
|
+
>
|
|
3819
|
+
</path>
|
|
3820
|
+
</svg>
|
|
3821
|
+
</button>
|
|
3822
|
+
</div>
|
|
3823
|
+
</div>
|
|
3824
|
+
</div>
|
|
3825
|
+
</div>
|
|
3826
|
+
<div role="group"
|
|
3827
|
+
class="styled__TripDetail-sc-6q2ok2-14 gNQyHU transit-time"
|
|
3828
|
+
>
|
|
3829
|
+
<div role="presentation"
|
|
3830
|
+
class="styled__TripDetailIcon-sc-6q2ok2-16 hauLWc"
|
|
3831
|
+
>
|
|
3832
|
+
<svg viewbox="0 0 512 512"
|
|
3833
|
+
height="17"
|
|
3834
|
+
width="17"
|
|
3835
|
+
aria-hidden="true"
|
|
3836
|
+
focusable="false"
|
|
3837
|
+
fill="currentColor"
|
|
3838
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3839
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3840
|
+
>
|
|
3841
|
+
<path fill="currentColor"
|
|
3842
|
+
d="M256 512C114.6 512 0 397.4 0 256S114.6 0 256 0s256 114.6 256 256-114.6 256-256 256zm-24-392v136c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2V120c0-13.3-10.7-24-24-24s-24 10.7-24 24z"
|
|
3843
|
+
>
|
|
3844
|
+
</path>
|
|
3845
|
+
</svg>
|
|
3846
|
+
</div>
|
|
3847
|
+
<div class="styled__TripDetailSummary-sc-6q2ok2-20 jMnFLu">
|
|
3848
|
+
Transit Time:
|
|
3849
|
+
<strong>
|
|
3850
|
+
9 minutes
|
|
3851
|
+
</strong>
|
|
3852
|
+
</div>
|
|
3853
|
+
<div aria-hidden="true"
|
|
3854
|
+
class="rah-static rah-static--height-zero "
|
|
3855
|
+
style="height: 0px; overflow: hidden;"
|
|
3856
|
+
>
|
|
3857
|
+
<div style="display: none;">
|
|
3858
|
+
<div aria-labelledby="expand-button"
|
|
3859
|
+
id="mocked_id"
|
|
3860
|
+
class="styled__TripDetailDescription-sc-6q2ok2-15 emGeSO"
|
|
3861
|
+
>
|
|
3862
|
+
<button role="presentation"
|
|
3863
|
+
class="styled__BaseButton-sc-6q2ok2-2 styled__HideButton-sc-6q2ok2-7 bZXrLi fABSVY"
|
|
3864
|
+
>
|
|
3865
|
+
<svg viewbox="0 0 512 512"
|
|
3866
|
+
height="0.92em"
|
|
3867
|
+
width="0.92em"
|
|
3868
|
+
aria-hidden="true"
|
|
3869
|
+
focusable="false"
|
|
3870
|
+
fill="currentColor"
|
|
3871
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3872
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3873
|
+
>
|
|
3874
|
+
<path fill="currentColor"
|
|
3875
|
+
d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0 0 114.6 0 256s114.6 256 256 256zm-81-337c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"
|
|
3876
|
+
>
|
|
3877
|
+
</path>
|
|
3878
|
+
</svg>
|
|
3879
|
+
</button>
|
|
3880
|
+
</div>
|
|
3881
|
+
</div>
|
|
3882
|
+
</div>
|
|
3883
|
+
</div>
|
|
3884
|
+
<div role="group"
|
|
3885
|
+
class="styled__TripDetail-sc-6q2ok2-14 gNQyHU time-active"
|
|
3886
|
+
>
|
|
3887
|
+
<div role="presentation"
|
|
3888
|
+
class="styled__TripDetailIcon-sc-6q2ok2-16 hauLWc"
|
|
3889
|
+
>
|
|
3890
|
+
<svg viewbox="0 0 512 512"
|
|
3891
|
+
height="17"
|
|
3892
|
+
width="17"
|
|
3893
|
+
aria-hidden="true"
|
|
3894
|
+
focusable="false"
|
|
3895
|
+
fill="currentColor"
|
|
3896
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3897
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3898
|
+
>
|
|
3899
|
+
<path fill="currentColor"
|
|
3900
|
+
d="M228.3 469.1 47.6 300.4c-4.2-3.9-8.2-8.1-11.9-12.4h87c22.6 0 43-13.6 51.7-34.5l10.5-25.2 49.3 109.5c3.8 8.5 12.1 14 21.4 14.1s17.8-5 22-13.3l42.4-84.9 1.7 3.4c9.5 19 28.9 31 50.1 31h104.5c-3.7 4.3-7.7 8.5-11.9 12.4L283.7 469.1c-7.5 7-17.4 10.9-27.7 10.9s-20.2-3.9-27.7-10.9zM503.7 240h-132c-3 0-5.8-1.7-7.2-4.4l-23.2-46.3c-4.1-8.1-12.4-13.3-21.5-13.3s-17.4 5.1-21.5 13.3l-41.4 82.8-51-113.9c-3.9-8.7-12.7-14.3-22.2-14.1s-18.1 5.9-21.8 14.8l-31.8 76.3c-1.2 3-4.2 4.9-7.4 4.9H16c-2.6 0-5 .4-7.3 1.1-5.7-16-8.7-33-8.7-50.3v-5.8c0-69.9 50.5-129.5 119.4-141 45.6-7.6 92 7.3 124.6 39.9l12 12 12-12c32.6-32.6 79-47.5 124.6-39.9 68.9 11.5 119.4 71.1 119.4 141v5.8c0 16.9-2.8 33.5-8.3 49.1z"
|
|
3901
|
+
>
|
|
3902
|
+
</path>
|
|
3903
|
+
</svg>
|
|
3904
|
+
</div>
|
|
3905
|
+
<div class="styled__TripDetailSummary-sc-6q2ok2-20 jMnFLu">
|
|
3906
|
+
Time Spent Active:
|
|
3907
|
+
<strong>
|
|
3908
|
+
2 minutes
|
|
3909
|
+
</strong>
|
|
3910
|
+
<button aria-label="Show details"
|
|
3911
|
+
aria-controls="mocked_id"
|
|
3912
|
+
aria-expanded="false"
|
|
3913
|
+
id="expand-button"
|
|
3914
|
+
tabindex="0"
|
|
3915
|
+
class="styled__BaseButton-sc-6q2ok2-2 styled__ExpandButton-sc-6q2ok2-5 bZXrLi dfkWTA"
|
|
3916
|
+
>
|
|
3917
|
+
<svg viewbox="0 0 512 512"
|
|
3918
|
+
height="0.92em"
|
|
3919
|
+
width="0.92em"
|
|
3920
|
+
aria-hidden="true"
|
|
3921
|
+
focusable="false"
|
|
3922
|
+
fill="currentColor"
|
|
3923
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3924
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3925
|
+
>
|
|
3926
|
+
<path fill="currentColor"
|
|
3927
|
+
d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0 0 114.6 0 256s114.6 256 256 256zm-86.2-346.7c7.9-22.3 29.1-37.3 52.8-37.3h58.3c34.9 0 63.1 28.3 63.1 63.1 0 22.6-12.1 43.5-31.7 54.8L280 264.4c-.2 13-10.9 23.6-24 23.6-13.3 0-24-10.7-24-24v-13.5c0-8.6 4.6-16.5 12.1-20.8l44.3-25.4c4.7-2.7 7.6-7.7 7.6-13.1 0-8.4-6.8-15.1-15.1-15.1h-58.3c-3.4 0-6.4 2.1-7.5 5.3l-.4 1.2c-4.4 12.5-18.2 19-30.6 14.6s-19-18.2-14.6-30.6l.4-1.2zM288 352c0 17.7-14.3 32-32 32s-32-14.3-32-32 14.3-32 32-32 32 14.3 32 32z"
|
|
3928
|
+
>
|
|
3929
|
+
</path>
|
|
3930
|
+
</svg>
|
|
3931
|
+
</button>
|
|
3932
|
+
</div>
|
|
3933
|
+
<div aria-hidden="true"
|
|
3934
|
+
class="rah-static rah-static--height-zero "
|
|
3935
|
+
style="height: 0px; overflow: hidden;"
|
|
3936
|
+
>
|
|
3937
|
+
<div style="display: none;">
|
|
3938
|
+
<div aria-labelledby="expand-button"
|
|
3939
|
+
id="mocked_id"
|
|
3940
|
+
class="styled__TripDetailDescription-sc-6q2ok2-15 emGeSO"
|
|
3941
|
+
>
|
|
3942
|
+
<button role="presentation"
|
|
3943
|
+
class="styled__BaseButton-sc-6q2ok2-2 styled__HideButton-sc-6q2ok2-7 bZXrLi fABSVY"
|
|
3944
|
+
>
|
|
3945
|
+
<svg viewbox="0 0 512 512"
|
|
3946
|
+
height="0.92em"
|
|
3947
|
+
width="0.92em"
|
|
3948
|
+
aria-hidden="true"
|
|
3949
|
+
focusable="false"
|
|
3950
|
+
fill="currentColor"
|
|
3951
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3952
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3953
|
+
>
|
|
3954
|
+
<path fill="currentColor"
|
|
3955
|
+
d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0 0 114.6 0 256s114.6 256 256 256zm-81-337c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"
|
|
3956
|
+
>
|
|
3957
|
+
</path>
|
|
3958
|
+
</svg>
|
|
3959
|
+
</button>
|
|
3960
|
+
By taking this trip, you'll spend
|
|
3961
|
+
<strong>
|
|
3962
|
+
2 minutes
|
|
3963
|
+
</strong>
|
|
3964
|
+
walking and
|
|
3965
|
+
<strong>
|
|
3966
|
+
0 minutes
|
|
3967
|
+
</strong>
|
|
3968
|
+
biking.
|
|
3969
|
+
</div>
|
|
3970
|
+
</div>
|
|
3971
|
+
</div>
|
|
3972
|
+
</div>
|
|
3973
|
+
<div role="group"
|
|
3974
|
+
class="styled__TripDetail-sc-6q2ok2-14 gNQyHU emissions"
|
|
3975
|
+
>
|
|
3976
|
+
<div role="presentation"
|
|
3977
|
+
class="styled__TripDetailIcon-sc-6q2ok2-16 hauLWc"
|
|
3978
|
+
>
|
|
3979
|
+
<svg viewbox="0 0 512 512"
|
|
3980
|
+
height="17"
|
|
3981
|
+
width="17"
|
|
3982
|
+
aria-hidden="true"
|
|
3983
|
+
focusable="false"
|
|
3984
|
+
fill="currentColor"
|
|
3985
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3986
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
3987
|
+
>
|
|
3988
|
+
<path fill="currentColor"
|
|
3989
|
+
d="M272 96c-78.6 0-145.1 51.5-167.7 122.5 33.6-17 71.5-26.5 111.7-26.5h88c8.8 0 16 7.2 16 16s-7.2 16-16 16h-88c-16.6 0-32.7 1.9-48.3 5.4-25.9 5.9-49.9 16.4-71.4 30.7C38.3 298.8 0 364.9 0 440v16c0 13.3 10.7 24 24 24s24-10.7 24-24v-16c0-48.7 20.7-92.5 53.8-123.2C121.6 392.3 190.3 448 272 448h1c132.1-.7 239-130.9 239-291.4 0-42.6-7.5-83.1-21.1-119.6-2.6-6.9-12.7-6.6-16.2-.1C455.9 72.1 418.7 96 376 96H272z"
|
|
3990
|
+
>
|
|
3991
|
+
</path>
|
|
3992
|
+
</svg>
|
|
3993
|
+
</div>
|
|
3994
|
+
<div class="styled__TripDetailSummary-sc-6q2ok2-20 jMnFLu">
|
|
3995
|
+
<span class="styled__CO2Summary-sc-6q2ok2-4 ctvvFS">
|
|
3996
|
+
CO₂ Emitted:
|
|
3997
|
+
<strong>
|
|
3998
|
+
219g
|
|
3999
|
+
</strong>
|
|
4000
|
+
</span>
|
|
4001
|
+
<button aria-label="Show details"
|
|
4002
|
+
aria-controls="mocked_id"
|
|
4003
|
+
aria-expanded="false"
|
|
4004
|
+
id="expand-button"
|
|
4005
|
+
tabindex="0"
|
|
4006
|
+
class="styled__BaseButton-sc-6q2ok2-2 styled__ExpandButton-sc-6q2ok2-5 bZXrLi dfkWTA"
|
|
4007
|
+
>
|
|
4008
|
+
<svg viewbox="0 0 512 512"
|
|
4009
|
+
height="0.92em"
|
|
4010
|
+
width="0.92em"
|
|
4011
|
+
aria-hidden="true"
|
|
4012
|
+
focusable="false"
|
|
4013
|
+
fill="currentColor"
|
|
4014
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4015
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
4016
|
+
>
|
|
4017
|
+
<path fill="currentColor"
|
|
4018
|
+
d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0 0 114.6 0 256s114.6 256 256 256zm-86.2-346.7c7.9-22.3 29.1-37.3 52.8-37.3h58.3c34.9 0 63.1 28.3 63.1 63.1 0 22.6-12.1 43.5-31.7 54.8L280 264.4c-.2 13-10.9 23.6-24 23.6-13.3 0-24-10.7-24-24v-13.5c0-8.6 4.6-16.5 12.1-20.8l44.3-25.4c4.7-2.7 7.6-7.7 7.6-13.1 0-8.4-6.8-15.1-15.1-15.1h-58.3c-3.4 0-6.4 2.1-7.5 5.3l-.4 1.2c-4.4 12.5-18.2 19-30.6 14.6s-19-18.2-14.6-30.6l.4-1.2zM288 352c0 17.7-14.3 32-32 32s-32-14.3-32-32 14.3-32 32-32 32 14.3 32 32z"
|
|
4019
|
+
>
|
|
4020
|
+
</path>
|
|
4021
|
+
</svg>
|
|
4022
|
+
</button>
|
|
4023
|
+
</div>
|
|
4024
|
+
<div aria-hidden="true"
|
|
4025
|
+
class="rah-static rah-static--height-zero "
|
|
4026
|
+
style="height: 0px; overflow: hidden;"
|
|
4027
|
+
>
|
|
4028
|
+
<div style="display: none;">
|
|
4029
|
+
<div aria-labelledby="expand-button"
|
|
4030
|
+
id="mocked_id"
|
|
4031
|
+
class="styled__TripDetailDescription-sc-6q2ok2-15 emGeSO"
|
|
4032
|
+
>
|
|
4033
|
+
<button role="presentation"
|
|
4034
|
+
class="styled__BaseButton-sc-6q2ok2-2 styled__HideButton-sc-6q2ok2-7 bZXrLi fABSVY"
|
|
4035
|
+
>
|
|
4036
|
+
<svg viewbox="0 0 512 512"
|
|
4037
|
+
height="0.92em"
|
|
4038
|
+
width="0.92em"
|
|
4039
|
+
aria-hidden="true"
|
|
4040
|
+
focusable="false"
|
|
4041
|
+
fill="currentColor"
|
|
4042
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4043
|
+
class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
|
|
4044
|
+
>
|
|
4045
|
+
<path fill="currentColor"
|
|
4046
|
+
d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0 0 114.6 0 256s114.6 256 256 256zm-81-337c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"
|
|
4047
|
+
>
|
|
4048
|
+
</path>
|
|
4049
|
+
</svg>
|
|
4050
|
+
</button>
|
|
4051
|
+
CO₂ intensity is calculated by multiplying the distance of each leg of a trip by the CO₂ intensity of each mode. CO₂ intensity of each mode is derived from
|
|
4052
|
+
<a href="https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx"
|
|
4053
|
+
rel="noopener noreferrer"
|
|
4054
|
+
target="_blank"
|
|
4055
|
+
>
|
|
4056
|
+
this spreadsheet
|
|
4057
|
+
</a>
|
|
4058
|
+
.
|
|
4059
|
+
</div>
|
|
4060
|
+
</div>
|
|
4061
|
+
</div>
|
|
4062
|
+
</div>
|
|
4063
|
+
</div>
|
|
4064
|
+
</div>
|
|
4065
|
+
`;
|
|
4066
|
+
|
|
3754
4067
|
exports[`TripDetails WalkOnlyItinerary smoke-test 1`] = `
|
|
3755
4068
|
<div class="styled__TripDetails-sc-6q2ok2-17 bkRgZI trip-details">
|
|
3756
4069
|
<h2 id="trip-details-header"
|
|
@@ -18,15 +18,19 @@ import defaultEnglishMessages from "../../i18n/en-US.yml";
|
|
|
18
18
|
const defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);
|
|
19
19
|
|
|
20
20
|
interface DepartureDateProps {
|
|
21
|
-
|
|
21
|
+
startTime: Itinerary["startTime"];
|
|
22
22
|
DepartureDetails?: React.ElementType<DepartureDetailsProps>;
|
|
23
|
+
isBoarding: boolean;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export default function DepartureDate({
|
|
26
|
-
|
|
27
|
-
DepartureDetails
|
|
27
|
+
startTime,
|
|
28
|
+
DepartureDetails,
|
|
29
|
+
isBoarding
|
|
28
30
|
}: DepartureDateProps): ReactElement {
|
|
29
|
-
const departureDate = new Date(
|
|
31
|
+
const departureDate = new Date(startTime);
|
|
32
|
+
const values = { departureDate, strong: boldText };
|
|
33
|
+
|
|
30
34
|
return (
|
|
31
35
|
<TripDetail
|
|
32
36
|
className="departure-date"
|
|
@@ -36,16 +40,23 @@ export default function DepartureDate({
|
|
|
36
40
|
}
|
|
37
41
|
icon={<CalendarAlt size={17} />}
|
|
38
42
|
summary={
|
|
43
|
+
// TODO: is there a way to do this without `isBoarding`?
|
|
39
44
|
<S.Timing>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
{isBoarding ? (
|
|
46
|
+
<FormattedMessage
|
|
47
|
+
defaultMessage={defaultMessages["otpUi.TripDetails.boarding"]}
|
|
48
|
+
description="Text showing when to board the first transit leg."
|
|
49
|
+
id="otpUi.TripDetails.boarding"
|
|
50
|
+
values={values}
|
|
51
|
+
/>
|
|
52
|
+
) : (
|
|
53
|
+
<FormattedMessage
|
|
54
|
+
defaultMessage={defaultMessages["otpUi.TripDetails.departure"]}
|
|
55
|
+
description="Text showing the departure date/time for a trip."
|
|
56
|
+
id="otpUi.TripDetails.departure"
|
|
57
|
+
values={values}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
49
60
|
</S.Timing>
|
|
50
61
|
}
|
|
51
62
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { FormattedMessage } from "react-intl";
|
|
3
3
|
import { Heartbeat } from "@styled-icons/fa-solid/Heartbeat";
|
|
4
|
-
import {
|
|
4
|
+
import { Leg } from "@opentripplanner/types";
|
|
5
5
|
import flatten from "flat";
|
|
6
6
|
import TripDetail from "../trip-detail";
|
|
7
7
|
import { boldText } from "../utils";
|
|
@@ -41,17 +41,17 @@ export function DefaultTimeActiveDetails({
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export default function TimeActive({
|
|
44
|
-
|
|
44
|
+
legs,
|
|
45
45
|
TimeActiveDetails,
|
|
46
46
|
showApproximateMinutesActive
|
|
47
47
|
}: {
|
|
48
|
-
|
|
48
|
+
legs: Leg[];
|
|
49
49
|
TimeActiveDetails: React.ComponentType<TimeActiveDetailsProps>;
|
|
50
50
|
showApproximateMinutesActive: boolean;
|
|
51
51
|
}): JSX.Element | null {
|
|
52
52
|
let walkDurationSeconds = 0;
|
|
53
53
|
let bikeDurationSeconds = 0;
|
|
54
|
-
|
|
54
|
+
legs.forEach(leg => {
|
|
55
55
|
if (leg.mode.startsWith("WALK")) walkDurationSeconds += leg.duration;
|
|
56
56
|
if (leg.mode.startsWith("BICYCLE")) bikeDurationSeconds += leg.duration;
|
|
57
57
|
});
|