Skip to content

Commit

Permalink
Merge pull request #1283 from opentripplanner/respect-mode-text-color
Browse files Browse the repository at this point in the history
respect mode text color
  • Loading branch information
miles-grant-ibigroup authored Nov 5, 2024
2 parents ea5c106 + d471628 commit 17eee37
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
27 changes: 19 additions & 8 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import {
getRouteColorBasedOnSettings,
getRouteIdForPattern,
getRouteTextColorBasedOnSettings,
routeIsValid
} from '../util/viewer'
import { isLastStop } from '../util/stop-times'
Expand Down Expand Up @@ -1130,20 +1131,30 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
...itin,
legs: itin.legs
?.map((leg) => {
const routeOperator = getRouteOperator(
{
agencyId: leg?.agency?.id,
id: leg?.route?.id
},
config.transitOperators
)
const routeProperties = {
color: leg?.route?.color,
mode: leg.mode
}

return {
...leg,
origColor: leg?.route?.color,
route: {
...leg.route,
color: getRouteColorBasedOnSettings(
getRouteOperator(
{
agencyId: leg?.agency?.id,
id: leg?.route?.id
},
config.transitOperators
),
{ color: leg?.route?.color, mode: leg.mode }
routeOperator,
routeProperties
).split('#')?.[1],
textColor: getRouteTextColorBasedOnSettings(
routeOperator,
routeProperties
).split('#')?.[1]
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/util/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ export function getRouteColorBasedOnSettings(operator = {}, route = {}) {
return backgroundColor
}
}
export function getRouteTextColorBasedOnSettings(operator = {}, route = {}) {
const { color } = getColorAndNameFromRoute(operator, route)
return color
}

/**
* Helper method to determine if a stop being viewed is a flex stop. This is not marked by
Expand Down

0 comments on commit 17eee37

Please sign in to comment.