11import { connect } from 'react-redux'
22import { FormattedMessage , useIntl } from 'react-intl'
3- import { MapPin } from '@styled-icons/fa-solid'
43import { Search } from '@styled-icons/fa-solid/Search'
54import { TransitOperator } from '@opentripplanner/types'
65import React , { ComponentType } from 'react'
@@ -10,8 +9,8 @@ import { Icon, IconWithText } from '../../util/styledIcon'
109import { StopData } from '../../util/types'
1110import InvisibleA11yLabel from '../../util/invisible-a11y-label'
1211import Link from '../../util/link'
13- import OperatorLogo from '../../util/operator-logo'
1412import Strong from '../../util/strong-text'
13+ import TransitOperatorLogos from '../../util/transit-operator-icons'
1514
1615import { CardBody , CardHeader , CardTitle } from './styled'
1716import DistanceDisplay from './distance-display'
@@ -28,41 +27,6 @@ type Props = {
2827 transitOperators ?: TransitOperator [ ]
2928}
3029
31- const Operator = ( { operator } : { operator ?: TransitOperator } ) => {
32- const intl = useIntl ( )
33- if ( ! operator ) {
34- return null
35- } else {
36- const operatorLogoAriaLabel = intl . formatMessage (
37- {
38- id : 'components.StopViewer.operatorLogoAriaLabel'
39- } ,
40- {
41- operatorName : operator . name
42- }
43- )
44- return operator . logo ? (
45- // Span with agency classname allows optional contrast/customization in user
46- // config for logos with poor contrast. Class name is hyphenated agency name
47- // e.g. "sound-transit"
48- < span
49- className = {
50- operator . name ? operator . name . replace ( / \s + / g, '-' ) . toLowerCase ( ) : ''
51- }
52- >
53- < OperatorLogo alt = { operatorLogoAriaLabel } operator = { operator } />
54- </ span >
55- ) : (
56- // If operator exists but logo is missing,
57- // we still need to announce the operator name to screen readers.
58- < >
59- < MapPin />
60- < InvisibleA11yLabel > { operatorLogoAriaLabel } </ InvisibleA11yLabel >
61- </ >
62- )
63- }
64- }
65-
6630const StopCardHeader = ( {
6731 actionIcon,
6832 actionParams,
@@ -75,12 +39,7 @@ const StopCardHeader = ({
7539 transitOperators
7640} : Props ) : JSX . Element => {
7741 const intl = useIntl ( )
78- const agencies =
79- stopData . stoptimesForPatterns ?. reduce < Set < string > > ( ( prev , cur ) => {
80- // @ts -expect-error The agency type is not yet compatible with OTP2
81- const agencyGtfsId = cur . pattern . route . agency ?. gtfsId
82- return agencyGtfsId ? prev . add ( agencyGtfsId ) : prev
83- } , new Set ( ) ) || new Set ( )
42+
8443 const zoomButtonText = onZoomClick
8544 ? intl . formatMessage ( {
8645 id : 'components.StopViewer.zoomToStop'
@@ -92,16 +51,10 @@ const StopCardHeader = ({
9251 < CardHeader >
9352 { /* @ts -expect-error The 'as' prop in styled-components is not listed for TypeScript. */ }
9453 < CardTitle as = { titleAs } >
95- { transitOperators
96- ?. filter ( ( to ) => Array . from ( agencies ) . includes ( to . agencyId ) )
97- // Second pass to remove duplicates based on name
98- . filter (
99- ( to , index , arr ) =>
100- index === arr . findIndex ( ( t ) => t ?. name === to ?. name )
101- )
102- . map ( ( to ) => (
103- < Operator key = { to . agencyId } operator = { to } />
104- ) ) }
54+ < TransitOperatorLogos
55+ stopData = { stopData }
56+ transitOperators = { transitOperators }
57+ />
10558 < span > { stopData . name } </ span >
10659 </ CardTitle >
10760 < DistanceDisplay distance = { stopData . distance } />
0 commit comments