Skip to content

Commit 60de4ff

Browse files
Merge branch 'dev' into a11y-work-regression-repair
2 parents 157b346 + 8c5939e commit 60de4ff

File tree

7 files changed

+57
-28
lines changed

7 files changed

+57
-28
lines changed

Diff for: .github/workflows/codespell.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
# skip git, yarn, pixel test script, and all i18n resources.
1616
# Also, the a11y test file has a false positive and the ignore list does not work
1717
# see https://github.com/opentripplanner/otp-react-redux/pull/436/checks?check_run_id=3369380014
18-
skip: ./.git,yarn.lock,./a11y/a11y.test.js,./percy/percy.test.js,./i18n
18+
skip: ./.git,yarn.lock,./a11y/a11y.test.js,./a11y/mocks,./percy/percy.test.js,./i18n

Diff for: i18n/en-US.yml

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ components:
236236
fromStop: "from {stop}"
237237
itineraryDescription: "{time} itinerary using {routes}"
238238
leaveAt: You leave
239+
originallyScheduledTime: (originally {originalTime})
239240
multipleOptions: Multiple Options
240241
orAlternatives: or other routes in the same direction
241242
singleModeItineraryDescription: "{time} {mode} itinerary"

Diff for: i18n/es.yml

-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ components:
466466
setDestination: Marcar el destino
467467
setOrigin: Establecer origen
468468
MetroUI:
469-
arriveAtTime: Llegar a {time}
470469
fromStop: de {stop}
471470
itineraryDescription: '{time} itinerario en {routes}'
472471
leaveAt: Partir a

Diff for: i18n/fr.yml

-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ components:
232232
stops: Arrêts et stations
233233
streets: Plan des rues
234234
MetroUI:
235-
arriveAtTime: "Arrivée à {time}"
236235
fromStop: "de {stop}"
237236
itineraryDescription: "Trajet de {time} par les lignes {routes}"
238237
leaveAt: Partez à

Diff for: lib/components/narrative/metro/departure-times-list.tsx

+19-23
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import { Itinerary, Leg } from '@opentripplanner/types'
33
import React from 'react'
44

55
import { firstTransitLegIsRealtime } from '../../../util/viewer'
6-
import {
7-
getFirstLegStartTime,
8-
getLastLegEndTime
9-
} from '../../../util/itinerary'
6+
import { getDepartureLabelText } from '../utils'
7+
import { getFirstLegStartTime } from '../../../util/itinerary'
108

119
type DepartureTimesProps = {
1210
activeItineraryTimeIndex?: number
@@ -23,18 +21,17 @@ export const DepartureTimesList = (props: DepartureTimesProps): JSX.Element => {
2321
const { activeItineraryTimeIndex, itinerary, setItineraryTimeIndex } = props
2422
const intl = useIntl()
2523
const isRealTime = firstTransitLegIsRealtime(itinerary)
24+
const itineraryButtonLabel = getDepartureLabelText(
25+
intl,
26+
itinerary.startTime,
27+
isRealTime
28+
)
2629
if (!itinerary.allStartTimes) {
2730
return (
2831
<button
32+
aria-label={itineraryButtonLabel}
2933
className={isRealTime ? 'realtime active' : 'active'}
30-
title={`${intl.formatMessage(
31-
{ id: 'components.MetroUI.arriveAtTime' },
32-
{ time: intl.formatTime(itinerary.endTime) }
33-
)} ${
34-
isRealTime
35-
? intl.formatMessage({ id: 'components.StopTimeCell.realtime' })
36-
: ''
37-
}`}
34+
title={itineraryButtonLabel}
3835
>
3936
<FormattedTime value={itinerary.startTime} />
4037
</button>
@@ -49,23 +46,22 @@ export const DepartureTimesList = (props: DepartureTimesProps): JSX.Element => {
4946
<FormattedList
5047
type="disjunction"
5148
value={allStartTimes.map((time, index) => {
49+
const { legs, realtime } = time
5250
const classNames = []
53-
if (time.realtime) classNames.push('realtime')
51+
if (realtime) classNames.push('realtime')
5452
if (index === (activeItineraryTimeIndex || 0)) classNames.push('active')
55-
53+
const singleItinLabel = getDepartureLabelText(
54+
intl,
55+
getFirstLegStartTime(legs),
56+
realtime
57+
)
5658
return (
5759
<button
60+
aria-label={singleItinLabel}
5861
className={classNames.join(' ')}
59-
key={getFirstLegStartTime(time.legs)}
62+
key={getFirstLegStartTime(legs)}
6063
onClick={() => setItineraryTimeIndex(index)}
61-
title={`${intl.formatMessage(
62-
{ id: 'components.MetroUI.arriveAtTime' },
63-
{ time: intl.formatTime(getLastLegEndTime(time.legs)) }
64-
)} ${
65-
time.realtime
66-
? intl.formatMessage({ id: 'components.StopTimeCell.realtime' })
67-
: ''
68-
}`}
64+
title={singleItinLabel}
6965
>
7066
<FormattedTime value={getFirstLegStartTime(time.legs)} />
7167
</button>

Diff for: lib/components/narrative/utils.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,24 @@ export function localizeGradationMap(
4242
})
4343
return newGradationMap
4444
}
45+
46+
/**
47+
* Takes the itinerary start time and returns a label for button title and
48+
* screen readers that indicates whether the departure time is based on realtime
49+
* or scheduled data.
50+
* @param intl React-Intl object
51+
* @param time Itinerary start time
52+
* @param realTime Whether the itinerary is based on realtime data
53+
* @returns string with time and realtime/schedule status
54+
*/
55+
export const getDepartureLabelText = (
56+
intl: IntlShape,
57+
time: any,
58+
realTime: boolean
59+
): string => {
60+
return `${intl.formatTime(time)} ${
61+
realTime
62+
? `(${intl.formatMessage({ id: 'components.StopTimeCell.realtime' })})`
63+
: `(${intl.formatMessage({ id: 'components.StopTimeCell.scheduled' })})`
64+
}`
65+
}

Diff for: lib/components/viewers/realtime-status-label.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
22
// Typescript TODO: Waiting on viewer.js being typed
33
import { connect } from 'react-redux'
4-
import { FormattedTime } from 'react-intl'
4+
import { FormattedMessage, FormattedTime } from 'react-intl'
55
import React from 'react'
66
import styled from 'styled-components'
77

88
import { getTripStatus, REALTIME_STATUS } from '../../util/viewer'
9+
import { InvisibleAdditionalDetails } from '@opentripplanner/itinerary-body/lib/styled'
910
import FormattedDuration from '../util/formatted-duration'
1011
import FormattedRealtimeStatusLabel from '../util/formatted-realtime-status-label'
1112

@@ -96,7 +97,7 @@ const RealtimeStatusLabel = ({
9697
// and display the updated time underneath.
9798
renderedTime = isEarlyOrLate ? (
9899
<TimeBlock>
99-
<TimeStruck>
100+
<TimeStruck aria-hidden>
100101
<FormattedTime timeStyle="short" value={originalTime} />
101102
</TimeStruck>
102103
<div>
@@ -133,6 +134,18 @@ const RealtimeStatusLabel = ({
133134
// @ts-ignore getTripStatus is not typed yet
134135
status={STATUS[status].label}
135136
/>
137+
{isEarlyOrLate && (
138+
<InvisibleAdditionalDetails>
139+
<FormattedMessage
140+
id="components.MetroUI.originallyScheduledTime"
141+
values={{
142+
originalTime: (
143+
<FormattedTime timeStyle="short" value={originalTime} />
144+
)
145+
}}
146+
/>
147+
</InvisibleAdditionalDetails>
148+
)}
136149
</MainContent>
137150
</Container>
138151
)

0 commit comments

Comments
 (0)