diff --git a/src/stories/injected/CoursePopup.stories.ts b/src/stories/injected/CoursePopup.stories.ts index 9245a6ea..d7a6dd2d 100644 --- a/src/stories/injected/CoursePopup.stories.ts +++ b/src/stories/injected/CoursePopup.stories.ts @@ -1,99 +1,99 @@ +import type { Meta, StoryObj } from '@storybook/react'; import { Course, Status } from 'src/shared/types/Course'; import { CourseMeeting } from 'src/shared/types/CourseMeeting'; import { UserSchedule } from 'src/shared/types/UserSchedule'; import CoursePopup from 'src/views/components/injected/CoursePopup/CoursePopup'; -import type { Meta, StoryObj } from '@storybook/react'; const exampleCourse: Course = new Course({ - courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB', - creditHours: 3, - department: 'C S', - description: [ - 'Problem solving and fundamental algorithms for various applications in science, business, and on the World Wide Web, and introductory programming in a modern object-oriented programming language.', - 'Only one of the following may be counted: Computer Science 303E, 312, 312H. Credit for Computer Science 303E may not be earned after a student has received credit for Computer Science 314, or 314H. May not be counted toward a degree in computer science.', - 'May be counted toward the Quantitative Reasoning flag requirement.', - 'Designed to accommodate 100 or more students.', - 'Taught as a Web-based course.', - ], - flags: ['Quantitative Reasoning'], - fullName: 'C S 303E ELEMS OF COMPTRS/PROGRAMMNG-WB', - instructionMode: 'Online', - instructors: [], - isReserved: false, - number: '303E', - schedule: { - meetings: [ - new CourseMeeting({ - days: ['Tuesday', 'Thursday'], - endTime: 660, - startTime: 570, - }), + courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB', + creditHours: 3, + department: 'C S', + description: [ + 'Problem solving and fundamental algorithms for various applications in science, business, and on the World Wide Web, and introductory programming in a modern object-oriented programming language.', + 'Only one of the following may be counted: Computer Science 303E, 312, 312H. Credit for Computer Science 303E may not be earned after a student has received credit for Computer Science 314, or 314H. May not be counted toward a degree in computer science.', + 'May be counted toward the Quantitative Reasoning flag requirement.', + 'Designed to accommodate 100 or more students.', + 'Taught as a Web-based course.', ], - }, - semester: { - code: '12345', - season: 'Spring', - year: 2024, - }, - status: Status.CANCELLED, - uniqueId: 12345, - url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/', + flags: ['Quantitative Reasoning'], + fullName: 'C S 303E ELEMS OF COMPTRS/PROGRAMMNG-WB', + instructionMode: 'Online', + instructors: [], + isReserved: false, + number: '303E', + schedule: { + meetings: [ + new CourseMeeting({ + days: ['Tuesday', 'Thursday'], + endTime: 660, + startTime: 570, + }), + ], + }, + semester: { + code: '12345', + season: 'Spring', + year: 2024, + }, + status: Status.CANCELLED, + uniqueId: 12345, + url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/', }); const exampleSchedule: UserSchedule = new UserSchedule({ - courses: [exampleCourse], - name: 'Example Schedule', + courses: [exampleCourse], + name: 'Example Schedule', }); const meta = { - title: 'Components/Injected/CoursePopup', - component: CoursePopup, - // tags: ['autodocs'], - args: { - course: exampleCourse, - activeSchedule: exampleSchedule, - }, - argTypes: { - course: { - control: { - type: 'other', - }, + title: 'Components/Injected/CoursePopup', + component: CoursePopup, + // tags: ['autodocs'], + args: { + course: exampleCourse, + activeSchedule: exampleSchedule, }, - activeSchedule: { - control: { - type: 'other', - }, + argTypes: { + course: { + control: { + type: 'other', + }, + }, + activeSchedule: { + control: { + type: 'other', + }, + }, }, - }, - parameters: { - design: { - type: 'figma', - url: 'https://www.figma.com/file/8tsCay2FRqctrdcZ3r9Ahw/UTRP?type=design&node-id=602-1879&mode=design&t=BoS5xBrpSsjgQXqv-11', + parameters: { + design: { + type: 'figma', + url: 'https://www.figma.com/file/8tsCay2FRqctrdcZ3r9Ahw/UTRP?type=design&node-id=602-1879&mode=design&t=BoS5xBrpSsjgQXqv-11', + }, }, - }, } satisfies Meta; export default meta; type Story = StoryObj; export const Open: Story = { - args: { - course: new Course({ ...exampleCourse, status: Status.OPEN }), - activeSchedule: new UserSchedule({ - courses: [], - name: 'Example Schedule', - }), - }, + args: { + course: new Course({ ...exampleCourse, status: Status.OPEN }), + activeSchedule: new UserSchedule({ + courses: [], + name: 'Example Schedule', + }), + }, }; export const Closed: Story = { - args: { - course: new Course({ ...exampleCourse, status: Status.CLOSED }), - }, + args: { + course: new Course({ ...exampleCourse, status: Status.CLOSED }), + }, }; export const Cancelled: Story = { - args: { - course: new Course({ ...exampleCourse, status: Status.CANCELLED }), - }, + args: { + course: new Course({ ...exampleCourse, status: Status.CANCELLED }), + }, }; diff --git a/src/stories/injected/CoursePopup2.stories.ts b/src/stories/injected/CoursePopup2.stories.ts index 6a48fcbd..5765b890 100644 --- a/src/stories/injected/CoursePopup2.stories.ts +++ b/src/stories/injected/CoursePopup2.stories.ts @@ -1,16 +1,67 @@ -import { Meta } from '@storybook/react'; -import { Course } from 'src/shared/types/Course'; +import type { Meta, StoryObj } from '@storybook/react'; +import { Course, Status } from 'src/shared/types/Course'; +import { CourseMeeting, DAY_MAP } from 'src/shared/types/CourseMeeting'; +import { CourseSchedule } from 'src/shared/types/CourseSchedule'; +import Instructor from 'src/shared/types/Instructor'; -const testCourse: Course = { - -} +import CoursePopup2 from 'src/views/components/injected/CoursePopup2/CoursePopup2'; + +const exampleCourse: Course = new Course({ + uniqueId: 47280, + number: '331C', + fullName: "BVO 331C Bevo's Seminar Longhorn Care", + courseName: "Bevo's Seminar Longhorn Care", + department: 'BVO', + creditHours: 3, + status: Status.OPEN, + instructors: [new Instructor({ fullName: "Hook'em", firstName: '', lastName: "Hook'em" })], + isReserved: true, + description: [ + 'Restricted to Students in the School of Longhorn Enthusiasts', + 'Immerse yourself in the daily routine of a longhorn—sunrise pasture walks and the best shady spots for a midday siesta. Understand the behavioral science behind our mascot’s stoic demeanor during games.', + 'BVO 311C and 312H may not both be counted.', + 'Prerequisite: Grazing 311 or 311H.', + 'May be counted toward the Independent Inquiry flag requirement. May be counted toward the Writing flag requirement.', + 'Offered on the letter-grade basis only.', + ], + schedule: new CourseSchedule({ + meetings: [ + new CourseMeeting({ + days: [DAY_MAP.T, DAY_MAP.TH], + startTime: 480, + endTime: 570, + location: { building: 'UTC', room: '123' }, + }), + new CourseMeeting({ + days: [DAY_MAP.TH], + startTime: 570, + endTime: 630, + location: { building: 'JES', room: '123' }, + }), + ], + }), + url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/', + flags: ['Writing', 'Independent Inquiry'], + instructionMode: 'In Person', + semester: { + year: 2024, + season: 'Spring', + }, +}); const meta: Meta = { + title: 'Components/Injected/CoursePopup2', component: CoursePopup2, + argTypes: { + onClose: { action: 'onClose' }, + }, }; export default meta; -type Story = StoryObj; -export const Open: Story = { +type Story = StoryObj; +export const Default: Story = { + args: { + course: exampleCourse, + }, }; diff --git a/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx b/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx index ffd8478b..47a7274a 100644 --- a/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx +++ b/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx @@ -1,21 +1,75 @@ import React from 'react'; import { Course } from 'src/shared/types/Course'; -import Text from '../../common/Text/Text'; import { Button } from '../../common/Button/Button'; +import Icon from '../../common/Icon/Icon'; +import Text from '../../common/Text/Text'; interface CourseHeadingAndActionsProps { course: Course; + onClose: () => void; } -const CourseHeadingAndActions = ({ course }: CourseHeadingAndActionsProps) => { - const { courseName, department, number, uniqueId } = course; +const CourseHeadingAndActions = ({ course, onClose }: CourseHeadingAndActionsProps) => { + const { courseName, department, number, uniqueId, instructors, flags, schedule } = course; + const instructorString = instructors + .map(instructor => { + const firstInitial = instructor.firstName.length > 0 ? `${instructor.firstName.charAt(0)}. ` : ''; + return `${firstInitial}${instructor.lastName}`; + }) + .join(', '); return (
-
- - {courseName} ({department} {number}) - - +
+
+ + {courseName} ({department} {number}) + + {/* TODO: change this button, include the left icon */} + + +
+
+ + with {instructorString} + +
+ {flags.map(flag => ( +
+ {/* get the first letter of each word in flag */} + + {flag + .split(' ') + .map(word => word.charAt(0)) + .join('')} + +
+ ))} +
+
+
+ {schedule.meetings.map(meeting => ( + + {meeting.getDaysString({ format: 'long', separator: 'long' })}{' '} + {meeting.getTimeString({ separator: ' to ', capitalize: false })} + {meeting.location && ( + <> + {` in `} + + {meeting.location.building} + + + )} + + ))} +
+
+
+ +
); diff --git a/src/views/components/injected/CoursePopup2/CoursePopup2.tsx b/src/views/components/injected/CoursePopup2/CoursePopup2.tsx index 4a432b09..2452f0d6 100644 --- a/src/views/components/injected/CoursePopup2/CoursePopup2.tsx +++ b/src/views/components/injected/CoursePopup2/CoursePopup2.tsx @@ -1,20 +1,20 @@ +import Popup from '@views/components/common/Popup/Popup'; import React from 'react'; import { Course } from 'src/shared/types/Course'; import { UserSchedule } from 'src/shared/types/UserSchedule'; -import Popup from '../../common/Popup/Popup'; import CourseHeadingAndActions from './CourseHeadingAndActions'; interface CoursePopup2Props { course: Course; activeSchedule?: UserSchedule; + onClose: () => void; } -const CoursePopup2 = ({ course, activeSchedule }: CoursePopup2Props) => ( - +const CoursePopup2 = ({ course, activeSchedule, onClose }: CoursePopup2Props) => ( +
- +
); - export default CoursePopup2; diff --git a/unocss.config.ts b/unocss.config.ts index a5cadfc9..092a1f5d 100644 --- a/unocss.config.ts +++ b/unocss.config.ts @@ -24,7 +24,7 @@ export default defineConfig({ }, colors: { ut: { - 'burnt-orange': '#BF5700', + burntorange: '#BF5700', black: '#333F48', orange: '#f8971f', yellow: '#ffd600',