Skip to content

Commit

Permalink
Merge pull request #164 from WhyAsh5114/fixes
Browse files Browse the repository at this point in the history
Proper form restrictions
  • Loading branch information
WhyAsh5114 authored Dec 28, 2024
2 parents 15f8ae7 + b346af2 commit 829c0a6
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 46 deletions.
63 changes: 27 additions & 36 deletions src/routes/(components)/layout/ChangelogDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import { onMount } from 'svelte';
import LoaderCircle from 'virtual:icons/lucide/loader-circle';
import ReloadIcon from 'virtual:icons/lucide/refresh-ccw';
import { checkForUpdates, needRefresh, updateDataLossDialog } from './PWAFunctions.svelte';
import { needRefresh, updateDataLossDialog } from './PWAFunctions.svelte';
let open = $state(false);
let checkedForUpdate = $state(false);
let dialogText = $state<string>();
let releases = $state<{ tag_name: string; body: string }[]>([]);
Expand All @@ -27,13 +26,8 @@
) {
open = true;
await loadChangelog(changelogShownOf);
while (checkForUpdates === null) {
await new Promise((resolve) => setTimeout(resolve, 500));
}
await checkForUpdates();
}
ls.setItem('changelogShownOf', latestRelease!.tag_name);
checkedForUpdate = true;
});
async function loadChangelog(lastRelease: string) {
Expand All @@ -50,33 +44,30 @@
}
</script>

<ResponsiveDialog title="What's new?" bind:open dismissible={false}>
{#if dialogText}
<ScrollArea class="h-96">
<article class="prose prose-sm dark:prose-invert">
{@html dialogText}
</article>
</ScrollArea>
<Button
disabled={!checkedForUpdate}
class="gap-2"
onclick={() => {
if ($needRefresh) updateDataLossDialog.open = true;
else open = false;
}}
>
{#if !checkedForUpdate}
Fetching update <LoaderCircle class="animate-spin" />
{:else if $needRefresh}
{#if $needRefresh}
<ResponsiveDialog title="What's new?" bind:open dismissible={false}>
{#if dialogText}
<ScrollArea class="h-96">
<article class="prose prose-sm dark:prose-invert">
{@html dialogText}
</article>
</ScrollArea>
<Button
class="gap-2"
onclick={() => {
if ($needRefresh) {
open = false;
updateDataLossDialog.open = true;
} else open = false;
}}
>
Update & reload <ReloadIcon />
{:else}
Already at the latest version 🎉
{/if}
</Button>
{:else}
<div class="flex items-center justify-center gap-2 p-2 text-sm text-muted-foreground">
<LoaderCircle class="animate-spin" />
<span>Loading changelog</span>
</div>
{/if}
</ResponsiveDialog>
</Button>
{:else}
<div class="flex items-center justify-center gap-2 p-2 text-sm text-muted-foreground">
<LoaderCircle class="animate-spin" />
<span>Loading changelog</span>
</div>
{/if}
</ResponsiveDialog>
{/if}
3 changes: 3 additions & 0 deletions src/routes/(components)/layout/PWAButtons.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import DownloadIcon from 'virtual:icons/lucide/download';
import UpdateIcon from 'virtual:icons/lucide/refresh-cw';
import { needRefresh, updateDataLossDialog } from './PWAFunctions.svelte';
import ChangelogDialog from './ChangelogDialog.svelte';
let { isMobile }: { isMobile: boolean } = $props();
Expand Down Expand Up @@ -78,3 +79,5 @@
{/if}
</div>
{/if}

<ChangelogDialog />
2 changes: 0 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { onMount } from 'svelte';
import { pwaInfo } from 'virtual:pwa-info';
import '../app.pcss';
import ChangelogDialog from './(components)/layout/ChangelogDialog.svelte';
import DesktopLayout from './(components)/layout/DesktopLayout.svelte';
import MobileLayout from './(components)/layout/MobileLayout.svelte';
import UpdateDataLossDialog from './(components)/layout/UpdateDataLossDialog.svelte';
Expand Down Expand Up @@ -32,7 +31,6 @@
<ModeWatcher />
<Toaster />

<ChangelogDialog />
<UpdateDataLossDialog />

{#if isMobile === true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<Input
id="{exercise.name}-set-{idx + 1}-reps"
disabled={set.completed || set.skipped}
min={0}
min={1}
required
type="number"
bind:value={set.reps}
Expand All @@ -210,7 +210,6 @@
<Input
id="{exercise.name}-set-{idx + 1}-RIR"
disabled={set.completed || set.skipped}
min={0}
required
type="number"
bind:value={set.RIR}
Expand Down Expand Up @@ -271,7 +270,7 @@
<Input
id="{exercise.name}-set-{idx + 1}-mini-set-{miniIdx + 1}-reps"
disabled={miniSet.completed}
min={0}
min={1}
required
type="number"
bind:value={miniSet.reps}
Expand All @@ -294,7 +293,6 @@
<Input
id="{exercise.name}-set-{idx + 1}-mini-set-{miniIdx + 1}-RIR"
disabled={miniSet.completed}
min={0}
required
type="number"
bind:value={miniSet.RIR}
Expand Down
28 changes: 24 additions & 4 deletions src/routes/workouts/manage/start/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,25 @@
</div>
{/if}
{#if !(useActiveMesocycle && workoutData.workoutOfMesocycle?.workoutStatus === 'RestDay')}
<div class="mb-1 flex w-full flex-col gap-1.5 rounded-lg border bg-card p-4">
<form
class="mb-1 flex w-full flex-col gap-1.5 rounded-lg border bg-card p-4"
name="user-bodyweight-form"
id="user-bodyweight-form"
onsubmit={(e) => {
e.preventDefault();
startWorkout();
}}
>
<Label for="user-bodyweight">Bodyweight</Label>
<Input id="user-bodyweight" placeholder="Type here" type="number" bind:value={userBodyweight} />
</div>
<Input
id="user-bodyweight"
placeholder="Type here"
type="number"
min={1}
step={0.01}
bind:value={userBodyweight}
/>
</form>
{/if}
{#if skippedWorkoutsOfCycle && skippedWorkoutsOfCycle.length > 0}
<Card.Root class="mb-1">
Expand Down Expand Up @@ -217,7 +232,12 @@
</Card.Root>
{/if}
{#if workoutData.workoutOfMesocycle?.workoutStatus !== 'RestDay'}
<Button class="mt-auto" disabled={userBodyweight === null || $navigating !== null} onclick={() => startWorkout()}>
<Button
class="mt-auto"
type="submit"
form="user-bodyweight-form"
disabled={userBodyweight === null || $navigating !== null}
>
{#if $navigating}
<LoaderCircle class="animate-spin" />
{:else}
Expand Down

0 comments on commit 829c0a6

Please sign in to comment.