@@ -17,6 +17,7 @@ import {
1717 ExternalFilterModule ,
1818 RenderApiModule ,
1919 CellStyleModule ,
20+ RowStyleModule ,
2021 themeQuartz ,
2122 type IRowNode ,
2223 type ColDef ,
@@ -41,9 +42,11 @@ import type { Class, Flags } from "../lib/class";
4142import { DARK_IMAGES , getFlagImg } from "../lib/class" ;
4243import { classNumberMatch , classSort , simplifyString } from "../lib/utils" ;
4344import type { TSemester } from "../lib/dates" ;
44- import "./ClassTable.scss" ;
4545import { HydrantContext } from "../lib/hydrant" ;
4646import type { State } from "../lib/state" ;
47+ import { ColorStyles } from "../lib/colors" ;
48+
49+ import styles from "./ClassTable.module.css" ;
4750
4851const hydrantTheme = themeQuartz . withParams ( {
4952 accentColor : "var(--chakra-colors-fg)" ,
@@ -62,25 +65,18 @@ const GRID_MODULES: Module[] = [
6265 ExternalFilterModule ,
6366 CellStyleModule ,
6467 RenderApiModule ,
68+ RowStyleModule ,
6569 ...( import . meta. env . DEV ? [ ValidationModule ] : [ ] ) ,
6670] ;
6771
6872ModuleRegistry . registerModules ( GRID_MODULES ) ;
6973
70- enum ColorEnum {
71- Muted = "ag-cell-muted-text" ,
72- Success = "ag-cell-success-text" ,
73- Warning = "ag-cell-warning-text" ,
74- Error = "ag-cell-error-text" ,
75- Normal = "ag-cell-normal-text" ,
76- }
77-
7874const getRatingColor = ( rating ?: string | null ) => {
79- if ( ! rating || rating === "N/A" ) return ColorEnum . Muted ;
75+ if ( ! rating || rating === "N/A" ) return ColorStyles . Muted ;
8076 const ratingNumber = Number ( rating ) ;
81- if ( ratingNumber >= 6 ) return ColorEnum . Success ;
82- if ( ratingNumber >= 5 ) return ColorEnum . Warning ;
83- return ColorEnum . Error ;
77+ if ( ratingNumber >= 6 ) return ColorStyles . Success ;
78+ if ( ratingNumber >= 5 ) return ColorStyles . Warning ;
79+ return ColorStyles . Error ;
8480} ;
8581
8682const getHoursColor = (
@@ -89,9 +85,9 @@ const getHoursColor = (
8985 term : TSemester ,
9086 half : number | undefined ,
9187) => {
92- if ( ! hours || hours === "N/A" ) return ColorEnum . Muted ;
93- if ( totalUnits === undefined ) return ColorEnum . Muted ;
94- if ( totalUnits === 0 ) return ColorEnum . Normal ;
88+ if ( ! hours || hours === "N/A" ) return ColorStyles . Muted ;
89+ if ( totalUnits === undefined ) return ColorStyles . Muted ;
90+ if ( totalUnits === 0 ) return ColorStyles . Normal ;
9591
9692 const hoursNumber = Number ( hours ) ;
9793 let weeksInTerm = 0 ;
@@ -115,9 +111,9 @@ const getHoursColor = (
115111 const expectedHours = totalUnits * ( weeksInTerm / 14 ) * ( half ? 2 : 1 ) ;
116112 const proportion = hoursNumber / expectedHours ;
117113
118- if ( proportion < 0.8 ) return ColorEnum . Success ;
119- if ( proportion >= 0.8 && proportion <= 1.2 ) return ColorEnum . Warning ;
120- return ColorEnum . Error ;
114+ if ( proportion < 0.8 ) return ColorStyles . Success ;
115+ if ( proportion >= 0.8 && proportion <= 1.2 ) return ColorStyles . Warning ;
116+ return ColorStyles . Error ;
121117} ;
122118
123119/** A single row in the class table. */
@@ -538,6 +534,7 @@ export function ClassTable() {
538534 comparator : classSort ,
539535 initialSort,
540536 maxWidth : 93 ,
537+ cellClass : styles [ "underline-on-hover" ] ,
541538 ...sortProps ,
542539 } ,
543540 {
@@ -617,6 +614,7 @@ export function ClassTable() {
617614 < AgGridReact < ClassTableRow >
618615 theme = { hydrantTheme }
619616 ref = { gridRef }
617+ rowClass = { styles . row }
620618 defaultColDef = { defaultColDef }
621619 columnDefs = { columnDefs }
622620 rowData = { rowData }
0 commit comments