-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into move-academic-session-select
- Loading branch information
Showing
13 changed files
with
630 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Related Classes Example | ||
|
||
```ts | ||
<RelatedClasses /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Typography } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
import { RelatedTermCard } from '../RelatedTermCard/relatedTermCard'; | ||
|
||
type SearchQuery = { | ||
prefix?: string; | ||
number?: string; | ||
professorName?: string; | ||
sectionNumber?: string; | ||
}; | ||
|
||
type RelatedClassesProps = { | ||
displayData: SearchQuery[]; | ||
addNew: (query: SearchQuery) => void; | ||
disabled: boolean; | ||
}; | ||
|
||
/** | ||
* This component returns a bar that will allow users to add and remove search terms (up to 3 max) | ||
* using the SearchBar component. The currently selected search terms are represented by | ||
* SearchTermCard components, and are displayed from left to right in this grid. | ||
*/ | ||
export const RelatedClasses = ({ | ||
displayData, | ||
addNew, | ||
disabled, | ||
}: RelatedClassesProps) => { | ||
function addSearchTerm(index: number) { | ||
addNew(displayData[index]); | ||
} | ||
|
||
return ( | ||
<div className="grid grid-flow-column auto-cols-fr justify-center"> | ||
<div className="p-4 rounded-none"> | ||
<Typography className="leading-tight text-lg text-dark"> | ||
Related Queries | ||
</Typography> | ||
</div> | ||
{displayData.map((option: SearchQuery, index: number) => ( | ||
<RelatedTermCard | ||
primaryText={searchQueryLabel(option)} | ||
key={index} | ||
index={index} | ||
onAddButtonClicked={addSearchTerm} | ||
disabled={disabled} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
function searchQueryLabel(query: SearchQuery): string { | ||
let result = ''; | ||
if (query.prefix !== undefined) { | ||
result += query.prefix; | ||
} | ||
if (query.number !== undefined) { | ||
result += ' ' + query.number; | ||
} | ||
if (query.sectionNumber !== undefined) { | ||
result += '.' + query.sectionNumber; | ||
} | ||
if (query.professorName !== undefined) { | ||
result += ' ' + query.professorName; | ||
} | ||
return result.trim(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### Related Term Card Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { AddCircle } from '@mui/icons-material'; | ||
import { IconButton, Tooltip, Typography } from '@mui/material'; | ||
import Card from '@mui/material/Card'; | ||
import * as React from 'react'; | ||
|
||
/** | ||
* Props type used by the SearchTermCard component | ||
*/ | ||
type RelatedTermCardProps = { | ||
primaryText: string; | ||
index: number; | ||
onAddButtonClicked: (index: number) => void; | ||
disabled: boolean; | ||
}; | ||
|
||
/** | ||
* This component returns a custom Card that shows the search term and a colored circle | ||
* next to it representing the corresponding data's color | ||
* | ||
*/ | ||
export const RelatedTermCard = (props: RelatedTermCardProps) => { | ||
function handleAddClick() { | ||
props.onAddButtonClicked(props.index); | ||
} | ||
|
||
return ( | ||
<Card | ||
className="bg-primary-light p-2 flex flex-row justify-between items-center rounded-none" | ||
variant="outlined" | ||
> | ||
<div className="float-left flex align-middle place-items-center"> | ||
<Typography className="leading-tight text-lg text-gray-600 dark:text-gray-200"> | ||
{props.primaryText} | ||
</Typography> | ||
</div> | ||
<div className="float-right"> | ||
<Tooltip | ||
title={ | ||
props.disabled | ||
? 'Remove a search term to add this query' | ||
: 'Add query to search' | ||
} | ||
> | ||
<span> | ||
<IconButton | ||
aria-label="add query" | ||
onClick={handleAddClick} | ||
disabled={props.disabled} | ||
> | ||
<AddCircle /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
</div> | ||
</Card> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.