From 78e6ddd05354723320243b01e96c391c7ee2fcb5 Mon Sep 17 00:00:00 2001 From: Sean Kelman Date: Sun, 24 Dec 2023 23:12:36 -0800 Subject: [PATCH 1/7] deprecated isDarkMode in favor of useThemeStore --- .../Calendar/CourseCalendarEvent.tsx | 7 ++- .../CustomEventDialog/CustomEventDialog.tsx | 8 ++- .../EditSchedule/DeleteScheduleDialog.tsx | 6 +- .../EditSchedule/ScheduleNameDialog.tsx | 6 +- .../Header/LoadSaveFunctionality.tsx | 18 ++++-- .../RightPane/CoursePane/CourseRenderPane.tsx | 23 ++++--- .../components/RightPane/RightPaneRoot.tsx | 6 +- .../RightPane/SectionTable/GradesPopup.tsx | 6 +- .../RightPane/SectionTable/PrereqTree.tsx | 7 ++- .../SectionTable/SectionTableBody.tsx | 63 ++++++++++++++----- .../src/components/buttons/Screenshot.tsx | 5 +- .../src/components/dialogs/AddSchedule.tsx | 6 +- .../src/components/dialogs/DeleteSchedule.tsx | 6 +- .../src/components/dialogs/RenameSchedule.tsx | 1 - 14 files changed, 114 insertions(+), 54 deletions(-) diff --git a/apps/antalmanac/src/components/Calendar/CourseCalendarEvent.tsx b/apps/antalmanac/src/components/Calendar/CourseCalendarEvent.tsx index 82dff4dc5..01dd0c4b5 100644 --- a/apps/antalmanac/src/components/Calendar/CourseCalendarEvent.tsx +++ b/apps/antalmanac/src/components/Calendar/CourseCalendarEvent.tsx @@ -10,12 +10,12 @@ import CustomEventDialog from './Toolbar/CustomEventDialog/CustomEventDialog'; import { deleteCourse, deleteCustomEvent } from '$actions/AppStoreActions'; import ColorPicker from '$components/ColorPicker'; import analyticsEnum, { logAnalytics } from '$lib/analytics'; -import { clickToCopy, isDarkMode } from '$lib/helpers'; +import { clickToCopy } from '$lib/helpers'; import AppStore from '$stores/AppStore'; import locationIds from '$lib/location_ids'; import { useTabStore } from '$stores/TabStore'; import { formatTimes } from '$stores/calendarizeHelpers'; -import { useTimeFormatStore } from '$stores/SettingsStore'; +import { useTimeFormatStore, useThemeStore } from '$stores/SettingsStore'; import buildingCatalogue from '$lib/buildingCatalogue'; const styles: Styles = { @@ -74,7 +74,6 @@ const styles: Styles = { clickableLocation: { cursor: 'pointer', - color: isDarkMode() ? '#1cbeff' : 'blue', background: 'none !important', border: 'none', padding: '0 !important', @@ -177,6 +176,7 @@ const CourseCalendarEvent = (props: CourseCalendarEventProps) => { const { setActiveTab } = useTabStore(); const { isMilitaryTime } = useTimeFormatStore(); + const appTheme = useThemeStore((store) => store.appTheme); const focusMap = useCallback(() => { setActiveTab(2); @@ -262,6 +262,7 @@ const CourseCalendarEvent = (props: CourseCalendarEventProps) => { className={classes.clickableLocation} to={`/map?location=${locationIds[location.building] ?? 0}`} onClick={focusMap} + color={appTheme == 'dark' ? '#1cbeff' : 'blue'} > {location.building} {location.room} diff --git a/apps/antalmanac/src/components/Calendar/Toolbar/CustomEventDialog/CustomEventDialog.tsx b/apps/antalmanac/src/components/Calendar/Toolbar/CustomEventDialog/CustomEventDialog.tsx index 69764d159..bb55a301e 100644 --- a/apps/antalmanac/src/components/Calendar/Toolbar/CustomEventDialog/CustomEventDialog.tsx +++ b/apps/antalmanac/src/components/Calendar/Toolbar/CustomEventDialog/CustomEventDialog.tsx @@ -19,7 +19,7 @@ import DaySelector from './DaySelector'; import ScheduleSelector from './ScheduleSelector'; import { addCustomEvent, editCustomEvent } from '$actions/AppStoreActions'; import analyticsEnum, { logAnalytics } from '$lib/analytics'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import AppStore from '$stores/AppStore'; import { BuildingSelect, ExtendedBuilding } from '$components/inputs/building-select'; @@ -129,6 +129,7 @@ class CustomEventDialog extends PureComponent {this.props.customEvent !== undefined ? ( @@ -203,7 +204,10 @@ class CustomEventDialog extends PureComponent - diff --git a/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx b/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx index 7f919943c..2b5df1cae 100644 --- a/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx +++ b/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx @@ -14,7 +14,7 @@ import { useState } from 'react'; import { Clear } from '@material-ui/icons'; import { deleteSchedule } from '$actions/AppStoreActions'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import AppStore from '$stores/AppStore'; interface DeleteScheduleDialogProps { @@ -23,6 +23,8 @@ interface DeleteScheduleDialogProps { } const DeleteScheduleDialog = (props: DeleteScheduleDialogProps) => { + const appTheme = useThemeStore((store) => store.appTheme); + const { scheduleIndex } = props; const [isOpen, setIsOpen] = useState(false); @@ -58,7 +60,7 @@ const DeleteScheduleDialog = (props: DeleteScheduleDialogProps) => { - - @@ -137,6 +138,8 @@ class LoadSaveButtonBase extends PureComponent { + const appTheme = useThemeStore((store) => store.appTheme); + const [loading, setLoading] = useState(false); const loadScheduleAndSetLoading = async (userID: string, rememberMe: boolean) => { @@ -158,12 +161,19 @@ const LoadSaveScheduleFunctionality = () => { return ( <> - + ); diff --git a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx index 2375e8b8b..60f2b7f4a 100644 --- a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx +++ b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx @@ -14,7 +14,7 @@ import loadingGif from './SearchForm/Gifs/loading.gif'; import darkNoNothing from './static/dark-no_results.png'; import noNothing from './static/no_results.png'; import AppStore from '$stores/AppStore'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import Grades from '$lib/grades'; import analyticsEnum from '$lib/analytics'; import { openSnackbar } from '$actions/AppStoreActions'; @@ -52,6 +52,8 @@ const flattenSOCObject = (SOCObject: WebsocAPIResponse): (WebsocSchool | WebsocD const RecruitmentBanner = () => { const [bannerVisibility, setBannerVisibility] = useState(true); + const appTheme = useThemeStore((store) => store.appTheme); + // Display recruitment banner if more than 11 weeks (in ms) has passed since last dismissal const recruitmentDismissalTime = window.localStorage.getItem('recruitmentDismissalTime'); const dismissedRecently = @@ -67,8 +69,8 @@ const RecruitmentBanner = () => { icon={false} severity="info" style={{ - color: isDarkMode() ? '#ece6e6' : '#2e2e2e', - backgroundColor: isDarkMode() ? '#2e2e2e' : '#ece6e6', + color: appTheme == 'dark' ? '#ece6e6' : '#2e2e2e', + backgroundColor: appTheme == 'dark' ? '#2e2e2e' : '#ece6e6', }} action={ { + const appTheme = useThemeStore((store) => store.appTheme); return ( - Loading courses + Loading courses ); }; const ErrorMessage = () => { + const appTheme = useThemeStore((store) => store.appTheme); return ( No Results Found @@ -203,11 +207,10 @@ export default function CourseRenderPane(props: { id?: number }) { ? WebSOC.queryMultiple(websocQueryParams, 'units') : WebSOC.query(websocQueryParams), // Catch the error here so that the course pane still loads even if the grades cache fails to populate - Grades.populateGradesCache(gradesQueryParams) - .catch((error) => { - console.error(error); - openSnackbar('error', 'Error loading grades information'); - }), + Grades.populateGradesCache(gradesQueryParams).catch((error) => { + console.error(error); + openSnackbar('error', 'Error loading grades information'); + }), ]); setError(false); diff --git a/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx b/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx index 5b666f5b7..e2701d778 100644 --- a/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx +++ b/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx @@ -8,7 +8,7 @@ import CoursePane from './CoursePane/CoursePaneRoot'; import darkModeLoadingGif from './CoursePane/SearchForm/Gifs/dark-loading.gif'; import loadingGif from './CoursePane/SearchForm/Gifs/loading.gif'; import { useTabStore } from '$stores/TabStore'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; const UCIMap = React.lazy(() => import('../Map')); @@ -47,6 +47,8 @@ const tabs = [ export default function Desktop({ style }: DesktopTabsProps) { const { activeTab, setActiveTab } = useTabStore(); + const appTheme = useThemeStore((store) => store.appTheme); + return ( @@ -81,7 +83,7 @@ export default function Desktop({ style }: DesktopTabsProps) { - Loading map + Loading map } > diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx index 01045f8d0..03cc03e9c 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx @@ -1,7 +1,7 @@ import { useState, useEffect, useMemo } from 'react'; import { Bar, BarChart, CartesianGrid, ResponsiveContainer, XAxis, YAxis } from 'recharts'; import { Box, Link, Typography, Skeleton } from '@mui/material'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import GradesHelper, { type Grades } from '$lib/grades'; export interface GradeData { @@ -51,6 +51,8 @@ export interface GradesPopupProps { } function GradesPopup(props: GradesPopupProps) { + const appTheme = useThemeStore((store) => store.appTheme); + const { deptCode, courseNumber, instructor = '', isMobileScreen } = props; const [loading, setLoading] = useState(true); @@ -106,7 +108,7 @@ function GradesPopup(props: GradesPopupProps) { } const encodedDept = encodeURIComponent(deptCode); - const axisColor = isDarkMode() ? '#fff' : '#111'; + const axisColor = appTheme == 'dark' ? '#fff' : '#111'; return ( diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx index 1bc339d09..cd519897a 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx @@ -4,7 +4,7 @@ import { FC, useState } from 'react'; import { Button, Modal, Popover } from '@material-ui/core'; import { CourseInfo } from './CourseInfoBar'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import './PrereqTree.css'; @@ -23,13 +23,14 @@ interface NodeProps { } const Node: FC = (props) => { + const appTheme = useThemeStore((store) => store.appTheme); return (
{props.label} diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx index c2f23e89b..af5d9906f 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx @@ -25,7 +25,7 @@ import { ColorAndDelete, ScheduleAddCell } from './SectionTableButtons'; import restrictionsMapping from './static/restrictionsMapping.json'; import GradesPopup from './GradesPopup'; import analyticsEnum, { logAnalytics } from '$lib/analytics'; -import { clickToCopy, isDarkMode } from '$lib/helpers'; +import { clickToCopy } from '$lib/helpers'; import { CourseDetails } from '$lib/course_data.types'; import Grades from '$lib/grades'; import AppStore from '$stores/AppStore'; @@ -33,14 +33,14 @@ import { useTabStore } from '$stores/TabStore'; import locationIds from '$lib/location_ids'; import { normalizeTime, parseDaysString, formatTimes } from '$stores/calendarizeHelpers'; import useColumnStore, { type SectionTableColumn } from '$stores/ColumnStore'; -import { useTimeFormatStore } from '$stores/SettingsStore'; +import { useTimeFormatStore, useThemeStore } from '$stores/SettingsStore'; const styles: Styles = (theme) => ({ sectionCode: { display: 'inline-flex', cursor: 'pointer', '&:hover': { - color: isDarkMode() ? 'gold' : 'blueviolet', + //color: isDarkMode() ? 'gold' : 'blueviolet', cursor: 'pointer', }, alignSelf: 'center', @@ -50,23 +50,12 @@ const styles: Styles = (theme) => ({ backgroundColor: theme.palette.action.hover, }, }, - tr: { - '&.addedCourse': { - background: isDarkMode() ? '#b0b04f' : '#fcfc97', - }, - '&.scheduleConflict': { - background: isDarkMode() ? '#121212' : '#a0a0a0', - opacity: isDarkMode() ? 0.6 : 1, - }, - }, cell: {}, link: { textDecoration: 'underline', - color: isDarkMode() ? 'dodgerblue' : 'blue', cursor: 'pointer', }, mapLink: { - color: isDarkMode() ? 'dodgerblue' : 'blue', cursor: 'pointer', background: 'none !important', border: 'none', @@ -100,7 +89,6 @@ const styles: Styles = (theme) => ({ Tap: { color: '#8d2df0' }, Tut: { color: '#ffc705' }, popoverText: { - color: isDarkMode() ? 'dodgerblue' : 'blue', cursor: 'pointer', }, codeCell: { @@ -121,8 +109,20 @@ interface CourseCodeCellProps { } const CourseCodeCell = withStyles(styles)((props: CourseCodeCellProps) => { + const appTheme = useThemeStore((store) => store.appTheme); + const { classes, sectionCode } = props; + const [isHovered, setIsHovered] = useState(false); + + const handleMouseEnter = () => { + setIsHovered(true); + }; + + const handleMouseLeave = () => { + setIsHovered(false); + }; + return ( @@ -136,6 +136,11 @@ const CourseCodeCell = withStyles(styles)((props: CourseCodeCellProps) => { }} className={classes.sectionCode} label={sectionCode} + onMouseEnter={handleMouseEnter} + onMouseLeave={handleMouseLeave} + style={{ + color: isHovered ? (appTheme == 'dark' ? 'gold' : 'blueviolet') : '', + }} size="small" /> @@ -232,6 +237,8 @@ interface GPACellProps { } function GPACell(props: GPACellProps) { + const appTheme = useThemeStore((store) => store.appTheme); + const { deptCode, courseNumber, instructors } = props; const [gpa, setGpa] = useState(''); @@ -263,7 +270,7 @@ function GPACell(props: GPACellProps) { diff --git a/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx b/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx index 7f919943c..2b5df1cae 100644 --- a/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx +++ b/apps/antalmanac/src/components/Calendar/Toolbar/EditSchedule/DeleteScheduleDialog.tsx @@ -14,7 +14,7 @@ import { useState } from 'react'; import { Clear } from '@material-ui/icons'; import { deleteSchedule } from '$actions/AppStoreActions'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import AppStore from '$stores/AppStore'; interface DeleteScheduleDialogProps { @@ -23,6 +23,8 @@ interface DeleteScheduleDialogProps { } const DeleteScheduleDialog = (props: DeleteScheduleDialogProps) => { + const appTheme = useThemeStore((store) => store.appTheme); + const { scheduleIndex } = props; const [isOpen, setIsOpen] = useState(false); @@ -58,7 +60,7 @@ const DeleteScheduleDialog = (props: DeleteScheduleDialogProps) => { - - @@ -137,6 +138,8 @@ class LoadSaveButtonBase extends PureComponent { + const appTheme = useThemeStore((store) => store.appTheme); + const [loading, setLoading] = useState(false); const loadScheduleAndSetLoading = async (userID: string, rememberMe: boolean) => { @@ -158,12 +161,19 @@ const LoadSaveScheduleFunctionality = () => { return ( <> - + ); diff --git a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx index 2375e8b8b..60f2b7f4a 100644 --- a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx +++ b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx @@ -14,7 +14,7 @@ import loadingGif from './SearchForm/Gifs/loading.gif'; import darkNoNothing from './static/dark-no_results.png'; import noNothing from './static/no_results.png'; import AppStore from '$stores/AppStore'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import Grades from '$lib/grades'; import analyticsEnum from '$lib/analytics'; import { openSnackbar } from '$actions/AppStoreActions'; @@ -52,6 +52,8 @@ const flattenSOCObject = (SOCObject: WebsocAPIResponse): (WebsocSchool | WebsocD const RecruitmentBanner = () => { const [bannerVisibility, setBannerVisibility] = useState(true); + const appTheme = useThemeStore((store) => store.appTheme); + // Display recruitment banner if more than 11 weeks (in ms) has passed since last dismissal const recruitmentDismissalTime = window.localStorage.getItem('recruitmentDismissalTime'); const dismissedRecently = @@ -67,8 +69,8 @@ const RecruitmentBanner = () => { icon={false} severity="info" style={{ - color: isDarkMode() ? '#ece6e6' : '#2e2e2e', - backgroundColor: isDarkMode() ? '#2e2e2e' : '#ece6e6', + color: appTheme == 'dark' ? '#ece6e6' : '#2e2e2e', + backgroundColor: appTheme == 'dark' ? '#2e2e2e' : '#ece6e6', }} action={ { + const appTheme = useThemeStore((store) => store.appTheme); return ( - Loading courses + Loading courses ); }; const ErrorMessage = () => { + const appTheme = useThemeStore((store) => store.appTheme); return ( No Results Found @@ -203,11 +207,10 @@ export default function CourseRenderPane(props: { id?: number }) { ? WebSOC.queryMultiple(websocQueryParams, 'units') : WebSOC.query(websocQueryParams), // Catch the error here so that the course pane still loads even if the grades cache fails to populate - Grades.populateGradesCache(gradesQueryParams) - .catch((error) => { - console.error(error); - openSnackbar('error', 'Error loading grades information'); - }), + Grades.populateGradesCache(gradesQueryParams).catch((error) => { + console.error(error); + openSnackbar('error', 'Error loading grades information'); + }), ]); setError(false); diff --git a/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx b/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx index 5b666f5b7..e2701d778 100644 --- a/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx +++ b/apps/antalmanac/src/components/RightPane/RightPaneRoot.tsx @@ -8,7 +8,7 @@ import CoursePane from './CoursePane/CoursePaneRoot'; import darkModeLoadingGif from './CoursePane/SearchForm/Gifs/dark-loading.gif'; import loadingGif from './CoursePane/SearchForm/Gifs/loading.gif'; import { useTabStore } from '$stores/TabStore'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; const UCIMap = React.lazy(() => import('../Map')); @@ -47,6 +47,8 @@ const tabs = [ export default function Desktop({ style }: DesktopTabsProps) { const { activeTab, setActiveTab } = useTabStore(); + const appTheme = useThemeStore((store) => store.appTheme); + return ( @@ -81,7 +83,7 @@ export default function Desktop({ style }: DesktopTabsProps) { - Loading map + Loading map
} > diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx index 01045f8d0..03cc03e9c 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx @@ -1,7 +1,7 @@ import { useState, useEffect, useMemo } from 'react'; import { Bar, BarChart, CartesianGrid, ResponsiveContainer, XAxis, YAxis } from 'recharts'; import { Box, Link, Typography, Skeleton } from '@mui/material'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import GradesHelper, { type Grades } from '$lib/grades'; export interface GradeData { @@ -51,6 +51,8 @@ export interface GradesPopupProps { } function GradesPopup(props: GradesPopupProps) { + const appTheme = useThemeStore((store) => store.appTheme); + const { deptCode, courseNumber, instructor = '', isMobileScreen } = props; const [loading, setLoading] = useState(true); @@ -106,7 +108,7 @@ function GradesPopup(props: GradesPopupProps) { } const encodedDept = encodeURIComponent(deptCode); - const axisColor = isDarkMode() ? '#fff' : '#111'; + const axisColor = appTheme == 'dark' ? '#fff' : '#111'; return ( diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx index 1bc339d09..cd519897a 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx @@ -4,7 +4,7 @@ import { FC, useState } from 'react'; import { Button, Modal, Popover } from '@material-ui/core'; import { CourseInfo } from './CourseInfoBar'; -import { isDarkMode } from '$lib/helpers'; +import { useThemeStore } from '$stores/SettingsStore'; import './PrereqTree.css'; @@ -23,13 +23,14 @@ interface NodeProps { } const Node: FC = (props) => { + const appTheme = useThemeStore((store) => store.appTheme); return (
{props.label} diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx index c2f23e89b..25667fa33 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx @@ -25,7 +25,7 @@ import { ColorAndDelete, ScheduleAddCell } from './SectionTableButtons'; import restrictionsMapping from './static/restrictionsMapping.json'; import GradesPopup from './GradesPopup'; import analyticsEnum, { logAnalytics } from '$lib/analytics'; -import { clickToCopy, isDarkMode } from '$lib/helpers'; +import { clickToCopy } from '$lib/helpers'; import { CourseDetails } from '$lib/course_data.types'; import Grades from '$lib/grades'; import AppStore from '$stores/AppStore'; @@ -33,14 +33,13 @@ import { useTabStore } from '$stores/TabStore'; import locationIds from '$lib/location_ids'; import { normalizeTime, parseDaysString, formatTimes } from '$stores/calendarizeHelpers'; import useColumnStore, { type SectionTableColumn } from '$stores/ColumnStore'; -import { useTimeFormatStore } from '$stores/SettingsStore'; +import { useTimeFormatStore, useThemeStore } from '$stores/SettingsStore'; const styles: Styles = (theme) => ({ sectionCode: { display: 'inline-flex', cursor: 'pointer', '&:hover': { - color: isDarkMode() ? 'gold' : 'blueviolet', cursor: 'pointer', }, alignSelf: 'center', @@ -50,23 +49,12 @@ const styles: Styles = (theme) => ({ backgroundColor: theme.palette.action.hover, }, }, - tr: { - '&.addedCourse': { - background: isDarkMode() ? '#b0b04f' : '#fcfc97', - }, - '&.scheduleConflict': { - background: isDarkMode() ? '#121212' : '#a0a0a0', - opacity: isDarkMode() ? 0.6 : 1, - }, - }, cell: {}, link: { textDecoration: 'underline', - color: isDarkMode() ? 'dodgerblue' : 'blue', cursor: 'pointer', }, mapLink: { - color: isDarkMode() ? 'dodgerblue' : 'blue', cursor: 'pointer', background: 'none !important', border: 'none', @@ -100,7 +88,6 @@ const styles: Styles = (theme) => ({ Tap: { color: '#8d2df0' }, Tut: { color: '#ffc705' }, popoverText: { - color: isDarkMode() ? 'dodgerblue' : 'blue', cursor: 'pointer', }, codeCell: { @@ -121,8 +108,20 @@ interface CourseCodeCellProps { } const CourseCodeCell = withStyles(styles)((props: CourseCodeCellProps) => { + const appTheme = useThemeStore((store) => store.appTheme); + const { classes, sectionCode } = props; + const [isHovered, setIsHovered] = useState(false); + + const handleMouseEnter = () => { + setIsHovered(true); + }; + + const handleMouseLeave = () => { + setIsHovered(false); + }; + return ( @@ -136,6 +135,11 @@ const CourseCodeCell = withStyles(styles)((props: CourseCodeCellProps) => { }} className={classes.sectionCode} label={sectionCode} + onMouseEnter={handleMouseEnter} + onMouseLeave={handleMouseLeave} + style={{ + color: isHovered ? (appTheme == 'dark' ? 'gold' : 'blueviolet') : '', + }} size="small" /> @@ -232,6 +236,8 @@ interface GPACellProps { } function GPACell(props: GPACellProps) { + const appTheme = useThemeStore((store) => store.appTheme); + const { deptCode, courseNumber, instructors } = props; const [gpa, setGpa] = useState(''); @@ -263,7 +269,7 @@ function GPACell(props: GPACellProps) {
} > diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx index 03cc03e9c..e2467e015 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx @@ -108,7 +108,7 @@ function GradesPopup(props: GradesPopupProps) { } const encodedDept = encodeURIComponent(deptCode); - const axisColor = appTheme == 'dark' ? '#fff' : '#111'; + const axisColor = isDark ? '#fff' : '#111'; return ( diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx index cd519897a..90e3ee0d4 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/PrereqTree.tsx @@ -29,8 +29,8 @@ const Node: FC = (props) => {
{props.label} diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx index 25667fa33..29c7b2a68 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx @@ -108,7 +108,7 @@ interface CourseCodeCellProps { } const CourseCodeCell = withStyles(styles)((props: CourseCodeCellProps) => { - const appTheme = useThemeStore((store) => store.appTheme); + const isDark = useThemeStore((store) => store.isDark); const { classes, sectionCode } = props; @@ -138,7 +138,7 @@ const CourseCodeCell = withStyles(styles)((props: CourseCodeCellProps) => { onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} style={{ - color: isHovered ? (appTheme == 'dark' ? 'gold' : 'blueviolet') : '', + color: isHovered ? (isDark ? 'gold' : 'blueviolet') : '', }} size="small" /> @@ -236,7 +236,7 @@ interface GPACellProps { } function GPACell(props: GPACellProps) { - const appTheme = useThemeStore((store) => store.appTheme); + const isDark = useThemeStore((store) => store.isDark); const { deptCode, courseNumber, instructors } = props; @@ -269,7 +269,7 @@ function GPACell(props: GPACellProps) {