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

Wheelchair accessible labeling #675

Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/itinerary-body/i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ otpUi:
car: by car
escooter: by e-scooter
walk: by walking
tripAccessibility:
accessible: accessible
amy-corson-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
inaccessible: inaccessible
itineraryAccessibility: "Wheelchair accessibility of this trip: "
legAccessibility: "Wheelchair accessibility of this trip leg: "
likelyAccessible: likely accessible
unclear: unknown
viewOnMap: View on map
TransitLegBody:
AlertsBody:
Expand Down
43 changes: 38 additions & 5 deletions packages/itinerary-body/src/ItineraryBody/accessibility-rating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { GradationMap } from "@opentripplanner/types";
import React, { ReactElement } from "react";
import styled from "styled-components";
import { Wheelchair } from "@styled-icons/foundation/Wheelchair";
import { useIntl } from "react-intl";
import { InvisibleAdditionalDetails } from "../styled";

interface WrapperProps {
border: boolean;
Expand Down Expand Up @@ -40,6 +42,7 @@ interface Props {
gradationMap?: GradationMap;
grayscale?: boolean;
large?: boolean;
leg?: boolean;
amy-corson-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
score: number;
}

Expand All @@ -51,16 +54,33 @@ const AccessibilityRating = ({
gradationMap,
grayscale = false,
large = false,
leg = false,
score
}: Props): ReactElement => {
const intl = useIntl();
// Provide default mapping
const mapping = gradationMap || {
0.0: { color: "#ffe4e5", text: "❌" },
0.0: {
color: "#ffe4e5",
icon: "❌",
text: intl.formatMessage({
id: `otpUi.ItineraryBody.tripAccessibility.tripIsInaccessible`
})
},
0.5: {
color: "#dbe9ff",
text: "?"
icon: "?",
text: intl.formatMessage({
id: `otpUi.ItineraryBody.tripAccessibility.tripAccessibilityUnclear`
})
},
0.9: { color: "#bfffb5", text: "✅" }
0.9: {
color: "#bfffb5",
icon: "✅",
text: intl.formatMessage({
id: `otpUi.ItineraryBody.tripAccessibility.tripIsLikelyAccessible`
})
}
};

// Find the highest (including equality) key for our score.
Expand All @@ -75,15 +95,28 @@ const AccessibilityRating = ({
// External configuration may report "0.0" as 0, so include fallback
const mapped = mapping[mappedKey] || mapping[0.0];

const accessibilityPreface = intl.formatMessage({
id: `otpUi.ItineraryBody.tripAccessibility.${
leg ? "legAccessibility" : "itineraryAccessibility"
}`
});

const accessibilityScore = mapped.text;

const accessibilityLabel = accessibilityPreface + accessibilityScore;

return (
<Wrapper
border={grayscale}
color={grayscale ? "transparent" : mapped.color}
large={large}
title={mapped.text}
title={accessibilityLabel}
>
<InvisibleAdditionalDetails>
{accessibilityLabel}
</InvisibleAdditionalDetails>
<Wheelchair style={{ flex: "2", height: "100%", minWidth: "20px" }} />
<StatusWrapper>
<StatusWrapper aria-hidden>
{/* Show either icon or text if no icon given */}
{mapped.icon || <TextWrapper>{mapped.text}</TextWrapper>}
</StatusWrapper>
Expand Down
2 changes: 2 additions & 0 deletions packages/itinerary-body/src/ItineraryBody/place-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ export default function PlaceRow({
{/* Custom rendering of the departure/arrival time of the specified leg. */}
<TimeColumnContent isDestination={isDestination} leg={leg} />
{!isDestination && leg.accessibilityScore && (
// TODO: Reorder markup so accessibility info doesn't fall between time and destination.
<AccessibilityRating
gradationMap={accessibilityScoreGradationMap}
leg
score={leg.accessibilityScore}
/>
)}
Expand Down
Loading