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

feat: Link bus tooltip to line profile #463

Merged

Conversation

YuvalMasada
Copy link
Collaborator

Added Router's Link as line name to the Maps' tooltip.
The Link sends you the the line profile page.
@NoamGaash

Copy link
Member

@NoamGaash NoamGaash left a comment

Choose a reason for hiding this comment

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

thanks!
see suggestion

src/pages/components/map-related/MapLayers/BusToolTip.tsx Outdated Show resolved Hide resolved
@@ -39,7 +47,7 @@ export function BusToolTip({ position, icon }: BusToolTipProps) {
<>
<header className="header">
<h1 className="title">
{t('line')} :<span>{siriRide && siriRide.gtfsRouteRouteShortName}</span>
{t('line')} :<span>{LinkToProfile}</span>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{t('line')} :<span>{LinkToProfile}</span>
{t('line')} :<span>
<Link to={`/profile/${siriRide.gtfsRouteRouteShortName}`}>
{siriRide && siriRide.gtfsRouteRouteShortName}{' '}
</Link>
</span>

isn't it easier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What if the siriRide is undefined?
I think that at some point of the renders it doesn't got any properties or even a value.
I can take care of the null/undefined scenario when using the Link component in an inline JSX, but I personally just like it less & have no problem to follow the project standard style.

Copy link
Member

Choose a reason for hiding this comment

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

What about turning it into a component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that This is a good choice. I'll add it as a local Component.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, if the siriRide is undefined, we should probably hide the entire page. Don't you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes there is no reason to show the tooltip without data. In the case I'll return NULL then there will be a white line which is the leaflet popup wrapper. So in a future issue it might be a nice to deal with it. For now it should be a good solution.

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be for the best if you'll place the link inline, and the nullish logic will be handled in outer scope

@NoamGaash
Copy link
Member

(accepted with suggestion - that's a great PR, thanks for the contribution, feel free to merge it with or without the suggestion. you're great, thank you)

{t('line')} :<span>{siriRide && siriRide.gtfsRouteRouteShortName}</span>
{t('line')} :
<span>
{siriRide ? (
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{siriRide ? (

now this check isn't needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I left it like this because the whole file is written in this style, but maybe I'll remove it from the whole file since it's not needed inside the returned JSX. sounds good?

Copy link
Member

Choose a reason for hiding this comment

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

sounds great! let's keep things minimal wherever it's possible

Copy link
Member

Choose a reason for hiding this comment

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

(feel free to hit the merge button if you want to)

@YuvalMasada
Copy link
Collaborator Author

I have removed redundant checks.

Copy link
Member

@NoamGaash NoamGaash left a comment

Choose a reason for hiding this comment

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

💯

@YuvalMasada
Copy link
Collaborator Author

Is there something else from my side? From what I understand only repository owners can merge to the main branch. right, or should I do something else?

@NoamGaash
Copy link
Member

you're right, I thought you already have permission
image

@NoamGaash NoamGaash merged commit 02bb9c1 into hasadna:main Feb 13, 2024
17 checks passed
@NoamGaash NoamGaash linked an issue Feb 15, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link bus tooltips to line profile page
2 participants