From 249e83586fc6426e729b12bcbf4daf5db658a522 Mon Sep 17 00:00:00 2001 From: Samuel Gunter Date: Mon, 20 May 2024 22:15:41 -0700 Subject: [PATCH 1/2] feat: popout icon for ccip in calendar --- src/views/components/calendar/Calendar.tsx | 68 ++++++++++--------- .../HeadingAndActions.tsx | 15 +++- src/views/contexts/CalendarContext.ts | 20 ++++++ 3 files changed, 70 insertions(+), 33 deletions(-) create mode 100644 src/views/contexts/CalendarContext.ts diff --git a/src/views/components/calendar/Calendar.tsx b/src/views/components/calendar/Calendar.tsx index 580dfeb5d..3be4b1a50 100644 --- a/src/views/components/calendar/Calendar.tsx +++ b/src/views/components/calendar/Calendar.tsx @@ -7,9 +7,11 @@ import CalendarHeader from '@views/components/calendar/CalenderHeader'; import ImportantLinks from '@views/components/calendar/ImportantLinks'; import Divider from '@views/components/common/Divider'; import CourseCatalogInjectedPopup from '@views/components/injected/CourseCatalogInjectedPopup/CourseCatalogInjectedPopup'; +import type { CalendarData } from '@views/contexts/CalendarContext'; +import { CalendarContext } from '@views/contexts/CalendarContext'; import { useFlattenedCourseSchedule } from '@views/hooks/useFlattenedCourseSchedule'; import { MessageListener } from 'chrome-extension-toolkit'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import CalendarFooter from './CalendarFooter'; import TeamLinks from './TeamLinks'; @@ -63,40 +65,44 @@ export default function Calendar(): JSX.Element { if (course) setShowPopup(true); }, [course]); + const contextValue = useMemo(() => ({ isInCalendar: true }), []); + return ( -
- { - setShowSidebar(!showSidebar); - }} - /> -
- {showSidebar && ( -
-
- - - - - + +
+ { + setShowSidebar(!showSidebar); + }} + /> +
+ {showSidebar && ( +
+
+ + + + + +
+
- -
- )} -
-
- + )} +
+
+ +
+
-
-
- setShowPopup(false)} - open={showPopup} - afterLeave={() => setCourse(null)} - /> -
+ setShowPopup(false)} + open={showPopup} + afterLeave={() => setCourse(null)} + /> +
+ ); } diff --git a/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx b/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx index 37f04adb0..8694d36f9 100644 --- a/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx +++ b/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx @@ -7,6 +7,7 @@ import { Chip, flagMap } from '@views/components/common/Chip'; import Divider from '@views/components/common/Divider'; import Link from '@views/components/common/Link'; import Text from '@views/components/common/Text/Text'; +import { useCalendar } from '@views/contexts/CalendarContext'; import React from 'react'; import Add from '~icons/material-symbols/add'; @@ -15,6 +16,7 @@ import CloseIcon from '~icons/material-symbols/close'; import Copy from '~icons/material-symbols/content-copy'; import Description from '~icons/material-symbols/description'; import Mood from '~icons/material-symbols/mood'; +import OpenNewIcon from '~icons/material-symbols/open-in-new'; import Remove from '~icons/material-symbols/remove'; import Reviews from '~icons/material-symbols/reviews'; @@ -50,6 +52,7 @@ export default function HeadingAndActions({ course, activeSchedule, onClose }: H const { courseName, department, number: courseNumber, uniqueId, instructors, flags, schedule } = course; const courseAdded = activeSchedule.courses.some(ourCourse => ourCourse.uniqueId === uniqueId); const formattedUniqueId = uniqueId.toString().padStart(5, '0'); + const { isInCalendar } = useCalendar(); const getInstructorFullName = (instructor: Instructor) => { const { firstName = '', lastName = '' } = instructor; @@ -179,8 +182,16 @@ export default function HeadingAndActions({ course, activeSchedule, onClose }: H