diff --git a/apps/antalmanac/src/components/PatchNotes.tsx b/apps/antalmanac/src/components/PatchNotes.tsx index eab0a78bc..601003c8e 100644 --- a/apps/antalmanac/src/components/PatchNotes.tsx +++ b/apps/antalmanac/src/components/PatchNotes.tsx @@ -51,15 +51,18 @@ function PatchNotes() { data-testid={dialogTestId} slots={{ backdrop: PatchNotesBackdrop }} > - {"What's New - August 2023"} + {"What's New - October 2023"} Features (gif of the new feature) { const [bannerVisibility, setBannerVisibility] = React.useState(true); diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoButton.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoButton.tsx index 0f54c60fd..4899f1271 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoButton.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoButton.tsx @@ -1,7 +1,7 @@ -import { Button, Popover, useMediaQuery } from '@material-ui/core'; +import { Button, Paper, Popper, useMediaQuery } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; import { ClassNameMap } from '@material-ui/core/styles/withStyles'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { MOBILE_BREAKPOINT } from '../../../globals'; import { logAnalytics } from '$lib/analytics'; @@ -34,25 +34,55 @@ function CourseInfoButton({ }: CourseInfoButtonProps) { const [popupAnchor, setPopupAnchor] = useState(null); const isMobileScreen = useMediaQuery(`(max-width: ${MOBILE_BREAKPOINT})`); + const [isClicked, setIsClicked] = useState(false); + + useEffect(() => { + // When the user clicks on the button, it triggers both onMouseEnter + // and onClick. In order to log the analytics only once, we should + // have this hook when the popupAnchor changes + if (popupAnchor) { + logAnalytics({ + category: analyticsCategory, + action: analyticsAction, + }); + } + }, [popupAnchor, analyticsCategory, analyticsAction]); + + const handleMouseEnter = (event: React.MouseEvent) => { + // If there is popup content, allow the content to be shown when the button is hovered + // Note that on mobile devices, hovering is not possible, so the popup still needs to be able + // to appear when the button is clicked + if (popupContent) { + setPopupAnchor(event.currentTarget); + } + }; + + const handleMouseLeave = () => { + if (popupContent) { + setIsClicked(false); + setPopupAnchor(null); + } + }; + return ( - <> +
{popupContent && ( - setPopupAnchor(null)} - anchorOrigin={{ - vertical: 'bottom', - horizontal: 'center', - }} - transformOrigin={{ - vertical: 'top', - horizontal: 'center', - }} - > - {popupContent} - + + {popupContent} + )} - +
); } diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx index 16616d16c..01045f8d0 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/GradesPopup.tsx @@ -57,20 +57,22 @@ function GradesPopup(props: GradesPopupProps) { const [gradeData, setGradeData] = useState(); - const width = useMemo(() => (isMobileScreen ? 300 : 500), [isMobileScreen]); + const width = useMemo(() => (isMobileScreen ? 250 : 400), [isMobileScreen]); - const height = useMemo(() => (isMobileScreen ? 200 : 300), [isMobileScreen]); + const height = useMemo(() => (isMobileScreen ? 150 : 200), [isMobileScreen]); const graphTitle = useMemo(() => { return gradeData - ? `${deptCode} ${courseNumber}${instructor ? ` — ${instructor}` : "" } | Average GPA: ${gradeData.courseGrades.averageGPA.toFixed(2)}` + ? `${deptCode} ${courseNumber}${ + instructor ? ` — ${instructor}` : '' + } | Average GPA: ${gradeData.courseGrades.averageGPA.toFixed(2)}` : 'Grades are not available for this class.'; }, [deptCode, instructor, gradeData]); const gpaString = useMemo( - () => (gradeData ? `Average GPA: ${gradeData.courseGrades.averageGPA.toFixed(2)}` : ""), + () => (gradeData ? `Average GPA: ${gradeData.courseGrades.averageGPA.toFixed(2)}` : ''), [gradeData] - ) + ); useEffect(() => { if (loading === false) { @@ -107,15 +109,15 @@ function GradesPopup(props: GradesPopupProps) { const axisColor = isDarkMode() ? '#fff' : '#111'; return ( - + {graphTitle} diff --git a/apps/antalmanac/src/stores/ColumnStore.ts b/apps/antalmanac/src/stores/ColumnStore.ts index 936fe8434..7e346eaa6 100644 --- a/apps/antalmanac/src/stores/ColumnStore.ts +++ b/apps/antalmanac/src/stores/ColumnStore.ts @@ -1,6 +1,6 @@ import { create } from 'zustand'; -import analyticsEnum, { logAnalytics } from '$lib/analytics'; import useTabStore from './TabStore'; +import analyticsEnum, { logAnalytics } from '$lib/analytics'; /** * Search results are displayed in a tabular format.