{/* Header Block */}
@@ -63,199 +180,140 @@ class RouteViewer extends Component {
{/* Back button */}
{!hideBackButton && (
-
+
)}
{/* Header Text */}
- {languageConfig.routeViewer || 'Route Viewer'}
+
-
- {languageConfig.routeViewerDetails}
+
+
-
+
- {sortedRoutes
- .map(route => {
- // Find operator based on agency_id (extracted from OTP route ID).
- const operator = coreUtils.route.getTransitOperatorFromOtpRoute(
+ {sortedRoutes.map((route) => {
+ // Find operator based on agency_id (extracted from OTP route ID).
+ const operator =
+ coreUtils.route.getTransitOperatorFromOtpRoute(
route,
transitOperators
) || {}
- return (
-
- )
- })
- }
+ return (
+
+ )
+ })}
+ {/* check modes length to differentiate between loading and over-filtered */}
+ {modes.length > 0 && sortedRoutes.length === 0 && (
+
+
+
+ )}
)
}
}
-const StyledRouteRow = styled.div`
- background-color: ${props => props.isActive ? '#f6f8fa' : 'white'};
- border-bottom: 1px solid gray;
-`
-
-const RouteRowButton = styled(Button)`
- align-items: center;
- display: flex;
- padding: 6px;
- width: 100%;
-`
-
-const RouteRowElement = styled.span`
-`
-
-const OperatorImg = styled.img`
- height: 25px;
- margin-right: 8px;
-`
-
-const ModeIconElement = styled.span`
- display: inline-block;
- vertical-align: bottom;
- height: 22px;
-`
-
-const RouteNameElement = styled(Label)`
- background-color: ${props => (
- props.backgroundColor === '#ffffff' || props.backgroundColor === 'white'
- ? 'rgba(0,0,0,0)'
- : props.backgroundColor
- )};
- color: ${props => props.color};
- flex: 0 1 auto;
- font-size: medium;
- font-weight: 400;
- margin-left: ${props => (
- props.backgroundColor === '#ffffff' || props.backgroundColor === 'white'
- ? 0
- : '8px'
- )};
- margin-top: 2px;
- overflow: hidden;
- text-overflow: ellipsis;
-`
-
-const RouteDetails = styled.div`
- padding: 8px;
-`
-
-class RouteRow extends PureComponent {
- static contextType = ComponentContext
-
- _onClick = () => {
- const { findRoute, isActive, route, setViewedRoute } = this.props
- if (isActive) {
- // Deselect current route if active.
- setViewedRoute({ routeId: null })
- } else {
- // Otherwise, set active and fetch route patterns.
- findRoute({ routeId: route.id })
- setViewedRoute({ routeId: route.id })
- }
- }
-
- getCleanRouteLongName ({ longNameSplitter, route }) {
- let longName = ''
- if (route.longName) {
- // Attempt to split route name if splitter is defined for operator (to
- // remove short name value from start of long name value).
- const nameParts = route.longName.split(longNameSplitter)
- longName = (longNameSplitter && nameParts.length > 1)
- ? nameParts[1]
- : route.longName
- // If long name and short name are identical, set long name to be an empty
- // string.
- if (longName === route.shortName) longName = ''
- }
- return longName
- }
-
- render () {
- const { isActive, operator, route } = this.props
- const { ModeIcon } = this.context
-
- const {defaultRouteColor, defaultRouteTextColor, longNameSplitter} = operator || {}
- const backgroundColor = `#${defaultRouteColor || route.color || 'ffffff'}`
- // NOTE: text color is not a part of short response route object, so there
- // is no way to determine from OTP what the text color should be if the
- // background color is, say, black. Instead, determine the appropriate
- // contrast color and use that if no text color is available.
- const contrastColor = getContrastYIQ(backgroundColor)
- const color = `#${defaultRouteTextColor || route.textColor || contrastColor}`
- // Default long name is empty string (long name is an optional GTFS value).
- const longName = this.getCleanRouteLongName({ longNameSplitter, route })
- return (
-