* fix: update CourseCellColorPicker.tsx background to white * feat: add color picker to CalendarCourseCell component * feat: add color picker functionality to update course colors * fix: type issues with storybook components * feat: add useColorPicker hook, isValidHexColor and updateCourseColors utilities * refactor: color picker logic and UI components * refactor: update useFlattenedCourseSchedule hook to include courseID property * refactor: update storybook calendar components with updated props * refactor: update color picker ui logic to account for position of cell * fix: revert back to error handling for invalid rgb * refactor: update jsdocs * refactor: integrate ColorPickerContext into Calendar components and update props * refactor: integrate ColorPickerContext into Calendar components and update related props * refactor: change JSDocs comments and remove unused color inversion state * refactor: update story components * feat: add functionality for selecting secondary course colors * refactor: enhance HexColorEditor to dynamically adjust tag icon color based on preview color * refactor: simplify JSDoc comment in useColorPicker hook * fix: revert Button component * refactor: update CalendarCourseCell component positioning and styling * fix: correct types in color.ts * feat: add getDarkerShade function to compute darker shades of hex colors * feat: add shadow to color picker button * fix: update button size in ColorPatch component * feat: implement debounced input for hex color editor and add useDebounce hook * chore: utilize the logical and && operator instead of the ternary operator * fix: imports and palette icon * refactor: remove unused import * fix: bug when course add fails with custom colors * chore: run lint * chore: run check-types * feat: add HSL color type and conversion functions * refactor: rename colorway to theme * fix: hide color picker on screenshot * fix: undo important syntax * refactor: rename SomeFunction to DebouncedCallback * refactor: remove inner function * refactor: update return type to DebouncedCallback * fix: adjust sizes for hash and palette button * feat: create tests for hexToHSL and isValidHexColor * refactor: update parameter type to use HexColor * fix: increase size of palette button * fix: update dependency array for hex code debounce * fix: change colorPickerRef element ref --------- Co-authored-by: doprz <52579214+doprz@users.noreply.github.com>
149 lines
4.9 KiB
TypeScript
149 lines
4.9 KiB
TypeScript
import { Course, Status } from '@shared/types/Course';
|
||
import Instructor from '@shared/types/Instructor';
|
||
import { getCourseColors } from '@shared/util/colors';
|
||
import type { Meta, StoryObj } from '@storybook/react';
|
||
import CalendarBottomBar from '@views/components/calendar/CalendarBottomBar';
|
||
import type { CalendarGridCourse } from '@views/hooks/useFlattenedCourseSchedule';
|
||
import React from 'react';
|
||
|
||
const exampleGovCourse: Course = new Course({
|
||
courseName: 'Nope',
|
||
creditHours: 3,
|
||
department: 'GOV',
|
||
description: ['nah', 'aint typing this', 'corndog'],
|
||
flags: ['no flag for you >:)'],
|
||
core: ['American and Texas Government'],
|
||
fullName: 'GOV 312L Something something',
|
||
instructionMode: 'Online',
|
||
instructors: [
|
||
new Instructor({
|
||
firstName: 'Bevo',
|
||
lastName: 'Barrymore',
|
||
fullName: 'Bevo Barrymore',
|
||
}),
|
||
],
|
||
isReserved: false,
|
||
number: '312L',
|
||
schedule: {
|
||
meetings: [],
|
||
},
|
||
scrapedAt: Date.now(),
|
||
semester: {
|
||
code: '12345',
|
||
season: 'Spring',
|
||
year: 2024,
|
||
},
|
||
status: Status.OPEN,
|
||
uniqueId: 12345,
|
||
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
|
||
colors: getCourseColors('red', 500),
|
||
});
|
||
|
||
const examplePsyCourse: Course = new Course({
|
||
courseName: 'Nope Again',
|
||
creditHours: 3,
|
||
department: 'PSY',
|
||
description: ['nah', 'aint typing this', 'corndog'],
|
||
flags: ['no flag for you >:)'],
|
||
core: ['Social and Behavioral Sciences'],
|
||
fullName: 'PSY 317L Yada yada',
|
||
instructionMode: 'Online',
|
||
scrapedAt: Date.now(),
|
||
instructors: [
|
||
new Instructor({
|
||
firstName: 'Bevo',
|
||
lastName: 'Etz',
|
||
fullName: 'Bevo Etz',
|
||
}),
|
||
],
|
||
isReserved: false,
|
||
number: '317L',
|
||
schedule: {
|
||
meetings: [],
|
||
},
|
||
semester: {
|
||
code: '12346',
|
||
season: 'Spring',
|
||
year: 2024,
|
||
},
|
||
status: Status.CLOSED,
|
||
uniqueId: 12346,
|
||
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
|
||
colors: getCourseColors('blue', 500),
|
||
});
|
||
|
||
const meta = {
|
||
title: 'Components/Calendar/CalendarBottomBar',
|
||
component: CalendarBottomBar,
|
||
parameters: {
|
||
layout: 'centered',
|
||
},
|
||
tags: ['autodocs'],
|
||
argTypes: {},
|
||
} satisfies Meta<typeof CalendarBottomBar>;
|
||
export default meta;
|
||
|
||
type Story = StoryObj<typeof meta>;
|
||
|
||
export const Default: Story = {
|
||
args: {
|
||
courseCells: [
|
||
{
|
||
async: true,
|
||
calendarGridPoint: { dayIndex: -1, endIndex: -1, startIndex: -1 },
|
||
componentProps: {
|
||
courseDeptAndInstr: `${exampleGovCourse.department} ${exampleGovCourse.number} – ${exampleGovCourse.instructors[0]!.lastName}`,
|
||
status: exampleGovCourse.status,
|
||
blockData: {
|
||
calendarGridPoint: { dayIndex: -1, endIndex: -1, startIndex: -1 },
|
||
componentProps: {
|
||
courseDeptAndInstr: `${exampleGovCourse.department} ${exampleGovCourse.number} – ${exampleGovCourse.instructors[0]!.lastName}`,
|
||
status: exampleGovCourse.status,
|
||
blockData: {} as CalendarGridCourse,
|
||
},
|
||
course: exampleGovCourse,
|
||
async: true,
|
||
},
|
||
},
|
||
course: exampleGovCourse,
|
||
},
|
||
{
|
||
async: true,
|
||
calendarGridPoint: { dayIndex: -1, endIndex: -1, startIndex: -1 },
|
||
componentProps: {
|
||
courseDeptAndInstr: `${examplePsyCourse.department} ${examplePsyCourse.number} – ${examplePsyCourse.instructors[0]!.lastName}`,
|
||
status: examplePsyCourse.status,
|
||
blockData: {
|
||
calendarGridPoint: { dayIndex: -1, endIndex: -1, startIndex: -1 },
|
||
componentProps: {
|
||
courseDeptAndInstr: `${examplePsyCourse.department} ${examplePsyCourse.number} – ${examplePsyCourse.instructors[0]!.lastName}`,
|
||
status: examplePsyCourse.status,
|
||
blockData: {} as CalendarGridCourse,
|
||
},
|
||
course: examplePsyCourse,
|
||
async: true,
|
||
},
|
||
},
|
||
course: examplePsyCourse,
|
||
},
|
||
],
|
||
setCourse: () => {},
|
||
},
|
||
render: props => (
|
||
<div className='outline-red outline w-292.5!'>
|
||
<CalendarBottomBar {...props} />
|
||
</div>
|
||
),
|
||
};
|
||
export const Empty: Story = {
|
||
args: {
|
||
courseCells: [],
|
||
setCourse: () => {},
|
||
},
|
||
render: props => (
|
||
<div className='outline-red outline w-292.5!'>
|
||
<CalendarBottomBar {...props} />
|
||
</div>
|
||
),
|
||
};
|