diff --git a/src/app/OverviewPage.tsx b/src/app/OverviewPage.tsx index 094b0df..8d98b3e 100644 --- a/src/app/OverviewPage.tsx +++ b/src/app/OverviewPage.tsx @@ -1,9 +1,24 @@ import {SubjectComparisonCard} from "@/app/cards/subjectComparisonCard"; import {CalendarOverviewCard} from "@/app/cards/calendarOverviewCard"; -import {OverviewConfig} from "@/app/overviewConfig"; import {SubjectOverviewCard} from "@/app/cards/subjectOverviewCard"; import {getData} from "@/app/fetchData"; +export interface OverviewConfig { + title: string, + + subjects: { + title?: string, + projectId: number, + }[], + + goalHours: number, + + timePeriod: { + start: string, + end: string + }, +} + export default async function OverviewPage({config}: { config: OverviewConfig }) { @@ -25,6 +40,7 @@ export default async function OverviewPage({config}: { diff --git a/src/app/cards/calendarOverviewCard.tsx b/src/app/cards/calendarOverviewCard.tsx index 82d1047..8ba32de 100644 --- a/src/app/cards/calendarOverviewCard.tsx +++ b/src/app/cards/calendarOverviewCard.tsx @@ -8,12 +8,15 @@ import '../calendar-styles.css' import {Tooltip} from 'react-tooltip'; import {Data} from "@/app/fetchData"; -const dailyGoal = 4; const granularity = 4; -function computeCompletionShade(value: number) { +function computeCompletionShade(value: number, dailyGoal: number) { const linearValue = Math.round((value / dailyGoal) * granularity); + + // If we did something, but not enough to reach the first level, return 1 if (linearValue == 0 && value > 0) return 1; + + // Clamp to the granularity if (linearValue > granularity) return granularity; return linearValue; } @@ -50,10 +53,12 @@ function useCalendarData(data: Data, initialDate: Date, endDate: Date) { export function CalendarOverviewCard({ data, + goal, startTime, - endTime + endTime, }: { data: Data, + goal: number, startTime: string, endTime: string, }) { @@ -69,7 +74,7 @@ export function CalendarOverviewCard({ startDate={initialDate} endDate={endDate} values={calendarData} - classForValue={value => `color-github-${computeCompletionShade(value?.count ?? 0)}`} + classForValue={value => `color-github-${computeCompletionShade(value?.count ?? 0, goal)}`} tooltipDataAttrs={(value: any) => { return value.date ? { 'data-tooltip-id': `calendar-tooltip`, diff --git a/src/app/fetchData.ts b/src/app/fetchData.ts index 5ea131b..ef11160 100644 --- a/src/app/fetchData.ts +++ b/src/app/fetchData.ts @@ -1,6 +1,7 @@ "use server"; -import {OverviewConfig} from "@/app/overviewConfig"; + +import {OverviewConfig} from "@/app/OverviewPage"; export interface Data { projects: { diff --git a/src/app/overviewConfig.ts b/src/app/overviewConfig.ts index 4f24dd0..8b13789 100644 --- a/src/app/overviewConfig.ts +++ b/src/app/overviewConfig.ts @@ -1,40 +1 @@ -export interface OverviewConfig { - title: string, - subjects: { - title?: string, - projectId: number, - }[], - - goalHours: number, - - timePeriod: { - start: string, - end: string - }, -} - -export const semester1Revision: OverviewConfig = { - title: 'Semester 1 Revision', - goalHours: 4, - subjects: [ - { - projectId: 195482340, - }, - { - title: 'Measure Theory', - projectId: 195519024, - }, - { - title: 'Quantum Mechanics', - projectId: 195518593, - }, - { - projectId: 195754611, - } - ], - timePeriod: { - start: "2023-12-15T00:00:00.000Z", - end: "2024-01-25T00:00:00.000Z" - } -} diff --git a/src/app/page.tsx b/src/app/page.tsx index 9edbe6e..a060f66 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,6 +1,18 @@ -import OverviewPage from "@/app/OverviewPage"; -import {semester1Revision} from "@/app/overviewConfig"; +import Link from "next/link"; export default function Home() { - return + return
+

Work Tracker

+ +
    +
  1. + + Semester 1 Revision + +
  2. +
  3. + Semester 2 +
  4. +
+
} diff --git a/src/app/sem1-revision/page.tsx b/src/app/sem1-revision/page.tsx new file mode 100644 index 0000000..3ca5a76 --- /dev/null +++ b/src/app/sem1-revision/page.tsx @@ -0,0 +1,30 @@ +import OverviewPage, {OverviewConfig} from "@/app/OverviewPage"; + +const semester1Revision: OverviewConfig = { + title: 'Semester 1 Revision', + goalHours: 4, + subjects: [ + { + projectId: 195482340, + }, + { + title: 'Measure Theory', + projectId: 195519024, + }, + { + title: 'Quantum Mechanics', + projectId: 195518593, + }, + { + projectId: 195754611, + } + ], + timePeriod: { + start: "2023-12-15T00:00:00.000Z", + end: "2024-01-25T00:00:00.000Z" + } +} + +export default function Home() { + return +} diff --git a/src/app/sem2/page.tsx b/src/app/sem2/page.tsx index 3de8a71..2e1bae9 100644 --- a/src/app/sem2/page.tsx +++ b/src/app/sem2/page.tsx @@ -1,9 +1,8 @@ -import OverviewPage from "@/app/OverviewPage"; -import {OverviewConfig} from "@/app/overviewConfig"; +import OverviewPage, {OverviewConfig} from "@/app/OverviewPage"; const semester2: OverviewConfig = { title: 'Semester 2', - goalHours: 4, + goalHours: 7.5, subjects: [ { projectId: 195754611,