-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix route sort, color issues #123
Conversation
// contrast color and use that if no text color is available. | ||
const contrastColor = getContrastYIQ(backgroundColor) | ||
const color = `#${defaultRouteTextColor || route.textColor || contrastColor}` | ||
console.log(route, color, backgroundColor, contrastColor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove console.log
lib/util/itinerary.js
Outdated
aComp = a.sortOrder | ||
bComp = b.sortOrder | ||
} else if (!isNaN(parseInt(a.shortName)) && !isNaN(parseInt(b.shortName))) { | ||
// Otherwise, if both short names can be parsed as integers, use these | ||
// numbers for sorting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a chance that two routes could have the exact same number value for shortName. In that case, I think it would make sense to defer to sorting based off of shortName/longName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The viewer doesn't distinguish by agency, does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binh-dam-ibigroup, it used to, but it's been commented out:
otp-react-redux/lib/components/viewers/route-viewer.js
Lines 135 to 140 in 1210661
{// TODO: re-implement multi-agency logos for route viewer. | |
// Currently, the agency object is not nested within the get all | |
// routes endpoint and causing this to only display operators for | |
// the selected route. | |
// operator && <img src={operator.logo} style={{marginRight: '5px'}} height={25} /> | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binh-dam-ibigroup, it does handle agencies:
otp-react-redux/lib/components/viewers/route-viewer.js
Lines 61 to 65 in 12d9034
const agencySortedRoutes = operators.length > 0 | |
? sortedRoutes.sort((a, b) => { | |
return operatorIndexForRoute(operators, a) - operatorIndexForRoute(operators, b) | |
}) | |
: sortedRoutes |
Codecov Report
@@ Coverage Diff @@
## dev #123 +/- ##
==========================================
+ Coverage 10.62% 10.65% +0.03%
==========================================
Files 133 133
Lines 6081 6090 +9
Branches 1756 1758 +2
==========================================
+ Hits 646 649 +3
- Misses 4613 4618 +5
- Partials 822 823 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my two comments.
rename some functions, use consistent arguments and allow disabling integer route short name sorting
Make route comparator tolerate all kinds of data
🎉 This PR is included in version 0.13.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR fixes the route sort order issue in #122.
It also addresses some issues with route text color found with SEPTA. When viewing the route viewer (link), the route text color is not available to render the route label because it is not included in the OTP short response for route. See image with issue:
This fix uses a utility function (which should move to otp-ui soon) to identify the right contrasting color for a given bg color.