Skip to content

Commit 7b5e934

Browse files
Merge branch 'dev' into otp-ui-humanize-distance
2 parents 13cf9ea + 60b4d74 commit 7b5e934

File tree

4 files changed

+114
-34
lines changed

4 files changed

+114
-34
lines changed

lib/components/narrative/line-itin/connected-itinerary-body.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import PlaceName from '@opentripplanner/itinerary-body/lib/otp-react-redux/place
77
import RouteDescription from '@opentripplanner/itinerary-body/lib/otp-react-redux/route-description'
88
import React, { Component } from 'react'
99
import { connect } from 'react-redux'
10+
import styled from 'styled-components'
1011

1112
import { showLegDiagram } from '../../../actions/map'
1213
import { setActiveLeg } from '../../../actions/narrative'
@@ -17,6 +18,10 @@ import TripTools from '../trip-tools'
1718

1819
const noop = () => {}
1920

21+
const ItineraryBodyContainer = styled.div`
22+
padding: 20px 0px;
23+
`
24+
2025
class ConnectedItineraryBody extends Component {
2126
/** avoid rerendering if the itinerary to display hasn't changed */
2227
shouldComponentUpdate (nextProps, nextState) {
@@ -34,7 +39,7 @@ class ConnectedItineraryBody extends Component {
3439
} = this.props
3540

3641
return (
37-
<div className='itin-body'>
42+
<ItineraryBodyContainer>
3843
<ItineraryBody
3944
config={config}
4045
diagramVisible={diagramVisible}
@@ -57,7 +62,7 @@ class ConnectedItineraryBody extends Component {
5762
/>
5863
<TripDetails itinerary={itinerary} />
5964
<TripTools itinerary={itinerary} />
60-
</div>
65+
</ItineraryBodyContainer>
6166
)
6267
}
6368
}

lib/components/narrative/line-itin/itin-summary.js

Lines changed: 99 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,82 @@
1-
import React, { Component } from 'react'
1+
import coreUtils from '@opentripplanner/core-utils'
22
import PropTypes from 'prop-types'
3-
4-
import { calculateFares, calculatePhysicalActivity, getLegIcon, isTransit } from '../../../util/itinerary'
3+
import React, { Component } from 'react'
4+
import styled from 'styled-components'
5+
6+
import {
7+
calculateFares,
8+
calculatePhysicalActivity,
9+
getLegIcon,
10+
isTransit
11+
} from '../../../util/itinerary'
512
import { formatDuration, formatTime } from '../../../util/time'
613

714
// TODO: make this a prop
815
const defaultRouteColor = '#008'
916

17+
const Container = styled.div`
18+
display: ${() => coreUtils.ui.isMobile() ? 'table' : 'none'};
19+
height: 60px;
20+
margin-bottom: 15px;
21+
padding-right: 5px;
22+
width: 100%;
23+
`
24+
25+
const Detail = styled.div`
26+
color: #999999;
27+
font-size: 13px;
28+
`
29+
30+
const Details = styled.div`
31+
display: table-cell;
32+
vertical-align: top;
33+
`
34+
35+
const Header = styled.div`
36+
font-size: 18px;
37+
font-weight: bold;
38+
margin-top: -3px;
39+
`
40+
41+
const ModeIcon = styled.div`
42+
height: 30px;
43+
width: 30px;
44+
`
45+
46+
const NonTransitSpacer = styled.div`
47+
height: 30px;
48+
overflow: hidden
49+
`
50+
51+
const RoutePreivew = styled.div`
52+
display: inline-block;
53+
margin-left: 8px;
54+
vertical-align: top;
55+
`
56+
57+
const Routes = styled.div`
58+
display: table-cell;
59+
text-align: right;
60+
`
61+
62+
const ShortName = styled.div`
63+
background-color: ${props => getRouteColorForBadge(props.leg)};
64+
border-radius: 15px;
65+
border: 2px solid white;
66+
box-shadow: 0 0 0.5em #000;
67+
color: white;
68+
font-size: 15px;
69+
font-weight: 500;
70+
height: 30px;
71+
margin-top: 6px;
72+
overflow: hidden;
73+
padding-top: 4px;
74+
text-align: center;
75+
text-overflow: ellipsis;
76+
white-space: nowrap;
77+
width: 30px;
78+
`
79+
1080
export default class ItinerarySummary extends Component {
1181
static propTypes = {
1282
itinerary: PropTypes.object
@@ -31,52 +101,54 @@ export default class ItinerarySummary extends Component {
31101
const { caloriesBurned } = calculatePhysicalActivity(itinerary)
32102

33103
return (
34-
<div className='itin-summary' onClick={this._onSummaryClicked}>
35-
<div className='details'>
104+
<Container onClick={this._onSummaryClicked}>
105+
<Details>
36106
{/* Travel time in hrs/mins */}
37-
<div className='header'>{formatDuration(itinerary.duration)}</div>
107+
<Header>{formatDuration(itinerary.duration)}</Header>
38108

39109
{/* Duration as time range */}
40-
<div className='detail'>
110+
<Detail>
41111
{formatTime(itinerary.startTime, timeOptions)} - {formatTime(itinerary.endTime, timeOptions)}
42-
</div>
112+
</Detail>
43113

44114
{/* Fare / Calories */}
45-
<div className='detail'>
115+
<Detail>
46116
{minTotalFare > 0 && <span>
47117
{centsToString(minTotalFare)}
48118
{minTotalFare !== maxTotalFare && <span> - {centsToString(maxTotalFare)}</span>}
49119
<span> &bull; </span>
50120
</span>}
51121
{Math.round(caloriesBurned)} Cals
52-
</div>
122+
</Detail>
53123

54124
{/* Number of transfers, if applicable */}
55125
{itinerary.transfers > 0 && (
56-
<div className='detail'>
126+
<Detail>
57127
{itinerary.transfers} transfer{itinerary.transfers > 1 ? 's' : ''}
58-
</div>
128+
</Detail>
59129
)}
60130

61-
</div>
62-
<div className='routes'>
131+
</Details>
132+
<Routes>
63133
{itinerary.legs.filter(leg => {
64134
return !(leg.mode === 'WALK' && itinerary.transitTime > 0)
65135
}).map((leg, k) => {
66-
return <div className='route-preview' key={k}>
67-
<div className='mode-icon'>{getLegIcon(leg, customIcons)}</div>
68-
{isTransit(leg.mode)
69-
? (
70-
<div className='short-name' style={{ backgroundColor: getRouteColorForBadge(leg) }}>
71-
{getRouteNameForBadge(leg)}
72-
</div>
73-
)
74-
: (<div style={{ height: 30, overflow: 'hidden' }} />)
75-
}
76-
</div>
136+
return (
137+
<RoutePreivew key={k}>
138+
<ModeIcon>{getLegIcon(leg, customIcons)}</ModeIcon>
139+
{isTransit(leg.mode)
140+
? (
141+
<ShortName leg={leg} >
142+
{getRouteNameForBadge(leg)}
143+
</ShortName>
144+
)
145+
: (<NonTransitSpacer />)
146+
}
147+
</RoutePreivew>
148+
)
77149
})}
78-
</div>
79-
</div>
150+
</Routes>
151+
</Container>
80152
)
81153
}
82154
}

lib/components/narrative/line-itin/line-itinerary.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import React from 'react'
2+
import styled from 'styled-components'
23

4+
import ItineraryBody from './connected-itinerary-body'
5+
import ItinerarySummary from './itin-summary'
36
import NarrativeItinerary from '../narrative-itinerary'
47
import SimpleRealtimeAnnotation from '../simple-realtime-annotation'
58
import { getLegModeLabel, getTimeZoneOffset, isTransit } from '../../../util/itinerary'
69

7-
import ItinerarySummary from './itin-summary'
8-
import ItineraryBody from './connected-itinerary-body'
10+
export const LineItineraryContainer = styled.div`
11+
margin-bottom: 20px;
12+
`
913

1014
export default class LineItinerary extends NarrativeItinerary {
1115
_headerText () {
@@ -59,7 +63,7 @@ export default class LineItinerary extends NarrativeItinerary {
5963
}
6064

6165
return (
62-
<div className='line-itin'>
66+
<LineItineraryContainer>
6367
<ItinerarySummary
6468
companies={companies}
6569
itinerary={itinerary}
@@ -71,7 +75,7 @@ export default class LineItinerary extends NarrativeItinerary {
7175
? <ItineraryBody itinerary={itinerary} />
7276
: null}
7377
{itineraryFooter}
74-
</div>
78+
</LineItineraryContainer>
7579
)
7680
}
7781
}

lib/index.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
@import url(lib/components/form/form.css);
1212
@import url(lib/components/narrative/narrative.css);
1313
@import url(lib/components/narrative/default/itinerary.css);
14-
@import url(lib/components/narrative/line-itin/itinerary.css);
1514
@import url(lib/components/mobile/mobile.css);
1615
@import url(lib/components/viewers/viewers.css);
1716

0 commit comments

Comments
 (0)