Skip to content
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

Merged
merged 11 commits into from
Feb 5, 2020
Merged

Fix route sort, color issues #123

merged 11 commits into from
Feb 5, 2020

Conversation

landonreed
Copy link
Member

@landonreed landonreed commented Jan 28, 2020

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:

image

This fix uses a utility function (which should move to otp-ui soon) to identify the right contrasting color for a given bg color.

// 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove console.log

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.
Copy link
Contributor

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.

Copy link
Collaborator

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?

Copy link
Contributor

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:

{// 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} />
}

Copy link
Member Author

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:

const agencySortedRoutes = operators.length > 0
? sortedRoutes.sort((a, b) => {
return operatorIndexForRoute(operators, a) - operatorIndexForRoute(operators, b)
})
: sortedRoutes

@codecov-io
Copy link

codecov-io commented Jan 28, 2020

Codecov Report

Merging #123 into dev will increase coverage by 0.03%.
The diff coverage is 9.09%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/components/viewers/route-viewer.js 0% <0%> (ø) ⬆️
lib/util/itinerary.js 16.96% <100%> (+1.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 906d922...b940040. Read the comment docs.

Copy link
Contributor

@evansiroky evansiroky left a 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.

@evansiroky evansiroky merged commit 1c0022a into dev Feb 5, 2020
@evansiroky evansiroky deleted the fix-route-order branch February 5, 2020 19:35
@landonreed landonreed mentioned this pull request Feb 13, 2020
@evansiroky
Copy link
Contributor

🎉 This PR is included in version 0.13.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@evansiroky evansiroky added the ported-to-otp-ui Indicates whether changes made to the maintenance branch have been ported to otp-ui label Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ported-to-otp-ui Indicates whether changes made to the maintenance branch have been ported to otp-ui released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants