Skip to content

Commit 6f3e720

Browse files
authored
Merge pull request #821 from opentripplanner/fix-operator-aria-label
Fix operator aria label
2 parents 4fca116 + fde9c63 commit 6f3e720

File tree

9 files changed

+32
-47
lines changed

9 files changed

+32
-47
lines changed

Diff for: __tests__/components/viewers/__snapshots__/stop-viewer.js.snap

-5
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ exports[`components > viewers > stop viewer should render countdown times after
448448
<div
449449
className="header-text"
450450
>
451-
<OperatorLogo />
452451
<h1
453452
style={
454453
Object {
@@ -3327,7 +3326,6 @@ exports[`components > viewers > stop viewer should render countdown times for st
33273326
<div
33283327
className="header-text"
33293328
>
3330-
<OperatorLogo />
33313329
<h1
33323330
style={
33333331
Object {
@@ -5239,7 +5237,6 @@ exports[`components > viewers > stop viewer should render times after midnight w
52395237
<div
52405238
className="header-text"
52415239
>
5242-
<OperatorLogo />
52435240
<h1
52445241
style={
52455242
Object {
@@ -8507,7 +8504,6 @@ exports[`components > viewers > stop viewer should render with OTP transit index
85078504
<div
85088505
className="header-text"
85098506
>
8510-
<OperatorLogo />
85118507
<h1
85128508
style={
85138509
Object {
@@ -15582,7 +15578,6 @@ exports[`components > viewers > stop viewer should render with TriMet transit in
1558215578
<div
1558315579
className="header-text"
1558415580
>
15585-
<OperatorLogo />
1558615581
<h1
1558715582
style={
1558815583
Object {

Diff for: i18n/en-US.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,6 @@ components:
369369
moreDetails: "More Details"
370370
stopsTo: "Towards"
371371
selectADirection: "Select a direction..."
372-
RouteRow:
373-
operatorLogoAltText: "logo for {operatorName}"
374-
operatorLogoAriaLabel: "{operatorName} stop:"
375372
# Used in both desktop and mobile
376373
RouteViewer:
377374
agencyFilter: Agency Filter
@@ -442,6 +439,7 @@ components:
442439
loadingText: Loading Stop...
443440
nextArrivals: Next Arrivals
444441
noStopsFound: No stop times found for date.
442+
operatorLogoAriaLabel: "{operatorName} stop:"
445443
schedule: Schedule
446444
timezoneWarning: "Departure times are shown in <strong>{timezoneCode}</strong>."
447445
titleBarStopId: "Stop {stopId}"

Diff for: i18n/es.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ components:
261261
header: Visor de paradas
262262
loadingText: Cargando la parada...
263263
noStopsFound: No se han encontrado tiempos de parada para la fecha.
264+
operatorLogoAriaLabel: "Parada de {operatorName}:"
264265
timezoneWarning: Las horas de salida se indican en <strong>{timezoneCode}</strong>.
265266
titleBarStopId: Parada {stopId}
266267
viewNextArrivals: Ver próximas llegadas
@@ -489,8 +490,6 @@ components:
489490
noTripFound: No se encontró ningún viaje
490491
tripsFound: Encontramos {count, plural, one {# opción} other {# opciones}}
491492
waiting: Espera...
492-
RouteRow:
493-
operatorLogoAltText: logotipo de {operatorName}
494493
SimpleRealtimeAnnotation:
495494
usingRealtimeInfo: Este viaje utiliza información de tráfico y retrasos en tiempo
496495
real

Diff for: i18n/fr.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ components:
360360
moreDetails: "Plus d'infos"
361361
stopsTo: "Direction"
362362
selectADirection: "Choisissez une direction..."
363-
RouteRow:
364-
operatorLogoAriaLabel: "{operatorName} stop:"
365-
operatorLogoAltText: "Logo de {operatorName}"
366363
# Used in both desktop and mobile
367364
RouteViewer:
368365
agencyFilter: Filtrer les transporteurs
@@ -434,6 +431,7 @@ components:
434431
loadingText: Chargement de l'arrêt...
435432
nextArrivals: Prochains passages
436433
noStopsFound: Aucun horaire pour la date choisie.
434+
operatorLogoAriaLabel: "Arrêt {operatorName} :"
437435
schedule: Horaires
438436
timezoneWarning: "Les horaires sont affichés dans le fuseau <strong>{timezoneCode}</strong>."
439437
titleBarStopId: "Arrêt {stopId}"

Diff for: i18n/ko.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ components:
237237
header: 정류장 뷰어
238238
loadingText: 로딩 중지…
239239
noStopsFound: 날짜에 대한 정지 시간이 없습니다.
240+
operatorLogoAriaLabel: "정류장 {operatorName}:"
240241
timezoneWarning: 출발 시간은 <strong>{timezoneCode}</strong> 로 표시됩니다.
241242
titleBarStopId: 정류장 {stopId}
242243
viewNextArrivals: 다음 도착 정보보기
@@ -476,8 +477,6 @@ components:
476477
RelatedPanel:
477478
hideExtraStops: 여분의 정지를 숨 깁니다
478479
showExtraStops: 추가 정거장 {count} 개를 보여줍니다
479-
RouteRow:
480-
operatorLogoAltText: '{operatorName} 심벌 마크'
481480
SimpleRealtimeAnnotation:
482481
usingRealtimeInfo: 이 여행은 실시간 트래픽과 지연 정보를 사용합니다
483482
StackedPaneDisplay:

Diff for: i18n/vi.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ components:
245245
header: Trình xem trạm dừng
246246
loadingText: Đang tải trạm dừng…
247247
noStopsFound: Không tìm thấy thời gian dừng cho ngày.
248+
operatorLogoAriaLabel: "Điểm dừng của {operatorName}:"
248249
timezoneWarning: Thời gian khởi hành được hiển thị trong <strong>{timezoneCode}</strong>.
249250
titleBarStopId: 'Điểm dừng {stopId}'
250251
viewNextArrivals: Xem những người đến tiếp theo
@@ -468,8 +469,6 @@ components:
468469
RelatedPanel:
469470
hideExtraStops: Ẩn các điểm trạm dừng thêm
470471
showExtraStops: Hiển thị thêm {count} trạm điểm dừng
471-
RouteRow:
472-
operatorLogoAltText: logo {operatorName}
473472
SavedTripEditor:
474473
editSavedTrip: Chỉnh sửa chuyến đi lưu
475474
saveNewTrip: Lưu chuyến đi mới

Diff for: i18n/zh.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ components:
259259
header: 车站查看器
260260
loadingText: 加载车站信息…
261261
noStopsFound: 未找到该日期的车站时间.
262+
operatorLogoAriaLabel: "公交车站 {operatorName}:"
262263
timezoneWarning: 出发时间以 <strong>{timezoneCode}</strong> 显示.
263264
titleBarStopId: 车站 {stopId}
264265
viewNextArrivals: 查看下一个公共交通到达
@@ -469,8 +470,6 @@ components:
469470
noTripFound: 没有找到旅行
470471
tripsFound: 我们发现了 {count} 选项
471472
waiting: 等待...
472-
RouteRow:
473-
operatorLogoAltText: '{operatorName} 标志'
474473
SavedTripScreen:
475474
tripNameAlreadyUsed: 另一个保存的旅行已经使用了这个名字. 请选择一个不同的名字.
476475
tripNameRequired: 请输入一个行程名称.

Diff for: lib/components/util/operator-logo.tsx

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { TransitOperator } from '@opentripplanner/types'
2-
import { useIntl } from 'react-intl'
32
import React from 'react'
43
import styled from 'styled-components'
54

@@ -8,31 +7,13 @@ const OperatorImg = styled.img`
87
`
98

109
type Props = {
10+
alt?: string
1111
operator?: TransitOperator
1212
}
1313

14-
const OperatorLogo = ({ operator }: Props): JSX.Element | null => {
15-
const intl = useIntl()
16-
14+
const OperatorLogo = ({ alt, operator }: Props): JSX.Element | null => {
1715
if (!operator?.logo) return null
18-
19-
return (
20-
<OperatorImg
21-
alt={intl.formatMessage(
22-
{
23-
id: 'components.RouteRow.operatorLogoAltText'
24-
},
25-
{ operatorName: operator.name }
26-
)}
27-
aria-label={intl.formatMessage(
28-
{
29-
id: 'components.RouteRow.operatorLogoAriaLabel'
30-
},
31-
{ operatorName: operator.name }
32-
)}
33-
src={operator.logo}
34-
/>
35-
)
16+
return <OperatorImg alt={alt || operator.name} src={operator.logo} />
3617
}
3718

3819
export default OperatorLogo

Diff for: lib/components/viewers/stop-viewer.js

+23-6
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,13 @@ class StopViewer extends Component {
191191
}
192192

193193
_renderHeader = (agencyCount) => {
194-
const { enableFavoriteStops, hideBackButton, showUserSettings, stopData } =
195-
this.props
194+
const {
195+
enableFavoriteStops,
196+
hideBackButton,
197+
intl,
198+
showUserSettings,
199+
stopData
200+
} = this.props
196201

197202
// We can use the first route, as this operator will only be used if there is only one operator
198203
const stationOperator = this.getOperator()
@@ -213,10 +218,22 @@ class StopViewer extends Component {
213218
{/* Header Text */}
214219
<div className="header-text">
215220
{stopData ? (
216-
<>
217-
{agencyCount <= 1 && <OperatorLogo operator={stationOperator} />}
218-
<h1 style={{ paddingLeft: '0.5ch' }}>{stopData.name}</h1>
219-
</>
221+
<h1 style={{ paddingLeft: '0.5ch' }}>
222+
{agencyCount <= 1 && stationOperator && (
223+
<OperatorLogo
224+
alt={intl.formatMessage(
225+
{
226+
id: 'components.StopViewer.operatorLogoAriaLabel'
227+
},
228+
{
229+
operatorName: stationOperator.name
230+
}
231+
)}
232+
operator={stationOperator}
233+
/>
234+
)}
235+
{stopData.name}
236+
</h1>
220237
) : (
221238
<h1>
222239
<FormattedMessage id="components.StopViewer.loadingText" />

0 commit comments

Comments
 (0)