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 warnings #324

Merged
merged 11 commits into from
Apr 30, 2024
Merged

fix warnings #324

merged 11 commits into from
Apr 30, 2024

Conversation

abhumbla
Copy link
Contributor

got sloppy in #314

@abhumbla abhumbla requested a review from arindam1993 April 18, 2024 03:47
@graue
Copy link
Contributor

graue commented Apr 18, 2024

This feature is looking great!

Can you fix the other unaddressed comments in #314 as well, including

  • avoid using <IconSvg ... onClick>: wrap in button
  • move viewingLeg state to <Itinerary>
  • localize the "via [street or streets]" string (again, see the via string for modes for an example)
  • don't hide short bike legs from the itinerary

Example of where hiding short bike legs is problematic: it makes it hard to figure out the 48/44 transfer.

image

image

route

@abhumbla
Copy link
Contributor Author

  • avoid using <IconSvg ... onClick>: wrap in button

this is the only suggestion im not taking, BorderlessButton breaks styling. im using <div onClick={...}> instead

@graue
Copy link
Contributor

graue commented Apr 19, 2024

How does it break styling? I'm sure there's a way to make it work. Maybe BorderlessButton needs to be improved to reset something else.

Our coding conventions say:

  • Don't make random elements like a div or span or icon clickable. Use a <button> so there's good keyboard, accessibility, and cursor support. Use <BorderlessButton> utility class to reset the button styling when needed.

@graue
Copy link
Contributor

graue commented Apr 19, 2024

Also this comment from the original PR was not addressed in the way I intended:

Can we keep the textual descriptions of individual modes (bus vs train, etc) as an additional reminder in case you don't see the icon, and also for accessibility since the info is only otherwise presented visually?

You added the mode name to the message description (seen by translators) but not to the actual message (in the UI). There's no reason to do this. Restoring the previous messages like "Ride the $LINE ferry ($OPERATOR)", "Ride the $LINE train ($OPERATOR)", etc., would address my comment.

@abhumbla
Copy link
Contributor Author

There's no reason to do this.

i think take the BART train looks ridiculous. for people that can see the icon that's enough, the mode is there in the description for people with vision impairments

@graue
Copy link
Contributor

graue commented Apr 19, 2024

Ah, I see the confusion. That's not what that description does. It's not alt text. It's a description for the translator, because they'll see the string out of context, and sometimes the same string translates differently depending on context. (For example, is "Stop" a verb or a noun?)

Personally, I don't think the icons are super clear and like having the redundancy. But if we're getting rid of the text, then the fix is to add a label for the icon. This might take a bit of refactoring because the natural place to select the label is in ModeIcon along with the icon selection, but it returns an SVG instance, not an Icon, where the label is usually attached. But it might be fine to set the aria-label on an SVG. You can right-click "Inspect Accessibility Properties" in Firefox to see if it works.

i think take the BART train looks ridiculous

For what it's worth, it would actually look like Take the Yellow-N train (BART).

@graue
Copy link
Contributor

graue commented Apr 19, 2024

Hmm the itinerary no longer shows the name/number of the line either. Like I have no idea which Muni bus to board. I think this is a bigger problem

image

@abhumbla
Copy link
Contributor Author

Hmm the itinerary no longer shows the name/number of the line either

good call, fixed

Screenshot 2024-04-19 at 12 25 33 AM


function alertSummary(alertBody) {
return alertBody.slice(0, 40) + '...';
return alertBody.slice(0, ALERT_SUMMARY_LENGTH) + '...';
Copy link
Contributor

Choose a reason for hiding this comment

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

You might get more consistent results by instead using CSS to set the size (number of lines) you want to show along with overflow: hidden and text-overflow: ellipsis

<FormattedMessage
defaultMessage="via {streets}"
description="list of major streets taken on bike leg"
values={{ streets: majorStreets.join(', ') }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all languages use commas for punctuation so use intl.formatList for this part. There's an example in Itinerary.jsx.

<span className="ItineraryHeader_alertHeader">
{alertHeader}
</span>
<div />
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this for?

@@ -148,7 +157,7 @@ export default function ItineraryTransitLeg({
</ItineraryStep>
))}
</div>
) : (
) : stops.length > 2 ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

A few lines below this there's a test for stopsBetweenStartAndEnd > 0 which seems equivalent. Is this redundant?

} else {
return { ...state, viewingLeg: action.leg };
}
return { ...state, viewingDetails: false, viewingLeg: null };
Copy link
Contributor

Choose a reason for hiding this comment

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

viewingLeg is no longer used

Comment on lines 42 to 59
case MODES.TRAM_STREETCAR_LIGHT_RAIL:
return 'tram/streetcar/light rail';
case MODES.MONORAIL:
return 'monorail';
case MODES.SUBWAY_METRO:
return 'subway/metro';
case MODES.RAIL_INTERCITY_LONG_DISTANCE:
return 'intercity/long-distance rail';
case MODES.BUS:
case MODES.TROLLEYBUS:
return 'bus';
case MODES.FERRY:
return 'ferry';
case MODES.CABLE_TRAM:
case MODES.AERIAL_TRAM_SUSPENDED_CABLE_CAR:
return 'cable tram/cable car/aerial tram/suspended cable car';
case MODES.FUNICULAR:
return 'funicular';
Copy link
Contributor

Choose a reason for hiding this comment

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

These need to be localized (which means the strings need to be in a React component, for access to intl).

Also, all the slashes make it quite wordy. How about plain English? You can provide more detail to the translator in the description.

}

function quartileStreets(streets, q) {
async function quartileStreets(streets, q) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't seem to do anything as there is no asynchronous stuff in the function body

if (isOnlyLeg) {
onToggleLegExpand(idx);
if (isOnlyLeg && expandedLeg !== idx) {
setExpandedLeg(idx);
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't work because React doesn't allow you to set state at render time.

If you really want to do it this way, you can use the useEffect hook to set the state in response to the legs prop changing. However, it would be cleaner and avoid an unnecessary render to incorporate this into the render logic: <ItineraryBikeLeg expanded={isOnlyLeg || expandedLeg === idx}>

@graue graue merged commit 7207a3b into main Apr 30, 2024
2 checks passed
@graue graue deleted the fix-warnings branch April 30, 2024 04:56
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.

2 participants