@opentripplanner/trip-details 9.2.0 → 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/fares-v2-table.js +7 -3
- package/esm/components/fares-v2-table.js.map +1 -1
- package/esm/components/fares.js +3 -1
- package/esm/components/fares.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 +18 -5
- 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/fares-v2-table.d.ts +3 -2
- package/lib/components/fares-v2-table.d.ts.map +1 -1
- package/lib/components/fares-v2-table.js +6 -4
- package/lib/components/fares-v2-table.js.map +1 -1
- package/lib/components/fares.d.ts +3 -2
- package/lib/components/fares.d.ts.map +1 -1
- package/lib/components/fares.js +3 -1
- package/lib/components/fares.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 +16 -5
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +15 -1
- 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 +40 -5
- package/src/__snapshots__/TripDetails.story.tsx.snap +313 -0
- package/src/components/departure-date.tsx +24 -13
- package/src/components/fares-v2-table.tsx +11 -3
- package/src/components/fares.tsx +9 -2
- package/src/components/time-active.tsx +4 -4
- package/src/components/transit-time.tsx +40 -0
- package/src/index.tsx +16 -3
- package/src/types.ts +20 -5
- package/tsconfig.tsbuildinfo +1 -1
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",
|
|
@@ -90,8 +90,11 @@ function createTripDetailsTemplate(
|
|
|
90
90
|
DepartureDetails,
|
|
91
91
|
FareDetails,
|
|
92
92
|
itinerary,
|
|
93
|
+
mediumRiderWhitelist,
|
|
94
|
+
showApproximateMinutesActive,
|
|
95
|
+
showTransitTime,
|
|
93
96
|
TimeActiveDetails,
|
|
94
|
-
|
|
97
|
+
transitOnly
|
|
95
98
|
}: TripDetailsProps): ReactElement => {
|
|
96
99
|
return (
|
|
97
100
|
<Component
|
|
@@ -100,8 +103,11 @@ function createTripDetailsTemplate(
|
|
|
100
103
|
DepartureDetails={DepartureDetails}
|
|
101
104
|
FareDetails={FareDetails}
|
|
102
105
|
itinerary={itinerary}
|
|
106
|
+
mediumRiderWhitelist={mediumRiderWhitelist}
|
|
103
107
|
showApproximateMinutesActive={showApproximateMinutesActive}
|
|
108
|
+
showTransitTime={showTransitTime}
|
|
104
109
|
TimeActiveDetails={TimeActiveDetails}
|
|
110
|
+
transitOnly={transitOnly}
|
|
105
111
|
/>
|
|
106
112
|
);
|
|
107
113
|
};
|
|
@@ -123,14 +129,27 @@ function makeStory(
|
|
|
123
129
|
}
|
|
124
130
|
|
|
125
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
|
+
},
|
|
126
148
|
component: TripDetails,
|
|
127
149
|
parameters: {
|
|
128
150
|
date: new Date("March 10, 2021 10:00:00"),
|
|
129
|
-
// Hide all controls
|
|
130
|
-
// (there are no args that the user can interactively change for this component).
|
|
131
151
|
controls: {
|
|
132
|
-
|
|
133
|
-
include: []
|
|
152
|
+
include: ["showTransitTime", "transitOnly"]
|
|
134
153
|
}
|
|
135
154
|
},
|
|
136
155
|
title: "TripDetails"
|
|
@@ -153,6 +172,12 @@ export const WalkTransitWalkItinerary = makeStory({
|
|
|
153
172
|
itinerary: walkTransitWalkItinerary
|
|
154
173
|
});
|
|
155
174
|
|
|
175
|
+
export const TransitTimingItinerary = makeStory({
|
|
176
|
+
itinerary: walkTransitWalkTransitWalkItinerary,
|
|
177
|
+
showTransitTime: true,
|
|
178
|
+
transitOnly: true
|
|
179
|
+
});
|
|
180
|
+
|
|
156
181
|
export const StyledItinerary = makeStory(
|
|
157
182
|
{
|
|
158
183
|
itinerary: walkTransitWalkItinerary
|
|
@@ -166,6 +191,16 @@ export const LegFareProductsItinerary = makeStory({
|
|
|
166
191
|
defaultFareType: { mediumId: "electronic", riderCategoryId: "regular" }
|
|
167
192
|
});
|
|
168
193
|
|
|
194
|
+
// export const LegFareProductsWithSpecialFareTableFeatures = makeStory({
|
|
195
|
+
// itinerary: TODO: MISSING DATA!,
|
|
196
|
+
// defaultFareType: { mediumId: "electronic", riderCategoryId: "regular" },
|
|
197
|
+
// showApproximateMinutesActive: true,
|
|
198
|
+
// mediumRiderWhitelist: [
|
|
199
|
+
// { medium: "electronic", rider: "regular" },
|
|
200
|
+
// { medium: "electronic", rider: "senior" }
|
|
201
|
+
// ]
|
|
202
|
+
// });
|
|
203
|
+
|
|
169
204
|
// The render of this itinerary is uninteresting, but the test
|
|
170
205
|
// is if we can parse an OTP2 itinerary without crashing
|
|
171
206
|
export const OTP2EScooterRentalTransitItinerary = makeStory({
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Leg } from "@opentripplanner/types";
|
|
3
|
+
import { Leg, MediumRiderWhitelist } from "@opentripplanner/types";
|
|
4
4
|
import coreUtils from "@opentripplanner/core-utils";
|
|
5
5
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
6
6
|
import styled from "styled-components";
|
|
@@ -72,15 +72,16 @@ const categorySorter = (favoriteId?: string) => (
|
|
|
72
72
|
return aId > bId ? 1 : -1;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
// TODO: This component currently can only show one type of fare per medium
|
|
76
75
|
const FaresV2Table = ({
|
|
77
76
|
legs,
|
|
78
77
|
favoriteMediumId,
|
|
79
|
-
favoriteRiderCategoryId
|
|
78
|
+
favoriteRiderCategoryId,
|
|
79
|
+
mediumRiderWhitelist
|
|
80
80
|
}: {
|
|
81
81
|
legs: Leg[];
|
|
82
82
|
favoriteMediumId?: string;
|
|
83
83
|
favoriteRiderCategoryId?: string;
|
|
84
|
+
mediumRiderWhitelist?: MediumRiderWhitelist;
|
|
84
85
|
}): JSX.Element => {
|
|
85
86
|
const intl = useIntl();
|
|
86
87
|
|
|
@@ -114,6 +115,13 @@ const FaresV2Table = ({
|
|
|
114
115
|
fp.product?.riderCategory?.id === rmp.rider?.id &&
|
|
115
116
|
fp.product?.medium?.id === rmp.medium?.id
|
|
116
117
|
)
|
|
118
|
+
)
|
|
119
|
+
.filter(
|
|
120
|
+
pair =>
|
|
121
|
+
!mediumRiderWhitelist ||
|
|
122
|
+
mediumRiderWhitelist?.find(
|
|
123
|
+
p => p.medium === pair.medium?.id && p.rider === pair.rider?.id
|
|
124
|
+
)
|
|
117
125
|
);
|
|
118
126
|
|
|
119
127
|
// Ensure we have at least one rider/medium
|
package/src/components/fares.tsx
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { FormattedMessage } from "react-intl";
|
|
3
3
|
import coreUtils from "@opentripplanner/core-utils";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
FareProductSelector,
|
|
6
|
+
Itinerary,
|
|
7
|
+
MediumRiderWhitelist
|
|
8
|
+
} from "@opentripplanner/types";
|
|
5
9
|
import { MoneyBillAlt } from "@styled-icons/fa-solid";
|
|
6
10
|
import { flatten } from "flat";
|
|
7
11
|
import * as S from "../styled";
|
|
@@ -17,6 +21,7 @@ export interface FaresProps {
|
|
|
17
21
|
itinerary: Itinerary;
|
|
18
22
|
FareDetails?: React.ElementType<FareDetailsProps>;
|
|
19
23
|
defaultFareType?: FareProductSelector;
|
|
24
|
+
mediumRiderWhitelist?: MediumRiderWhitelist;
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
// HACK: We should flatten the messages loaded above because
|
|
@@ -28,7 +33,8 @@ const defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);
|
|
|
28
33
|
export default function Fares({
|
|
29
34
|
itinerary,
|
|
30
35
|
FareDetails,
|
|
31
|
-
defaultFareType
|
|
36
|
+
defaultFareType,
|
|
37
|
+
mediumRiderWhitelist
|
|
32
38
|
}: FaresProps): ReactElement | null {
|
|
33
39
|
// process the transit fare
|
|
34
40
|
const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
|
|
@@ -99,6 +105,7 @@ export default function Fares({
|
|
|
99
105
|
</summary>
|
|
100
106
|
<FaresV2Table
|
|
101
107
|
legs={itinerary.legs}
|
|
108
|
+
mediumRiderWhitelist={mediumRiderWhitelist}
|
|
102
109
|
favoriteMediumId={
|
|
103
110
|
Array.isArray(defaultFareType?.mediumId)
|
|
104
111
|
? defaultFareType?.mediumId[0]
|
|
@@ -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
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { FormattedMessage } from "react-intl";
|
|
3
|
+
import { Clock } from "@styled-icons/fa-solid/Clock";
|
|
4
|
+
import { Leg } from "@opentripplanner/types";
|
|
5
|
+
import flatten from "flat";
|
|
6
|
+
import TripDetail from "../trip-detail";
|
|
7
|
+
import { boldText } from "../utils";
|
|
8
|
+
|
|
9
|
+
import defaultEnglishMessages from "../../i18n/en-US.yml";
|
|
10
|
+
|
|
11
|
+
const defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);
|
|
12
|
+
|
|
13
|
+
/** Time on board transit vehicles, excluding transfer activity and waiting. */
|
|
14
|
+
export default function TransitTime({
|
|
15
|
+
legs
|
|
16
|
+
}: {
|
|
17
|
+
legs: Leg[];
|
|
18
|
+
}): ReactElement | null {
|
|
19
|
+
const transitLegs = legs.filter(leg => leg.transitLeg);
|
|
20
|
+
if (transitLegs.length === 0) return null;
|
|
21
|
+
|
|
22
|
+
const minutes = Math.round(
|
|
23
|
+
transitLegs.reduce((seconds, leg) => seconds + leg.duration, 0) / 60
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<TripDetail
|
|
28
|
+
className="transit-time"
|
|
29
|
+
icon={<Clock size={17} />}
|
|
30
|
+
summary={
|
|
31
|
+
<FormattedMessage
|
|
32
|
+
defaultMessage={defaultMessages["otpUi.TripDetails.transitTime"]}
|
|
33
|
+
description="Time spent on board transit vehicles, excluding transfers and waiting."
|
|
34
|
+
id="otpUi.TripDetails.transitTime"
|
|
35
|
+
values={{ minutes, strong: boldText }}
|
|
36
|
+
/>
|
|
37
|
+
}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|