1
1
import React from "react" ;
2
2
import { action } from "@storybook/addon-actions" ;
3
- import MapPopupContents , { FocusTrapWrapper } from "./index" ;
3
+ import styled from "styled-components" ;
4
+ import { Station , Stop } from "@opentripplanner/types" ;
5
+ import MapPopupContents from "./index" ;
4
6
5
7
export default {
6
8
title : "Map Popup"
7
9
} ;
8
10
9
11
const STOP = {
10
12
flex : false ,
13
+ gtfsId : "9526" ,
11
14
id : "9526" ,
12
15
lat : 45.523009 ,
13
16
lon : - 122.672529 ,
@@ -40,21 +43,57 @@ const FLOATING_VEHICLE = {
40
43
id : '"bike_6861"' ,
41
44
isCarStation : false ,
42
45
isFloatingBike : true ,
43
- name : "0541 BIKETOWN " ,
46
+ name : "0541" ,
44
47
networks : [ "BIKETOWN" ] ,
45
48
realTimeData : true ,
46
49
spacesAvailable : 0 ,
47
50
x : - 122.70486 ,
48
51
y : 45.525486666666666
49
52
} ;
50
53
54
+ const FLOATING_CAR = {
55
+ "stroke-width" : 1 ,
56
+ allowDropoff : false ,
57
+ allowPickup : true ,
58
+ color : "#333" ,
59
+ id : "car_6861" ,
60
+ isCarStation : false ,
61
+ isFloatingCar : true ,
62
+ name : "0541" ,
63
+ networks : [ "MILES" ] , // https://miles-mobility.com
64
+ realTimeData : true ,
65
+ spacesAvailable : 0 ,
66
+ x : 13.405 ,
67
+ y : 52.52
68
+ } ;
69
+
70
+ const getEntityPrefixExample = ( entity : Stop | Station ) => {
71
+ const DemoIcon = styled . span `
72
+ background-color: blue;
73
+ border-radius: 50px;
74
+ color: white;
75
+ margin-right: 0.5ch;
76
+ padding: 2px;
77
+ ` ;
78
+
79
+ return < DemoIcon > { entity . name ?. charAt ( 0 ) } </ DemoIcon > ;
80
+ } ;
81
+
51
82
export const StopEntity = ( ) : JSX . Element => (
52
83
< MapPopupContents
53
84
entity = { STOP }
54
85
setLocation = { action ( "setLocation" ) }
55
86
setViewedStop = { action ( "setViewedStop" ) }
56
87
/>
57
88
) ;
89
+ export const StopEntitywithEntityPrefix = ( ) : JSX . Element => (
90
+ < MapPopupContents
91
+ entity = { STOP }
92
+ getEntityPrefix = { getEntityPrefixExample }
93
+ setLocation = { action ( "setLocation" ) }
94
+ setViewedStop = { action ( "setViewedStop" ) }
95
+ />
96
+ ) ;
58
97
59
98
export const StopEntityNoHandlers = ( ) : JSX . Element => (
60
99
< MapPopupContents entity = { STOP } />
@@ -68,20 +107,14 @@ export const StationEntity = (): JSX.Element => (
68
107
/>
69
108
) ;
70
109
110
+ export const FloatingCarEntity = ( ) : JSX . Element => (
111
+ < MapPopupContents entity = { FLOATING_CAR } setLocation = { action ( "setLocation" ) } />
112
+ ) ;
113
+
71
114
export const FloatingVehicleEntity = ( ) : JSX . Element => (
72
115
< MapPopupContents
73
116
entity = { FLOATING_VEHICLE }
74
117
setLocation = { action ( "setLocation" ) }
75
118
setViewedStop = { action ( "setViewedStop" ) }
76
119
/>
77
120
) ;
78
-
79
- export const StopEntityWithFocusTrap = ( ) : JSX . Element => (
80
- < FocusTrapWrapper closePopup = { ( ) => { } } id = "storybook-stop" >
81
- < MapPopupContents
82
- entity = { STOP }
83
- setLocation = { action ( "setLocation" ) }
84
- setViewedStop = { action ( "setViewedStop" ) }
85
- />
86
- </ FocusTrapWrapper >
87
- ) ;
0 commit comments