diff --git a/src/views/components/calendar/Calendar.tsx b/src/views/components/calendar/Calendar.tsx index 5525646b..8fde938c 100644 --- a/src/views/components/calendar/Calendar.tsx +++ b/src/views/components/calendar/Calendar.tsx @@ -33,6 +33,8 @@ import CalendarFooter from './CalendarFooter'; */ export default function Calendar(): ReactNode { const { courseCells, activeSchedule } = useFlattenedCourseSchedule(); + const asyncCourseCells = courseCells.filter(block => block.async); + const displayBottomBar = asyncCourseCells && asyncCourseCells.length > 0; const [course, setCourse] = useState(useCourseFromUrl()); @@ -85,7 +87,7 @@ export default function Calendar(): ReactNode { return (
-
+
-
+
diff --git a/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx b/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx index 8990cb56..07e608a5 100644 --- a/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx +++ b/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx @@ -5,6 +5,7 @@ import { Button } from '@views/components/common/Button'; import DialogProvider from '@views/components/common/DialogProvider/DialogProvider'; import Divider from '@views/components/common/Divider'; import { ExtensionRootWrapper, styleResetClass } from '@views/components/common/ExtensionRoot/ExtensionRoot'; +import { LargeLogo } from '@views/components/common/LogoIcon'; import ScheduleTotalHoursAndCourses from '@views/components/common/ScheduleTotalHoursAndCourses'; import useSchedules from '@views/hooks/useSchedules'; import clsx from 'clsx'; @@ -39,6 +40,9 @@ export default function CalendarHeader({ sidebarOpen, onSidebarToggle }: Calenda /> )} + + +
{ * @param calendarRef - The reference to the calendar component. */ export const saveCalAsPng = () => { + const WIDTH_PX = 1165; + const HEIGHT_PX = 754; + const SCALE = 2; + const rootNode = document.createElement('div'); rootNode.style.backgroundColor = 'white'; rootNode.style.position = 'fixed'; rootNode.style.zIndex = '1000'; rootNode.style.top = '-10000px'; rootNode.style.left = '-10000px'; - rootNode.style.width = '1165px'; - rootNode.style.height = '754px'; + rootNode.style.width = `${WIDTH_PX}px`; + rootNode.style.height = `${HEIGHT_PX}px`; document.body.appendChild(rootNode); const clonedNode = document.querySelector('#root')!.cloneNode(true) as HTMLDivElement; clonedNode.style.backgroundColor = 'white'; (clonedNode.firstChild as HTMLDivElement).classList.add('screenshot-in-progress'); - return new Promise((resolve, reject) => { - requestAnimationFrame(async () => { - rootNode.appendChild(clonedNode); + const calendarTarget = clonedNode.querySelector('.screenshot\\:calendar-target') as HTMLDivElement; + calendarTarget.style.width = `${WIDTH_PX}px`; + calendarTarget.style.height = `${HEIGHT_PX}px`; + return new Promise((resolve, reject) => { + rootNode.appendChild(clonedNode); + requestAnimationFrame(async () => { try { const screenshotBlob = await toBlob(clonedNode, { cacheBust: true, - canvasWidth: 1165 * 2, - canvasHeight: 754 * 2, + canvasWidth: WIDTH_PX * SCALE, + canvasHeight: HEIGHT_PX * SCALE, skipAutoScale: true, - pixelRatio: 2, + pixelRatio: SCALE, }); if (!screenshotBlob) {