Skip to content

Commit

Permalink
1200CS highlighting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TyHil committed Oct 18, 2023
1 parent a79c921 commit 5652d89
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
18 changes: 12 additions & 6 deletions components/common/SearchBar/searchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Autocomplete, InputAdornment, InputBase, Paper } from '@mui/material';
import Popper from '@mui/material/Popper';
import match from 'autosuggest-highlight/match';
import parse from 'autosuggest-highlight/parse';
import * as React from 'react';
import { useEffect } from 'react';
import React, { useEffect } from 'react';

import SearchQuery from '../../../modules/SearchQuery/SearchQuery';
import searchQueryLabel from '../../../modules/searchQueryLabel/searchQueryLabel';
Expand Down Expand Up @@ -126,10 +125,17 @@ export const SearchBar = (props: SearchProps) => {
//add spaces between prefix and course number
const matches = match(
text,
inputValue.replace(
/([a-zA-Z]{2,4})([0-9][0-9V]?[0-9]{0,2})/,
'$1 $2',
),
inputValue
.replace(
//CS1200 -> CS 1200
/([a-zA-Z]{2,4})([0-9][0-9V]?[0-9]{0,2})/,
'$1 $2',
)
.replace(
//1200CS -> 1200 CS
/([0-9][0-9V][0-9]{2})([a-zA-Z]{1,4})/,
'$1 $2',
),
);
const parts = parse(text, matches);
console.log(parts);
Expand Down
15 changes: 11 additions & 4 deletions components/common/SplashPageSearchBar/splashPageSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Search } from '@mui/icons-material';
import { Autocomplete, InputAdornment, InputBase } from '@mui/material';
import match from 'autosuggest-highlight/match';
import parse from 'autosuggest-highlight/parse';
import * as React from 'react';
import { useEffect } from 'react';
import React, { useEffect } from 'react';

import SearchQuery from '../../../modules/SearchQuery/SearchQuery';
import searchQueryLabel from '../../../modules/searchQueryLabel/searchQueryLabel';
Expand Down Expand Up @@ -107,8 +106,16 @@ export const SplashPageSearchBar = (props: SearchProps) => {
const matches = match(
text,
inputValue
.replace(/([a-zA-Z]{2,4})([0-9][0-9V]?[0-9]{0,2})/, '$1 $2')
.replace(/([0-9][0-9V]?[0-9]{0,2})([a-zA-Z]{2,4})/, '$1 $2'),
.replace(
//CS1200 -> CS 1200
/([a-zA-Z]{2,4})([0-9][0-9V]?[0-9]{0,2})/,
'$1 $2',
)
.replace(
//1200CS -> 1200 CS
/([0-9][0-9V][0-9]{2})([a-zA-Z]{1,4})/,
'$1 $2',
),
);
const parts = parse(text, matches);
return (
Expand Down
2 changes: 1 addition & 1 deletion data/autocomplete_graph.json

Large diffs are not rendered by default.

0 comments on commit 5652d89

Please sign in to comment.