chore: lint-format-docs-tests-bugfixes (#105)
* docs: add jsdoc * feat: change enums to as const objects * chore(test): add themeColors.test.ts * fix: fix tests and bugs with strings.ts util * fix: path alias imports and tsconfig file bug * fix: remove --max-warnings 0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { CalendarCourseCellProps } from 'src/views/components/calendar/CalendarCourseCell/CalendarCourseCell';
|
||||
import type { CalendarCourseCellProps } from '@views/components/calendar/CalendarCourseCell/CalendarCourseCell';
|
||||
|
||||
import useSchedules from './useSchedules';
|
||||
|
||||
@@ -27,7 +27,12 @@ export interface CalendarGridCourse {
|
||||
totalColumns?: number;
|
||||
}
|
||||
|
||||
export const convertMinutesToIndex = (minutes: number): number => Math.floor(minutes - 420 / 30);
|
||||
/**
|
||||
* Converts minutes to an index value.
|
||||
* @param minutes The number of minutes.
|
||||
* @returns The index value.
|
||||
*/
|
||||
export const convertMinutesToIndex = (minutes: number): number => Math.floor((minutes - 420) / 30);
|
||||
|
||||
/**
|
||||
* Get the active schedule, and convert it to be render-able into a calendar.
|
||||
|
||||
@@ -7,24 +7,26 @@ import { useEffect } from 'react';
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom hook for implementing infinite scrolling behavior.
|
||||
*
|
||||
* @param callback - The function to be called when scrolling reaches the specified threshold.
|
||||
* @param deps - Optional dependencies to be passed to the useEffect hook.
|
||||
*/
|
||||
export default function useInfiniteScroll(
|
||||
callback: () => Promise<void> | void,
|
||||
deps?: React.DependencyList | undefined
|
||||
) {
|
||||
const isScrolling = () => {
|
||||
const { innerHeight } = window;
|
||||
const { scrollTop, offsetHeight } = document.documentElement;
|
||||
if (innerHeight + scrollTop >= offsetHeight - 650) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const isScrolling = () => {
|
||||
const { innerHeight } = window;
|
||||
const { scrollTop, offsetHeight } = document.documentElement;
|
||||
if (innerHeight + scrollTop >= offsetHeight - 650) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
window.addEventListener('scroll', isScrolling, {
|
||||
passive: true,
|
||||
});
|
||||
return () => window.removeEventListener('scroll', isScrolling);
|
||||
}, deps);
|
||||
}, [deps, callback]);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ import { UserScheduleStore } from '@shared/storage/UserScheduleStore';
|
||||
import { UserSchedule } from '@shared/types/UserSchedule';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
/**
|
||||
* Custom hook that manages user schedules.
|
||||
* @returns A tuple containing the active schedule and an array of all schedules.
|
||||
*/
|
||||
export default function useSchedules(): [active: UserSchedule | null, schedules: UserSchedule[]] {
|
||||
const [schedules, setSchedules] = useState<UserSchedule[]>([]);
|
||||
const [activeIndex, setActiveIndex] = useState<number>(0);
|
||||
@@ -30,7 +34,7 @@ export default function useSchedules(): [active: UserSchedule | null, schedules:
|
||||
UserScheduleStore.removeListener(l1);
|
||||
UserScheduleStore.removeListener(l2);
|
||||
};
|
||||
}, []);
|
||||
}, [activeIndex, schedules]);
|
||||
|
||||
return [activeSchedule, schedules];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import TAB_MESSAGES from '@shared/messages/TabMessages';
|
||||
import type TAB_MESSAGES from '@shared/messages/TabMessages';
|
||||
import { createUseMessage } from 'chrome-extension-toolkit';
|
||||
|
||||
export const useTabMessage = createUseMessage<TAB_MESSAGES>();
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { ExtensionStore } from '@shared/storage/ExtensionStore';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
/**
|
||||
* Custom hook that retrieves the version from ExtensionStore and updates it when it changes.
|
||||
* @returns The current version as a string.
|
||||
*/
|
||||
export default function useVersion(): string {
|
||||
const [version, setVersion] = useState<string>('');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user