@@ -6,13 +6,16 @@ import { Link, LinkProps } from 'react-router-dom';
6
6
import { Venue , VenueLocationMap } from 'types/venues' ;
7
7
import { venuePage } from 'views/routes/paths' ;
8
8
9
+ import { highlight } from 'utils/react' ;
10
+ import { tokenize } from 'utils/moduleSearch' ;
9
11
import styles from './VenueList.scss' ;
10
12
11
13
type Props = {
12
14
venues : Venue [ ] ;
13
15
venueLocations ?: VenueLocationMap ;
14
16
selectedVenue ?: Venue | null ;
15
17
linkProps ?: Omit < LinkProps , 'to' > ;
18
+ query ?: string ;
16
19
} ;
17
20
18
21
const VenueList : React . FC < Props > = ( props ) => {
@@ -21,6 +24,8 @@ const VenueList: React.FC<Props> = (props) => {
21
24
const venueList = groupBy ( physicalVenues , ( venue ) => venue . charAt ( 0 ) . toUpperCase ( ) ) ;
22
25
const sortedVenueList = sortBy ( toPairs ( venueList ) , ( [ key ] ) => key ) ;
23
26
27
+ const tokens = props . query ? tokenize ( props . query . toLowerCase ( ) ) : [ ] ;
28
+
24
29
return (
25
30
< ul className = { styles . venueList } >
26
31
{ sortedVenueList . map ( ( [ heading , venues ] ) => (
@@ -41,15 +46,15 @@ const VenueList: React.FC<Props> = (props) => {
41
46
) }
42
47
{ ...props . linkProps }
43
48
>
44
- < div > { venue } </ div >
49
+ < div > { highlight ( venue , tokens ) } </ div >
45
50
{ props . venueLocations && props . venueLocations [ venue ] ? (
46
51
< div
47
52
className = { classnames (
48
53
'font-weight-light d-inline-block text-truncate' ,
49
54
styles . subtitle ,
50
55
) }
51
56
>
52
- { props . venueLocations [ venue ] . roomName }
57
+ < span > { highlight ( ` ${ props . venueLocations [ venue ] . roomName } ` , tokens ) } </ span >
53
58
</ div >
54
59
) : null }
55
60
</ Link >
0 commit comments