From 6a20911ae964ea8ba072460e4064a020627ca2cd Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Wed, 25 Dec 2024 13:58:43 +0530 Subject: [PATCH] feat: added warm-up calculator for exercises --- .../(components)/SetTimerComponent.svelte | 3 + .../(components)/WarmUpDialog.svelte | 123 ++++++++++++++++++ .../(components)/WorkoutExerciseCard.svelte | 4 + .../workouts/manage/exercises/+page.svelte | 2 + .../workouts/manage/workoutRunes.svelte.ts | 25 +++- 5 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 src/routes/workouts/manage/exercises/(components)/WarmUpDialog.svelte diff --git a/src/routes/workouts/manage/exercises/(components)/SetTimerComponent.svelte b/src/routes/workouts/manage/exercises/(components)/SetTimerComponent.svelte index 4dd3920e..af7f41fa 100644 --- a/src/routes/workouts/manage/exercises/(components)/SetTimerComponent.svelte +++ b/src/routes/workouts/manage/exercises/(components)/SetTimerComponent.svelte @@ -3,6 +3,7 @@ import * as Popover from '$lib/components/ui/popover'; import { cn } from '$lib/utils'; import TimerIcon from 'virtual:icons/lucide/timer'; + import MinusIcon from 'virtual:icons/lucide/minus'; import { workoutRunes } from '../../workoutRunes.svelte'; let lastCompletedSet = $derived( @@ -42,6 +43,8 @@ {#if lastCompletedSet} {secondsToMS(secondsSinceLastSet)} + {:else} + {/if} diff --git a/src/routes/workouts/manage/exercises/(components)/WarmUpDialog.svelte b/src/routes/workouts/manage/exercises/(components)/WarmUpDialog.svelte new file mode 100644 index 00000000..a56153d5 --- /dev/null +++ b/src/routes/workouts/manage/exercises/(components)/WarmUpDialog.svelte @@ -0,0 +1,123 @@ + + + + {#snippet description()} + {exercise?.name} + {/snippet} + {#if exercise} +
+
+ + +
+
+ + +
+ (oneRepMaxCalculatorOpen = v)}> + + + + + +
+ + +
+
+ + +
+ + +
+
+ + + {/if} + {#if warmUpSets} + + + + + Reps + Load + %RM + + + + {#each warmUpSets as warmUpSet, idx} + + {idx + 1} + {warmUpSet.reps} + {warmUpSet.load.toFixed(1)} + {warmUpSet.oneRMPercentage} + + {/each} + + + {/if} +
diff --git a/src/routes/workouts/manage/exercises/(components)/WorkoutExerciseCard.svelte b/src/routes/workouts/manage/exercises/(components)/WorkoutExerciseCard.svelte index 50409d9b..513d11dc 100644 --- a/src/routes/workouts/manage/exercises/(components)/WorkoutExerciseCard.svelte +++ b/src/routes/workouts/manage/exercises/(components)/WorkoutExerciseCard.svelte @@ -11,6 +11,7 @@ import SkipIcon from 'virtual:icons/lucide/skip-forward'; import DeleteIcon from 'virtual:icons/lucide/trash'; import HistoryIcon from 'virtual:icons/lucide/history'; + import ChartIcon from 'virtual:icons/lucide/chart-no-axes-column-increasing'; import { workoutRunes } from '../../workoutRunes.svelte'; import CompareComponent from './CompareComponent.svelte'; import SetsComponent from './SetsComponent.svelte'; @@ -58,6 +59,9 @@ workoutRunes.setEditingExercise(exercise)}> Edit + workoutRunes.openExerciseWarmupDialog(exercise)}> + Warm up + Skip sets left diff --git a/src/routes/workouts/manage/exercises/+page.svelte b/src/routes/workouts/manage/exercises/+page.svelte index ec297426..194a70ef 100644 --- a/src/routes/workouts/manage/exercises/+page.svelte +++ b/src/routes/workouts/manage/exercises/+page.svelte @@ -17,6 +17,7 @@ import DndComponent from './(components)/DndComponent.svelte'; import ExerciseHistorySheet from './(components)/ExerciseHistorySheet.svelte'; import SetTimerComponent from './(components)/SetTimerComponent.svelte'; + import WarmUpDialog from './(components)/WarmUpDialog.svelte'; let { data } = $props(); let reordering = $state(false); @@ -169,3 +170,4 @@ + diff --git a/src/routes/workouts/manage/workoutRunes.svelte.ts b/src/routes/workouts/manage/workoutRunes.svelte.ts index 8532782e..8e2bcd98 100644 --- a/src/routes/workouts/manage/workoutRunes.svelte.ts +++ b/src/routes/workouts/manage/workoutRunes.svelte.ts @@ -1,11 +1,11 @@ import type { MesocycleExerciseTemplateWithoutIdsOrIndex } from '$lib/components/mesocycleAndExerciseSplit/commonTypes'; -import type { Prisma } from '@prisma/client'; -import type { FullWorkoutWithMesoData } from '../[workoutId]/+page.server'; import type { RouterOutputs } from '$lib/trpc/router'; import { type WorkoutExerciseInProgress, createWorkoutExerciseInProgressFromMesocycleExerciseTemplate } from '$lib/utils/workoutUtils'; +import type { Prisma } from '@prisma/client'; +import type { FullWorkoutWithMesoData } from '../[workoutId]/+page.server'; export type PreviousWorkoutData = RouterOutputs['workouts']['getWorkoutExercisesWithPreviousData']['previousWorkoutData']; @@ -21,6 +21,8 @@ function createWorkoutRunes() { let exerciseHistorySheetOpen = $state(false); let exerciseHistorySheetName: string | undefined = $state(); + let exerciseWarmUpDialogOpen = $state(false); + let exerciseWarmUpDialogExercise: WorkoutExerciseInProgress | undefined = $state(); if (globalThis.localStorage) { const savedState = localStorage.getItem('workoutRunes'); @@ -88,6 +90,12 @@ function createWorkoutRunes() { exerciseHistorySheetOpen = true; } + function openExerciseWarmupDialog(exercise: WorkoutExerciseInProgress) { + if (workoutExercises === null) return; + exerciseWarmUpDialogOpen = true; + exerciseWarmUpDialogExercise = exercise; + } + function copyExerciseSetNumbersFromHistory( exerciseFromHistory: Prisma.WorkoutExerciseGetPayload<{ include: { sets: { include: { miniSets: true } } }; @@ -185,6 +193,18 @@ function createWorkoutRunes() { set exerciseHistorySheetOpen(value) { exerciseHistorySheetOpen = value; }, + get exerciseWarmUpDialogOpen() { + return exerciseWarmUpDialogOpen; + }, + set exerciseWarmUpDialogOpen(value) { + exerciseWarmUpDialogOpen = value; + }, + get exerciseWarmUpDialogExercise() { + return exerciseWarmUpDialogExercise; + }, + set exerciseWarmUpDialogExercise(value) { + exerciseWarmUpDialogExercise = value; + }, saveStoresToLocalStorage, resetStores, addExercise, @@ -193,6 +213,7 @@ function createWorkoutRunes() { deleteExercise, loadWorkout, openExerciseHistorySheet, + openExerciseWarmupDialog, copyExerciseSetNumbersFromHistory }; }