line height text, refactored course schedule, added string representation functions to course meeting

This commit is contained in:
Sriram Hariharan
2023-03-06 16:51:46 -06:00
parent 007ade81a0
commit 9b76f8afa0
9 changed files with 182 additions and 56 deletions

View File

@@ -25,6 +25,7 @@ export default function Text(props: PropsWithChildren<TextProps>) {
style.color ??= colors?.[props.color ?? 'charcoal'];
style.fontSize ??= fonts?.[`${props.size ?? 'medium'}_size`];
style.fontWeight ??= fonts?.[`${props.weight ?? 'regular'}_weight`];
style.lineHeight ??= fonts?.[`${props.size ?? 'medium'}_line_height`];
if (props.span) {
return (

View File

@@ -16,6 +16,7 @@ interface Props {
* The popup that appears when the user clicks on a course for more details.
*/
export default function CoursePopup({ course, onClose }: Props) {
console.log(course);
return (
<Popup className={styles.popup} overlay>
<Icon className={styles.close} size='large' name='close' onClick={onClose} />

View File

@@ -1,5 +1,5 @@
import { Course, Instructor, Status, InstructionMode, ScrapedRow } from 'src/shared/types/Course';
import { CourseSchedule, CourseMeeting } from 'src/shared/types/CourseSchedule';
import { CourseSchedule } from 'src/shared/types/CourseSchedule';
import { SiteSupport } from 'src/views/lib/getSiteSupport';
/**
@@ -289,17 +289,18 @@ export class CourseCatalogScraper {
throw new Error('Schedule data is malformed');
}
const meetings: CourseMeeting[] = [];
const schedule = new CourseSchedule();
for (let i = 0; i < dayLines.length; i += 1) {
const lineMeetings = CourseSchedule.parse(
dayLines[i].textContent || '',
hourLines[i].textContent || '',
roomLines[i].textContent || ''
schedule.meetings.push(
CourseSchedule.parse(
dayLines[i].textContent || '',
hourLines[i].textContent || '',
roomLines[i].textContent || ''
)
);
meetings.push(...lineMeetings);
}
return new CourseSchedule({ meetings });
return schedule;
}
}

View File

@@ -30,6 +30,13 @@ $large_size: 24px;
$x_large_size: 32px;
$xx_large_size: 48px;
$x_small_line_height: 12px;
$small_line_height: 16px;
$medium_line_height: 20px;
$large_line_height: 28px;
$x_large_line_height: 36px;
$xx_large_line_height: 52px;
:export {
light_weight: $light_weight;
regular_weight: $regular_weight;
@@ -44,4 +51,12 @@ $xx_large_size: 48px;
large_size: $large_size;
x_large_size: $x_large_size;
xx_large_size: $xx_large_size;
x_small_line_height: $x_small_line_height;
small_line_height: $small_line_height;
medium_line_height: $medium_line_height;
large_line_height: $large_line_height;
x_large_line_height: $x_large_line_height;
xx_large_line_height: $xx_large_line_height;
}

View File

@@ -22,6 +22,18 @@ export interface ISizes {
xx_large_size: number;
}
/**
* the type for all the line height scss variables exported from fonts.module.scss
*/
export interface LineHeight {
x_small_line_height: number;
small_line_height: number;
medium_line_height: number;
large_line_height: number;
x_large_line_height: number;
xx_large_line_height: number;
}
/** A utility type that removes the _weight postfix from the variable names for weights */
export type Weight = keyof IWeights extends `${infer U}_weight` ? U : never;
@@ -32,7 +44,7 @@ export type Size = keyof ISizes extends `${infer U}_size` ? U : never;
* This is a file that we need to create to tell typescript what the shape of the css modules is
* when we import them into ts/tsx files
*/
export type IFonts = IWeights & ISizes;
export type IFonts = IWeights & ISizes & LineHeight;
declare const fonts: IFonts;
export default fonts;