Skip to content

Commit

Permalink
Merge branch 'master' into req-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
terror authored Jul 26, 2023
2 parents 1ed7f06 + 08b15da commit f6bf65a
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 7 deletions.
70 changes: 70 additions & 0 deletions client/src/assets/buildingCodes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"ADAMS": "Adams Building",
"AGTECH": "Agriculture & Engineering Labs",
"ARTS": "Arts Building",
"BARTON": "Barton Building",
"BEATTY": "Beatty Hall",
"BIRKS": "Birks Building",
"BRONF": "Bronfman Building",
"BURN": "Burnside Hall",
"CDH": "Chancellor Day Hall",
"CENTEN": "Centennial Centre",
"CMH": "Charles Meredith House",
"CURRIE": "Currie Gymnasium",
"DAVIS": "Davis House",
"DAWSON": "Dawson Hall",
"DUFF": "Duff Medical Building",
"DUGGAN": "Duggan House",
"EDUC": "Education Building",
"ENGMC": "McConnell Engineering Building",
"ENGMD": "Macdonald Engineering Building",
"ENGTR": "Trottier Building",
"FARM": "Farm Centre",
"FIELD": "In field",
"HOSMCH": "Hosmer Coach House",
"HOSMER": "Hosmer House",
"JGH": "Jewish General Hospital",
"LEA": "Leacock Building",
"MAASS": "Maass Chemistry Building",
"MACSTW": "Macdonald Stewart Building",
"MCLIB": "McLennan Library Building",
"MCMED": "McIntyre Medical Building",
"MDHAR": "Macdonald Harrington Building",
"MGH": "Montreal General Hospital",
"MNI": "Montreal Neurological Inst",
"MOR": "Morrice Hall",
"MOYSE": "Moyse Hall",
"MT3434": "McTavish 3434",
"MT3438": "McTavish 3438",
"MUSIC": "Strathcona Music Building",
"NOROOM": "No room needed",
"PARA": "Institute of Parasitology",
"PE1085": "Dr. Penfield 1085",
"PETH": "Peterson Hall",
"PILOT": "Pilot House",
"PL3465": "Peel 3465",
"PL3475": "Peel 3475",
"PL3487": "Peel 3487",
"PL3647": "Peel 3647",
"PL3661": "Peel 3661",
"PL3674": "Peel 3674",
"PL3690": "Peel 3690",
"PL3715": "Peel 3715",
"PN1033": "Pine 1033",
"POLY": "Ecole Polytechnique",
"PURVIS": "Purvis Hall",
"RAYMND": "Raymond Building",
"REDLIB": "Redpath Library Building",
"REDMUS": "Redpath Museum",
"REDPTH": "Redpath Hall",
"RPHYS": "Rutherford Physics Building",
"RVH": "Royal Victoria Hospital",
"SADB": "Strathcona Anatomy & Dentistry",
"SCHOOL": "School Teaching",
"SH550": "Sherbrooke 550",
"SH688": "Sherbrooke 688",
"STBIO": "Stewart Biology Building",
"STHALL": "Stewart Hall",
"WILSON": "Wilson Hall",
"WONG": "Wong Building"
}
36 changes: 34 additions & 2 deletions client/src/components/SchedulesDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { twMerge } from 'tailwind-merge';
import { sortSchedulesByBlocks, sortTerms } from '../lib/utils';
import { Course } from '../model/Course';
import { Block, Schedule, TimeBlock } from '../model/Schedule';
import { Tooltip } from './Tooltip';
import * as buildingCodes from '../assets/buildingCodes.json';

const dayToWeekday = (day: string) => {
switch (day) {
Expand Down Expand Up @@ -45,6 +47,26 @@ type SchedulesDisplayProps = {
course: Course;
};

const BlockLocation = ({ location }: { location: string }) => {
const [showFullName, setShowFullName] = useState(false);

const room = location.split(' ')[0];

return (
<span
className='relative whitespace-nowrap'
onMouseEnter={() => setShowFullName(true)}
onMouseLeave={() => setShowFullName(false)}
>
<Tooltip
show={showFullName}
text={buildingCodes[room as keyof typeof buildingCodes]}
children={<p className='inline-block'> {location}</p>}
></Tooltip>
</span>
);
};

export const SchedulesDisplay = ({ course }: SchedulesDisplayProps) => {
const schedules = course.schedule;

Expand Down Expand Up @@ -116,8 +138,18 @@ export const SchedulesDisplay = ({ course }: SchedulesDisplayProps) => {
{block.campus}
</div>
<div>
<span className='font-semibold'>Classroom(s): </span>
{block.location ? block.location.replace(';', ',') : 'N/A'}
<span className='font-semibold'>Classroom(s):</span>
<span className='ml-1 inline-block w-80'>
{((split) =>
split.map((location: string, index) => (
<span>
<BlockLocation location={location.trim()} />
{index !== split.length - 1 && (
<span className='inline-block'>, </span>
)}
</span>
)))(block.location.split(';'))}
</span>
</div>
</div>
<button
Expand Down
9 changes: 4 additions & 5 deletions client/src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ type TooltipProps = {

export const Tooltip = ({ show, text, children }: TooltipProps) => {
return (
<div>
<span>
<Transition
show={show}
className='absolute -top-1 left-0 z-10 min-w-fit -translate-x-0 -translate-y-full rounded-md bg-white p-2 text-center text-xs font-medium text-gray-700 dark:bg-neutral-500 dark:text-gray-100'
enter='transition-opacity duration-200'
enterFrom='opacity-0'
enterTo='opacity-100'
leave='transition-opacity duration-200'
leaveFrom='opacity-100'
leaveTo='opacity-0'
>
<div className='absolute -top-1 left-0 z-10 w-28 -translate-x-0 -translate-y-full rounded-lg bg-white p-2 text-center text-xs font-bold text-gray-700 dark:bg-neutral-500 dark:text-gray-100'>
{text}
</div>
<div>{text}</div>
</Transition>
{children}
</div>
</span>
);
};

0 comments on commit f6bf65a

Please sign in to comment.