@opentripplanner/map-popup 3.1.1 → 3.1.2

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.
@@ -0,0 +1,302 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Map Popup FloatingCarEntity smoke-test 1`] = `
4
+ <div class="styled__MapOverlayPopup-sc-12v7ov3-2 hLIcgt">
5
+ <header class="styled__PopupTitle-sc-12v7ov3-4 jMeCoZ">
6
+ MILES Car: 0541
7
+ </header>
8
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
9
+ <strong>
10
+ Plan a trip:
11
+ </strong>
12
+ <span class="styled__FromToPickerSpan-sc-vb4790-1 hmUShj">
13
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
14
+ <svg viewbox="0 0 512 512"
15
+ height="0.9em"
16
+ width="0.9em"
17
+ aria-hidden="true"
18
+ focusable="false"
19
+ fill="currentColor"
20
+ xmlns="http://www.w3.org/2000/svg"
21
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__FromIcon-sc-n5xcvc-0 jTjMOf"
22
+ >
23
+ <path fill="currentColor"
24
+ d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
25
+ >
26
+ </path>
27
+ </svg>
28
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
29
+ From here
30
+ </button>
31
+ </span>
32
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
33
+ <svg viewbox="0 0 384 512"
34
+ height="0.9em"
35
+ width="0.9em"
36
+ aria-hidden="true"
37
+ focusable="false"
38
+ fill="currentColor"
39
+ xmlns="http://www.w3.org/2000/svg"
40
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__ToIcon-sc-n5xcvc-2 ipFnZE"
41
+ >
42
+ <path fill="currentColor"
43
+ d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"
44
+ >
45
+ </path>
46
+ </svg>
47
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
48
+ To here
49
+ </button>
50
+ </span>
51
+ </span>
52
+ </p>
53
+ </div>
54
+ `;
55
+
56
+ exports[`Map Popup FloatingVehicleEntity smoke-test 1`] = `
57
+ <div class="styled__MapOverlayPopup-sc-12v7ov3-2 hLIcgt">
58
+ <header class="styled__PopupTitle-sc-12v7ov3-4 jMeCoZ">
59
+ BIKETOWN Free-floating bike: 0541
60
+ </header>
61
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
62
+ <strong>
63
+ Plan a trip:
64
+ </strong>
65
+ <span class="styled__FromToPickerSpan-sc-vb4790-1 hmUShj">
66
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
67
+ <svg viewbox="0 0 512 512"
68
+ height="0.9em"
69
+ width="0.9em"
70
+ aria-hidden="true"
71
+ focusable="false"
72
+ fill="currentColor"
73
+ xmlns="http://www.w3.org/2000/svg"
74
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__FromIcon-sc-n5xcvc-0 jTjMOf"
75
+ >
76
+ <path fill="currentColor"
77
+ d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
78
+ >
79
+ </path>
80
+ </svg>
81
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
82
+ From here
83
+ </button>
84
+ </span>
85
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
86
+ <svg viewbox="0 0 384 512"
87
+ height="0.9em"
88
+ width="0.9em"
89
+ aria-hidden="true"
90
+ focusable="false"
91
+ fill="currentColor"
92
+ xmlns="http://www.w3.org/2000/svg"
93
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__ToIcon-sc-n5xcvc-2 ipFnZE"
94
+ >
95
+ <path fill="currentColor"
96
+ d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"
97
+ >
98
+ </path>
99
+ </svg>
100
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
101
+ To here
102
+ </button>
103
+ </span>
104
+ </span>
105
+ </p>
106
+ </div>
107
+ `;
108
+
109
+ exports[`Map Popup StationEntity smoke-test 1`] = `
110
+ <div class="styled__MapOverlayPopup-sc-12v7ov3-2 hLIcgt">
111
+ <header class="styled__PopupTitle-sc-12v7ov3-4 jMeCoZ">
112
+ BIKETOWN SW Morrison at 18th
113
+ </header>
114
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
115
+ <div>
116
+ Available bikes: 6
117
+ </div>
118
+ <div>
119
+ Available docks: 11
120
+ </div>
121
+ </p>
122
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
123
+ <strong>
124
+ Plan a trip:
125
+ </strong>
126
+ <span class="styled__FromToPickerSpan-sc-vb4790-1 hmUShj">
127
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
128
+ <svg viewbox="0 0 512 512"
129
+ height="0.9em"
130
+ width="0.9em"
131
+ aria-hidden="true"
132
+ focusable="false"
133
+ fill="currentColor"
134
+ xmlns="http://www.w3.org/2000/svg"
135
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__FromIcon-sc-n5xcvc-0 jTjMOf"
136
+ >
137
+ <path fill="currentColor"
138
+ d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
139
+ >
140
+ </path>
141
+ </svg>
142
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
143
+ From here
144
+ </button>
145
+ </span>
146
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
147
+ <svg viewbox="0 0 384 512"
148
+ height="0.9em"
149
+ width="0.9em"
150
+ aria-hidden="true"
151
+ focusable="false"
152
+ fill="currentColor"
153
+ xmlns="http://www.w3.org/2000/svg"
154
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__ToIcon-sc-n5xcvc-2 ipFnZE"
155
+ >
156
+ <path fill="currentColor"
157
+ d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"
158
+ >
159
+ </path>
160
+ </svg>
161
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
162
+ To here
163
+ </button>
164
+ </span>
165
+ </span>
166
+ </p>
167
+ </div>
168
+ `;
169
+
170
+ exports[`Map Popup StopEntity smoke-test 1`] = `
171
+ <div class="styled__MapOverlayPopup-sc-12v7ov3-2 hLIcgt">
172
+ <header class="styled__PopupTitle-sc-12v7ov3-4 jMeCoZ">
173
+ W Burnside &amp; SW 2nd
174
+ </header>
175
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
176
+ <strong>
177
+ Stop ID: 9526
178
+ </strong>
179
+ <button class="styled__ViewStopButton-sc-12v7ov3-0 jdXQjY">
180
+ Stop Viewer
181
+ </button>
182
+ </p>
183
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
184
+ <strong>
185
+ Plan a trip:
186
+ </strong>
187
+ <span class="styled__FromToPickerSpan-sc-vb4790-1 hmUShj">
188
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
189
+ <svg viewbox="0 0 512 512"
190
+ height="0.9em"
191
+ width="0.9em"
192
+ aria-hidden="true"
193
+ focusable="false"
194
+ fill="currentColor"
195
+ xmlns="http://www.w3.org/2000/svg"
196
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__FromIcon-sc-n5xcvc-0 jTjMOf"
197
+ >
198
+ <path fill="currentColor"
199
+ d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
200
+ >
201
+ </path>
202
+ </svg>
203
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
204
+ From here
205
+ </button>
206
+ </span>
207
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
208
+ <svg viewbox="0 0 384 512"
209
+ height="0.9em"
210
+ width="0.9em"
211
+ aria-hidden="true"
212
+ focusable="false"
213
+ fill="currentColor"
214
+ xmlns="http://www.w3.org/2000/svg"
215
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__ToIcon-sc-n5xcvc-2 ipFnZE"
216
+ >
217
+ <path fill="currentColor"
218
+ d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"
219
+ >
220
+ </path>
221
+ </svg>
222
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
223
+ To here
224
+ </button>
225
+ </span>
226
+ </span>
227
+ </p>
228
+ </div>
229
+ `;
230
+
231
+ exports[`Map Popup StopEntityNoHandlers smoke-test 1`] = `
232
+ <div class="styled__MapOverlayPopup-sc-12v7ov3-2 hLIcgt">
233
+ <header class="styled__PopupTitle-sc-12v7ov3-4 jMeCoZ">
234
+ W Burnside &amp; SW 2nd
235
+ </header>
236
+ </div>
237
+ `;
238
+
239
+ exports[`Map Popup StopEntityWithFocusTrap smoke-test 1`] = `
240
+ <div id="storybook-stop-popup-focus-trap"
241
+ role="presentation"
242
+ >
243
+ <div class="styled__MapOverlayPopup-sc-12v7ov3-2 hLIcgt">
244
+ <header class="styled__PopupTitle-sc-12v7ov3-4 jMeCoZ">
245
+ W Burnside &amp; SW 2nd
246
+ </header>
247
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
248
+ <strong>
249
+ Stop ID: 9526
250
+ </strong>
251
+ <button class="styled__ViewStopButton-sc-12v7ov3-0 jdXQjY">
252
+ Stop Viewer
253
+ </button>
254
+ </p>
255
+ <p class="styled__PopupRow-sc-12v7ov3-3 bGmFCM">
256
+ <strong>
257
+ Plan a trip:
258
+ </strong>
259
+ <span class="styled__FromToPickerSpan-sc-vb4790-1 hmUShj">
260
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
261
+ <svg viewbox="0 0 512 512"
262
+ height="0.9em"
263
+ width="0.9em"
264
+ aria-hidden="true"
265
+ focusable="false"
266
+ fill="currentColor"
267
+ xmlns="http://www.w3.org/2000/svg"
268
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__FromIcon-sc-n5xcvc-0 jTjMOf"
269
+ >
270
+ <path fill="currentColor"
271
+ d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
272
+ >
273
+ </path>
274
+ </svg>
275
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
276
+ From here
277
+ </button>
278
+ </span>
279
+ <span class="styled__LocationPickerSpan-sc-vb4790-0 gwsIFy">
280
+ <svg viewbox="0 0 384 512"
281
+ height="0.9em"
282
+ width="0.9em"
283
+ aria-hidden="true"
284
+ focusable="false"
285
+ fill="currentColor"
286
+ xmlns="http://www.w3.org/2000/svg"
287
+ class="StyledIconBase-ea9ulj-0 hPhvO styled__ToIcon-sc-n5xcvc-2 ipFnZE"
288
+ >
289
+ <path fill="currentColor"
290
+ d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"
291
+ >
292
+ </path>
293
+ </svg>
294
+ <button class="styled__Button-sc-vb4790-2 hNNoVB">
295
+ To here
296
+ </button>
297
+ </span>
298
+ </span>
299
+ </p>
300
+ </div>
301
+ </div>
302
+ `;
package/src/index.tsx CHANGED
@@ -1,5 +1,7 @@
1
1
  import React, { useCallback } from "react";
2
2
  import FromToLocationPicker from "@opentripplanner/from-to-location-picker";
3
+ import coreUtils from "@opentripplanner/core-utils";
4
+
3
5
  // eslint-disable-next-line prettier/prettier
4
6
  import type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from "@opentripplanner/types";
5
7
 
@@ -103,6 +105,7 @@ export function MapPopup({ configCompanies, entity, getEntityName, setLocation,
103
105
  const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);
104
106
  const name = getNameFunc(entity, configCompanies);
105
107
 
108
+ const stationNetwork = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);
106
109
 
107
110
  const bikesAvailablePresent = entityIsStation(entity)
108
111
  const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;
@@ -110,7 +113,14 @@ export function MapPopup({ configCompanies, entity, getEntityName, setLocation,
110
113
 
111
114
  return (
112
115
  <S.MapOverlayPopup>
113
- <S.PopupTitle>{name}</S.PopupTitle>
116
+ <S.PopupTitle>
117
+ <FormattedMessage
118
+ defaultMessage={defaultMessages["otpUi.MapPopup.popupTitle"]}
119
+ description="Text for title of the popup, contains an optional company name"
120
+ id="otpUi.MapPopup.popupTitle"
121
+ values={{ name, stationNetwork }}
122
+ />
123
+ </S.PopupTitle>
114
124
  {/* render dock info if it is available */}
115
125
  {entityIsStationHub && <StationHubDetails station={entity} />}
116
126
 
package/src/util.ts CHANGED
@@ -11,6 +11,8 @@ export function makeDefaultGetEntityName(
11
11
  entity: Station | Stop,
12
12
  configCompanies: Company[]
13
13
  ): string | null {
14
+ // TODO: Stop generating this / passing it to the car string? Is it needed?
15
+ // In English we say "Car: " instead
14
16
  const stationNetworks =
15
17
  "networks" in entity &&
16
18
  (coreUtils.itinerary.getCompaniesLabelFromNetworks(
@@ -36,7 +38,7 @@ export function makeDefaultGetEntityName(
36
38
  description: "Popup title for a free-floating bike",
37
39
  id: "otpUi.MapPopup.floatingBike"
38
40
  },
39
- { name: stationName || stationNetworks }
41
+ { name: stationName }
40
42
  );
41
43
  } else if ("isFloatingCar" in entity && entity.isFloatingCar) {
42
44
  stationName = intl.formatMessage(
@@ -59,7 +61,7 @@ export function makeDefaultGetEntityName(
59
61
  description: "Popup title for a free-floating e-scooter",
60
62
  id: "otpUi.MapPopup.floatingEScooter"
61
63
  },
62
- { name: stationName || stationNetworks }
64
+ { name: stationName }
63
65
  );
64
66
  }
65
67
  return stationName;