diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoBar.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoBar.tsx index dd8fa9f1a..e42625fd1 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoBar.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoBar.tsx @@ -187,7 +187,9 @@ const CourseInfoBar = (props: CourseInfoBarProps) => { void togglePopover(currentTarget); }} > - {`${deptCode} ${courseNumber} | ${courseTitle}`} + + {`${deptCode} ${courseNumber} | ${courseTitle}`} + (null); - const isMobileScreen = useMediaQuery(`(max-width: ${MOBILE_BREAKPOINT})`); const [isClicked, setIsClicked] = useState(false); useEffect(() => { @@ -65,11 +67,14 @@ function CourseInfoButton({ } }; + const scheduleManagementWidth = useScheduleManagementStore((state) => state.scheduleManagementWidth); + const compact = + isMobileScreen || (scheduleManagementWidth && scheduleManagementWidth < theme.breakpoints.values.xs); + return (
{popupContent && ( diff --git a/apps/antalmanac/src/routes/Home.tsx b/apps/antalmanac/src/routes/Home.tsx index 6ed8aed5c..c3f1b9b91 100644 --- a/apps/antalmanac/src/routes/Home.tsx +++ b/apps/antalmanac/src/routes/Home.tsx @@ -1,7 +1,7 @@ import DateFnsUtils from '@date-io/date-fns'; import { MuiPickersUtilsProvider } from '@material-ui/pickers'; -import { CssBaseline, useMediaQuery, useTheme } from '@mui/material'; -import { Stack } from '@mui/material'; +import { CssBaseline, useMediaQuery, useTheme, Stack } from '@mui/material'; +import { useCallback, useEffect, useRef } from 'react'; import Split from 'react-split'; import Calendar from '$components/Calendar/CalendarRoot'; @@ -10,6 +10,7 @@ import NotificationSnackbar from '$components/NotificationSnackbar'; import PatchNotes from '$components/PatchNotes'; import ScheduleManagement from '$components/SharedRoot'; import { Tutorial } from '$components/Tutorial'; +import { useScheduleManagementStore } from '$stores/ScheduleManagementStore'; function MobileHome() { return ( @@ -22,6 +23,29 @@ function MobileHome() { function DesktopHome() { const theme = useTheme(); + const setScheduleManagementWidth = useScheduleManagementStore((state) => state.setScheduleManagementWidth); + + const scheduleManagementRef = useRef(); + + const handleDrag = useCallback(() => { + const scheduleManagementElement = scheduleManagementRef.current; + if (!scheduleManagementElement) { + return; + } + + const elementWidth = scheduleManagementElement.getBoundingClientRect().width; + setScheduleManagementWidth(elementWidth); + }, [setScheduleManagementWidth]); + + useEffect(() => { + handleDrag(); + + window.addEventListener('resize', handleDrag); + + return () => { + window.removeEventListener('resize', handleDrag); + }; + }, [handleDrag]); return ( <> @@ -30,7 +54,7 @@ function DesktopHome() { - + diff --git a/apps/antalmanac/src/stores/HoveredStore.ts b/apps/antalmanac/src/stores/HoveredStore.ts index 66b001116..0b1980ed8 100644 --- a/apps/antalmanac/src/stores/HoveredStore.ts +++ b/apps/antalmanac/src/stores/HoveredStore.ts @@ -1,5 +1,4 @@ -import { AASection, ScheduleCourse } from '@packages/antalmanac-types'; -import { CourseDetails } from '@packages/antalmanac-types'; +import { AASection, ScheduleCourse, CourseDetails } from '@packages/antalmanac-types'; import { create } from 'zustand'; import { calendarizeCourseEvents, calendarizeFinals } from './calendarizeHelpers'; diff --git a/apps/antalmanac/src/stores/ScheduleManagementStore.ts b/apps/antalmanac/src/stores/ScheduleManagementStore.ts new file mode 100644 index 000000000..c67f6f443 --- /dev/null +++ b/apps/antalmanac/src/stores/ScheduleManagementStore.ts @@ -0,0 +1,11 @@ +import { create } from 'zustand'; + +interface ScheduleManagementStore { + scheduleManagementWidth: number | null; + setScheduleManagementWidth: (width: number) => void; +} + +export const useScheduleManagementStore = create((set) => ({ + scheduleManagementWidth: null, + setScheduleManagementWidth: (width) => set({ scheduleManagementWidth: width }), +}));