@@ -5,54 +5,37 @@ import Icon from '../Icon';
55import RouteNumber from '../RouteNumber' ;
66import { ViaLocationType , IndoorLegType } from '../../constants' ;
77
8- class ItineraryCircleLineWithIcon extends React . Component {
9- static propTypes = {
10- index : PropTypes . number . isRequired ,
11- modeClassName : PropTypes . string . isRequired ,
12- viaType : PropTypes . string ,
13- indoorLegType : PropTypes . oneOf ( Object . values ( IndoorLegType ) ) ,
14- showIntermediateSteps : PropTypes . bool ,
15- bikePark : PropTypes . bool ,
16- carPark : PropTypes . bool ,
17- color : PropTypes . string ,
18- appendClass : PropTypes . string ,
19- icon : PropTypes . string ,
20- style : PropTypes . shape ( { } ) ,
21- isNotFirstLeg : PropTypes . bool ,
22- isStop : PropTypes . bool ,
23- indoorStepsLength : PropTypes . number ,
24- } ;
25-
26- static defaultProps = {
27- viaType : null ,
28- indoorLegType : IndoorLegType . NoStepsInside ,
29- showIntermediateSteps : false ,
30- color : null ,
31- bikePark : false ,
32- carPark : false ,
33- appendClass : undefined ,
34- icon : undefined ,
35- style : { } ,
36- isNotFirstLeg : undefined ,
37- isStop : false ,
38- indoorStepsLength : 0 ,
39- } ;
40-
41- isFirstChild = ( ) => {
42- return (
43- ! this . props . isNotFirstLeg && this . props . index === 0 && ! this . props . viaType
44- ) ;
45- } ;
46-
47- getMarker = top => {
48- if ( this . props . viaType === ViaLocationType . Visit && ! this . props . isStop ) {
8+ function ItineraryCircleLineWithIcon ( {
9+ index,
10+ modeClassName,
11+ viaType = null ,
12+ indoorLegType = IndoorLegType . NoStepsInside ,
13+ showIntermediateSteps = false ,
14+ bikePark = false ,
15+ carPark = false ,
16+ color = null ,
17+ appendClass,
18+ icon,
19+ style = { } ,
20+ isNotFirstLeg,
21+ isStop = false ,
22+ hasPreviousTransitLeg = false ,
23+ indoorStepsLength = 0 ,
24+ } ) {
25+ const getMarker = top => {
26+ if ( top && hasPreviousTransitLeg ) {
27+ return null ;
28+ }
29+ if ( viaType === ViaLocationType . Visit && ! isStop ) {
4930 return (
5031 < div className = "itinerary-icon-container" >
5132 < Icon img = "icon_mapMarker" className = "itinerary-icon via via-it" />
5233 </ div >
5334 ) ;
5435 }
55- if ( this . isFirstChild ( ) ) {
36+
37+ // Check if this is the first leg with no via point to show origin marker
38+ if ( ! isNotFirstLeg && index === 0 && ! viaType ) {
5639 return (
5740 < div className = "itinerary-icon-container start" >
5841 < Icon
@@ -62,117 +45,126 @@ class ItineraryCircleLineWithIcon extends React.Component {
6245 </ div >
6346 ) ;
6447 }
65- if ( this . props . bikePark ) {
48+ if ( bikePark ) {
6649 return (
6750 < div className = "itinerary-icon-container bike-park" >
6851 < Icon img = "icon-bike_parking" />
6952 </ div >
7053 ) ;
7154 }
72- if ( this . props . carPark ) {
55+ if ( carPark ) {
7356 return (
7457 < div className = "itinerary-icon-container car-park" >
7558 < Icon img = "icon_car-park" />
7659 </ div >
7760 ) ;
7861 }
79- if (
80- this . props . modeClassName === 'walk' ||
81- this . props . modeClassName === 'bicycle'
82- ) {
62+ if ( modeClassName === 'walk' || modeClassName === 'bicycle' ) {
8363 return null ;
8464 }
8565 return (
8666 < div
87- className = { `leg-before-circle circle ${ this . props . modeClassName } ${
67+ className = { `leg-before-circle circle ${ modeClassName } ${
8868 top ? 'top' : ''
8969 } `}
9070 >
9171 < svg
9272 xmlns = "http://www.w3.org/2000/svg"
9373 width = { 28 }
9474 height = { 28 }
95- style = { { fill : '#fff' , stroke : this . props . color } }
75+ style = { { fill : '#fff' , stroke : color } }
9676 >
9777 < circle strokeWidth = "4" width = { 28 } cx = { 11 } cy = { 10 } r = { 6 } />
9878 </ svg >
9979 </ div >
10080 ) ;
10181 } ;
10282
103- render ( ) {
104- const topMarker = this . getMarker ( true ) ;
105- const bottomMarker = this . getMarker ( false ) ;
106- const legBeforeLineStyle = { color : this . props . color , ...this . props . style } ;
107- let topBackgroundClass = '' ;
108- let bottomBackgroundClass = '' ;
109- if (
110- this . props . modeClassName === 'walk' ||
111- this . props . modeClassName === 'bicycle_walk'
112- ) {
113- switch ( this . props . indoorLegType ) {
114- case IndoorLegType . StepsAfterEntranceInside :
115- topBackgroundClass = 'default-dotted-line' ;
83+ const topMarker = getMarker ( true ) ;
84+ const bottomMarker = getMarker ( false ) ;
85+ const legBeforeLineStyle = { color, ...style } ;
86+ let topBackgroundClass = '' ;
87+ let bottomBackgroundClass = '' ;
88+ if ( modeClassName === 'walk' || modeClassName === 'bicycle_walk' ) {
89+ switch ( indoorLegType ) {
90+ case IndoorLegType . StepsAfterEntranceInside :
91+ topBackgroundClass = 'default-dotted-line' ;
92+ bottomBackgroundClass = 'indoor-dotted-line' ;
93+ break ;
94+ case IndoorLegType . StepsBeforeEntranceInside :
95+ if ( showIntermediateSteps ) {
96+ topBackgroundClass = 'indoor-dotted-line' ;
11697 bottomBackgroundClass = 'indoor-dotted-line' ;
117- break ;
118- case IndoorLegType . StepsBeforeEntranceInside :
119- if ( this . props . showIntermediateSteps ) {
120- topBackgroundClass = 'indoor-dotted-line' ;
121- bottomBackgroundClass = 'indoor-dotted-line' ;
122- } else {
123- topBackgroundClass = 'indoor-dotted-line' ;
124- bottomBackgroundClass = 'default-dotted-line' ;
125- }
126- break ;
127- default :
128- topBackgroundClass = 'default-dotted-line' ;
98+ } else {
99+ topBackgroundClass = 'indoor-dotted-line' ;
129100 bottomBackgroundClass = 'default-dotted-line' ;
130- }
101+ }
102+ break ;
103+ default :
104+ topBackgroundClass = 'default-dotted-line' ;
105+ bottomBackgroundClass = 'default-dotted-line' ;
131106 }
132- return (
133- < div
134- className = { cx ( 'leg-before' , this . props . modeClassName , {
135- via : ! ! this . props . viaType ,
136- indoor : this . props . indoorLegType !== IndoorLegType . NoStepsInside ,
137- 'has-indoor-steps' : this . props . indoorStepsLength !== 0 ,
138- 'only-one-step' : this . props . indoorStepsLength === 1 ,
139- 'first-leg' : this . props . index === 0 && ! this . props . isNotFirstLeg ,
140- } ) }
141- aria-hidden = "true"
142- >
143- { topMarker }
144-
145- < div
146- style = { legBeforeLineStyle }
147- className = { cx (
148- 'leg-before-line' ,
149- this . props . modeClassName ,
150- this . props . appendClass ,
151- topBackgroundClass ,
152- ) }
153- />
154- < RouteNumber
155- appendClass = { this . props . appendClass }
156- mode = { this . props . modeClassName }
157- icon = { this . props . icon }
158- vertical
159- />
160- < div
161- style = { legBeforeLineStyle }
162- className = { cx (
163- 'leg-before-line' ,
164- this . props . modeClassName ,
165- 'bottom' ,
166- this . props . appendClass ,
167- bottomBackgroundClass ,
168- ) }
169- />
170- { ( this . props . modeClassName === 'scooter' ||
171- this . props . modeClassName === 'taxi-external' ) &&
172- bottomMarker }
173- </ div >
174- ) ;
175107 }
108+ return (
109+ < div
110+ className = { cx ( 'leg-before' , modeClassName , {
111+ via : ! ! viaType ,
112+ indoor : indoorLegType !== IndoorLegType . NoStepsInside ,
113+ 'has-indoor-steps' : indoorStepsLength !== 0 ,
114+ 'only-one-step' : indoorStepsLength === 1 ,
115+ 'first-leg' : index === 0 && ! isNotFirstLeg ,
116+ } ) }
117+ aria-hidden = "true"
118+ >
119+ { topMarker }
120+
121+ < div
122+ style = { legBeforeLineStyle }
123+ className = { cx (
124+ 'leg-before-line' ,
125+ modeClassName ,
126+ appendClass ,
127+ topBackgroundClass ,
128+ ) }
129+ />
130+ < RouteNumber
131+ appendClass = { appendClass }
132+ mode = { modeClassName }
133+ icon = { icon }
134+ vertical
135+ />
136+ < div
137+ style = { legBeforeLineStyle }
138+ className = { cx (
139+ 'leg-before-line' ,
140+ modeClassName ,
141+ 'bottom' ,
142+ appendClass ,
143+ bottomBackgroundClass ,
144+ ) }
145+ />
146+ { ( modeClassName === 'scooter' || modeClassName === 'taxi-external' ) &&
147+ bottomMarker }
148+ </ div >
149+ ) ;
176150}
177151
152+ ItineraryCircleLineWithIcon . propTypes = {
153+ index : PropTypes . number . isRequired ,
154+ modeClassName : PropTypes . string . isRequired ,
155+ viaType : PropTypes . string ,
156+ indoorLegType : PropTypes . oneOf ( Object . values ( IndoorLegType ) ) ,
157+ showIntermediateSteps : PropTypes . bool ,
158+ bikePark : PropTypes . bool ,
159+ carPark : PropTypes . bool ,
160+ color : PropTypes . string ,
161+ appendClass : PropTypes . string ,
162+ icon : PropTypes . string ,
163+ style : PropTypes . shape ( { } ) ,
164+ isNotFirstLeg : PropTypes . bool ,
165+ isStop : PropTypes . bool ,
166+ hasPreviousTransitLeg : PropTypes . bool ,
167+ indoorStepsLength : PropTypes . number ,
168+ } ;
169+
178170export default ItineraryCircleLineWithIcon ;
0 commit comments