feat: add core curriculum chips to injected popup (#372)
* feat: add core curriculum chips to injected popup * fix: add VP and MAcore indicators * feat: core now defined in constructor * fix: make core and flags closer together * fix: stop empty core chip from showing when no core requirements * fix: remove optional chaining for core chips * feat: generalize Chip for both flags and core classes * fix: change types for storybook and add new story for CoreChip * fix: remove labelMap prop from Chip, chore: clean up imports * feat: change tooltip for core curriculum requirement --------- Co-authored-by: Derek Chen <derex1987@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ const TableDataSelector = {
|
||||
SCHEDULE_HOURS: 'td[data-th="Hour"]>span',
|
||||
SCHEDULE_LOCATION: 'td[data-th="Room"]>span',
|
||||
FLAGS: 'td[data-th="Flags"] ul li',
|
||||
CORE_CURRICULUM: 'td[data-th="Core"] ul li',
|
||||
} as const satisfies Record<string, string>;
|
||||
|
||||
type TableDataSelectorType = (typeof TableDataSelector)[keyof typeof TableDataSelector];
|
||||
@@ -99,6 +100,7 @@ export class CourseCatalogScraper {
|
||||
semester: this.getSemester(),
|
||||
scrapedAt: Date.now(),
|
||||
colors: getCourseColors('emerald', 500),
|
||||
core: this.getCore(row),
|
||||
});
|
||||
courses.push({
|
||||
element: row,
|
||||
@@ -337,6 +339,21 @@ export class CourseCatalogScraper {
|
||||
return Array.from(lis).map(li => li.textContent || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of core curriculum requirements the course satisfies
|
||||
* @param row
|
||||
* @returns an array of core curriculum codes
|
||||
*/
|
||||
getCore(row: HTMLTableRowElement): string[] {
|
||||
const lis = row.querySelectorAll(TableDataSelector.CORE_CURRICULUM);
|
||||
return (
|
||||
Array.from(lis)
|
||||
// ut schedule is weird and puts a blank core curriculum element even if there aren't any core requirements so filter those out
|
||||
.filter(li => li.getAttribute('title') !== ' core curriculum requirement')
|
||||
.map(li => li.textContent || '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will scrape all the time information from the course catalog table row and return it as a CourseSchedule object, which represents all of the meeting timiestimes/places of the course.
|
||||
* @param row the row of the course catalog table
|
||||
|
||||
Reference in New Issue
Block a user