Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"globals": "^17.1.0",
"jsdom": "^27.4.0",
"prettier": "^3.8.1",
"sass-embedded": "^1.97.3",
"typescript": "^5.9.3",
"typescript-eslint": "^8.53.1",
"vite": "^7.3.1",
Expand Down
4 changes: 0 additions & 4 deletions src/components/Calendar.scss → src/components/Calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
.fc .fc-scrollgrid-section > td,
.fc .fc-timegrid-axis {
border-color: transparent;

.dark & {
border-color: transparent;
}
}

.fc .fc-timegrid-slot {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Slot } from "../lib/dates";
import { Class } from "../lib/class";
import { HydrantContext } from "../lib/hydrant";

import "./Calendar.scss";
import "./Calendar.css";

/**
* Calendar showing all the activities, including the buttons on top that
Expand Down
7 changes: 7 additions & 0 deletions src/components/ClassTable.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.row {
cursor: pointer;
}

.row:hover .underline-on-hover {
text-decoration: underline;
}
31 changes: 0 additions & 31 deletions src/components/ClassTable.scss

This file was deleted.

36 changes: 17 additions & 19 deletions src/components/ClassTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ExternalFilterModule,
RenderApiModule,
CellStyleModule,
RowStyleModule,
themeQuartz,
type IRowNode,
type ColDef,
Expand All @@ -41,9 +42,11 @@ import type { Class, Flags } from "../lib/class";
import { DARK_IMAGES, getFlagImg } from "../lib/class";
import { classNumberMatch, classSort, simplifyString } from "../lib/utils";
import type { TSemester } from "../lib/dates";
import "./ClassTable.scss";
import { HydrantContext } from "../lib/hydrant";
import type { State } from "../lib/state";
import { ColorStyles } from "../lib/colors";

import styles from "./ClassTable.module.css";

const hydrantTheme = themeQuartz.withParams({
accentColor: "var(--chakra-colors-fg)",
Expand All @@ -62,25 +65,18 @@ const GRID_MODULES: Module[] = [
ExternalFilterModule,
CellStyleModule,
RenderApiModule,
RowStyleModule,
...(import.meta.env.DEV ? [ValidationModule] : []),
];

ModuleRegistry.registerModules(GRID_MODULES);

enum ColorEnum {
Muted = "ag-cell-muted-text",
Success = "ag-cell-success-text",
Warning = "ag-cell-warning-text",
Error = "ag-cell-error-text",
Normal = "ag-cell-normal-text",
}

const getRatingColor = (rating?: string | null) => {
if (!rating || rating === "N/A") return ColorEnum.Muted;
if (!rating || rating === "N/A") return ColorStyles.Muted;
const ratingNumber = Number(rating);
if (ratingNumber >= 6) return ColorEnum.Success;
if (ratingNumber >= 5) return ColorEnum.Warning;
return ColorEnum.Error;
if (ratingNumber >= 6) return ColorStyles.Success;
if (ratingNumber >= 5) return ColorStyles.Warning;
return ColorStyles.Error;
};

const getHoursColor = (
Expand All @@ -89,9 +85,9 @@ const getHoursColor = (
term: TSemester,
half: number | undefined,
) => {
if (!hours || hours === "N/A") return ColorEnum.Muted;
if (totalUnits === undefined) return ColorEnum.Muted;
if (totalUnits === 0) return ColorEnum.Normal;
if (!hours || hours === "N/A") return ColorStyles.Muted;
if (totalUnits === undefined) return ColorStyles.Muted;
if (totalUnits === 0) return ColorStyles.Normal;

const hoursNumber = Number(hours);
let weeksInTerm = 0;
Expand All @@ -115,9 +111,9 @@ const getHoursColor = (
const expectedHours = totalUnits * (weeksInTerm / 14) * (half ? 2 : 1);
const proportion = hoursNumber / expectedHours;

if (proportion < 0.8) return ColorEnum.Success;
if (proportion >= 0.8 && proportion <= 1.2) return ColorEnum.Warning;
return ColorEnum.Error;
if (proportion < 0.8) return ColorStyles.Success;
if (proportion >= 0.8 && proportion <= 1.2) return ColorStyles.Warning;
return ColorStyles.Error;
};

/** A single row in the class table. */
Expand Down Expand Up @@ -538,6 +534,7 @@ export function ClassTable() {
comparator: classSort,
initialSort,
maxWidth: 93,
cellClass: styles["underline-on-hover"],
...sortProps,
},
{
Expand Down Expand Up @@ -617,6 +614,7 @@ export function ClassTable() {
<AgGridReact<ClassTableRow>
theme={hydrantTheme}
ref={gridRef}
rowClass={styles.row}
defaultColDef={defaultColDef}
columnDefs={columnDefs}
rowData={rowData}
Expand Down
24 changes: 11 additions & 13 deletions src/components/PEClassTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ExternalFilterModule,
RenderApiModule,
CellStyleModule,
RowStyleModule,
themeQuartz,
type IRowNode,
type ColDef,
Expand All @@ -37,9 +38,11 @@ import { LuPlus, LuMinus, LuSearch, LuStar } from "react-icons/lu";

import { type PEFlags, type PEClass, getPEFlagEmoji } from "../lib/pe";
import { classNumberMatch, classSort, simplifyString } from "../lib/utils";
import "./ClassTable.scss";
import { HydrantContext } from "../lib/hydrant";
import type { State } from "../lib/state";
import { ColorStyles } from "../lib/colors";

import styles from "./ClassTable.module.css";

const hydrantTheme = themeQuartz.withParams({
accentColor: "var(--chakra-colors-fg)",
Expand All @@ -57,25 +60,18 @@ const GRID_MODULES: Module[] = [
ClientSideRowModelModule,
ExternalFilterModule,
CellStyleModule,
RowStyleModule,
RenderApiModule,
...(import.meta.env.DEV ? [ValidationModule] : []),
];

ModuleRegistry.registerModules(GRID_MODULES);

enum ColorEnum {
Muted = "ag-cell-muted-text",
Success = "ag-cell-success-text",
Warning = "ag-cell-warning-text",
Error = "ag-cell-error-text",
Normal = "ag-cell-normal-text",
}

const getFeeColor = (fee: number) => {
if (isNaN(fee)) return ColorEnum.Muted;
if (fee == 0) return ColorEnum.Success;
if (fee <= 20) return ColorEnum.Warning;
return ColorEnum.Error;
if (isNaN(fee)) return ColorStyles.Muted;
if (fee == 0) return ColorStyles.Success;
if (fee <= 20) return ColorStyles.Warning;
return ColorStyles.Error;
};

/** A single row in the class table. */
Expand Down Expand Up @@ -418,6 +414,7 @@ export function PEClassTable() {
comparator: classSort,
initialSort,
maxWidth: 93,
cellClass: styles["underline-on-hover"],
...sortProps,
},
{
Expand Down Expand Up @@ -496,6 +493,7 @@ export function PEClassTable() {
<AgGridReact<ClassTableRow>
theme={hydrantTheme}
ref={gridRef}
rowClass={styles.row}
defaultColDef={defaultColDef}
columnDefs={columnDefs}
rowData={rowData}
Expand Down
19 changes: 19 additions & 0 deletions src/lib/colors.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.muted {
color: var(--chakra-colors-fg-muted);
}

.success {
color: var(--chakra-colors-fg-success);
}

.warning {
color: var(--chakra-colors-fg-warning);
}

.error {
color: var(--chakra-colors-fg-error);
}

.normal {
color: var(--chakra-colors-fg);
}
10 changes: 10 additions & 0 deletions src/lib/colors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import type { ColorMode } from "../components/ui/color-mode";
import type { Activity } from "./activity";

import styles from "./colors.module.css";

export const ColorStyles = {
Muted: styles.muted,
Success: styles.success,
Warning: styles.warning,
Error: styles.error,
Normal: styles.normal,
} as const;

/** The type of color schemes. */
export interface ColorScheme {
name: string;
Expand Down