Skip to content

Commit

Permalink
Merge pull request #123 from WhyAsh5114/minor-fixes-before-release
Browse files Browse the repository at this point in the history
feat: minor improvements, docs, and fixes before release
  • Loading branch information
WhyAsh5114 authored Oct 17, 2024
2 parents 4aa264f + cba4572 commit 04d0a2c
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 18 deletions.
18 changes: 12 additions & 6 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,20 @@ export function arrayAverage(arr: number[]): number {
export function averagePercentageChange(arr: number[]): number {
if (arr.length < 2) return 0;

const totalPercentageChange = arr.slice(1).reduce((sum, current, index) => {
const previous = arr[index];
let totalPercentageChange = 0;
let numberOfIncrements = 0;

for (let i = 1; i < arr.length; i++) {
const previous = arr[i - 1];
const current = arr[i];
if (previous === 0 || current === 0) continue;

const percentageChange = ((current - previous) / previous) * 100;
return sum + (isNaN(percentageChange) ? 0 : percentageChange);
}, 0);
totalPercentageChange += isNaN(percentageChange) ? 0 : percentageChange;
numberOfIncrements++;
}

const numberOfIncrements = arr.length - 1;
return totalPercentageChange / numberOfIncrements;
return numberOfIncrements > 0 ? totalPercentageChange / numberOfIncrements : 0;
}

export function convertCamelCaseToNormal(text?: string | null): string {
Expand Down
31 changes: 24 additions & 7 deletions src/routes/(components)/layout/NavLinks.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
<script lang="ts">
import { page } from '$app/stores';
import { Button } from '$lib/components/ui/button';
import Separator from '$lib/components/ui/separator/separator.svelte';
import { cn } from '$lib/utils';
export let sheetOpen: boolean | undefined = undefined;
const linkItems: { text: string; href: string }[] = [
const linkItems: ({ text: string; href: string } | null)[] = [
{ text: 'Dashboard', href: '/dashboard' },
null,
{ text: 'Exercise splits', href: '/exercise-splits' },
{ text: 'Mesocycles', href: '/mesocycles' },
{ text: 'Workouts', href: '/workouts' },
null,
{ text: 'Docs', href: '/docs' },
{ text: 'Donations', href: '/donations' },
{ text: 'Privacy policy', href: '/privacy-policy' }
];
</script>

<ul class="mb-auto lg:mt-8">
{#each linkItems as { text, href }}
<li>
<Button class="text-foreground lg:text-base" {href} onclick={() => (sheetOpen = false)} variant="link">
{text}
</Button>
</li>
{#each linkItems as linkItem}
{#if linkItem}
<li>
<Button
class={cn('text-muted-foreground lg:text-base', {
'text-foreground': $page.url.pathname.startsWith(linkItem.href)
})}
href={linkItem.href}
onclick={() => (sheetOpen = false)}
variant="link"
>
{linkItem.text}
</Button>
</li>
{:else}
<Separator class="my-2.5 bg-foreground opacity-25" />
{/if}
{/each}
</ul>
4 changes: 2 additions & 2 deletions src/routes/dashboard/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { createContext } from '$lib/trpc/context';
import { createCaller } from '$lib/trpc/router';
import { redirect } from '@sveltejs/kit';
import { error } from 'console';

export const load = async (event) => {
event.depends('workouts:all');
const session = await event.locals.auth();

if (session === null) {
redirect(302, '/');
error(401, 'Not logged in');
}

const trpc = createCaller(await createContext(event));
Expand Down
1 change: 1 addition & 0 deletions src/routes/docs/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const prerender = true;
37 changes: 37 additions & 0 deletions src/routes/docs/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="prose prose-neutral max-w-none dark:prose-invert lg:prose-lg">
<h1>Docs</h1>
<blockquote>Just a basic overview of things work in this app, as there are some differences from V2</blockquote>

<h2>Exercise splits</h2>
<p>
An exercise split refers to how workout sessions are divided across different days to target specific muscle groups
or movement patterns. Examples: <i>Push Pull Legs</i>, <i>Upper Lower</i>, and <i>Full Body.</i>
</p>
<p>Tha app supports both synchronous (weekly) splits, and asynchronous splits (non-weekly) splits.</p>

<h2>Mesocycle</h2>
<p>
A mesocycle is a unit of training consisting of several microcycles (repeated splits), usually lasting 4-6 weeks.
The mesocycle structures progression and recovery, with increasing intensity or volume followed by deload phases to
avoid overtraining. Deload feature will be coming soon!
</p>

<h2>Workouts</h2>
<p>
A single workout, consisting of multiple exercises, each with their own sets and options. Workouts can be done with
or without an active mesocycle.
</p>
<p>Using an active mesocycle allows the app to progress performance and sets every microcycle.</p>

<h2>Mesocycle exercise split</h2>
<p>
Whenever you create a mesocycle with an exercise split, that split is actually cloned for that mesocycle. This
allows you and the app to make changes to the mesocycle's split without altering the original split.
</p>

<h2 class="italic">"I need more help!"</h2>
<p>
Feel free to <a href="https://github.com/WhyAsh5114/issues">open an issue</a> on the GitHub repository, will be glad
to help you out and add more details to the docs
</p>
</div>
4 changes: 1 addition & 3 deletions src/routes/privacy-policy/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@
<li>
<p>
<strong>Website</strong> refers to MyFit, accessible from
<a href="https://my-fit-whyash5114.vercel.app" rel="external nofollow noopener"
>https://my-fit-whyash5114.vercel.app</a
>
<a href="https://my-fit-v3.vercel.app" rel="external nofollow noopener">https://my-fit-v3.vercel.app</a>
</p>
</li>
<li>
Expand Down

0 comments on commit 04d0a2c

Please sign in to comment.