|
3 | 3 | import { db } from "$lib/db"; |
4 | 4 | import { getActiveProgram } from "$lib/state/program.svelte"; |
5 | 5 | import { getWorkoutSnapshot } from "$lib/state/workout.svelte"; |
| 6 | + import { exercises } from "$lib/state/exercise.svelte"; |
| 7 | + import ExerciseProgress from "$lib/components/ExerciseProgress.svelte"; |
6 | 8 |
|
7 | 9 | const program = await getActiveProgram(); |
8 | 10 | const activeWorkout = await getWorkoutSnapshot(); |
|
11 | 13 | <main class="container"> |
12 | 14 | <h1>Dashboard</h1> |
13 | 15 |
|
14 | | - <div class="flex justify-between items-baseline"> |
15 | | - <h2>My Programs</h2> |
16 | | - <a href={resolve("/programs")}>All programs</a> |
17 | | - </div> |
18 | | - {#if program} |
19 | | - <article> |
20 | | - <header> |
21 | | - <h3>{program.name}</h3> |
22 | | - </header> |
| 16 | + <section> |
| 17 | + <div class="flex justify-between items-baseline"> |
| 18 | + <h2>My Programs</h2> |
| 19 | + <a href={resolve("/programs")}>All programs</a> |
| 20 | + </div> |
23 | 21 |
|
24 | | - {#if activeWorkout} |
25 | | - <p>Continue {activeWorkout.name}</p> |
26 | | - <footer> |
27 | | - <a href={resolve("/workout")} role="button">Continue</a> |
28 | | - </footer> |
29 | | - {:else} |
30 | | - {@const workout = program.workouts[program.nextWorkoutIndex]} |
31 | | - <p>Next workout: {workout.name}</p> |
| 22 | + {#if program} |
| 23 | + <article> |
| 24 | + <header> |
| 25 | + <h3>{program.name}</h3> |
| 26 | + </header> |
32 | 27 |
|
33 | | - <ul class="ml-4"> |
34 | | - {#each workout.exercises as { exerciseId }} |
35 | | - {@const exercise = await db.exercises.get(exerciseId)} |
36 | | - <li>{exercise?.name} @ {exercise?.workingWeight}</li> |
37 | | - {/each} |
38 | | - </ul> |
| 28 | + {#if activeWorkout} |
| 29 | + <p>Continue {activeWorkout.name}</p> |
| 30 | + <footer> |
| 31 | + <a href={resolve("/workout")} role="button">Continue</a> |
| 32 | + </footer> |
| 33 | + {:else} |
| 34 | + {@const workout = program.workouts[program.nextWorkoutIndex]} |
| 35 | + <p>Next workout: {workout.name}</p> |
39 | 36 |
|
| 37 | + <ul class="ml-4"> |
| 38 | + {#each workout.exercises as { exerciseId }} |
| 39 | + {@const exercise = await db.exercises.get(exerciseId)} |
| 40 | + <li>{exercise?.name} @ {exercise?.workingWeight}</li> |
| 41 | + {/each} |
| 42 | + </ul> |
| 43 | + |
| 44 | + <footer> |
| 45 | + <a href={resolve("/workout")} role="button">Start workout</a> |
| 46 | + </footer> |
| 47 | + {/if} |
| 48 | + </article> |
| 49 | + {:else} |
| 50 | + <article> |
| 51 | + <header> |
| 52 | + <h2>Welcome to ProgressBar!</h2> |
| 53 | + </header> |
40 | 54 | <footer> |
41 | | - <a href={resolve("/workout")} role="button">Start workout</a> |
| 55 | + <a href={resolve("/programs")} role="button">Browse Programs</a> |
42 | 56 | </footer> |
43 | | - {/if} |
44 | | - </article> |
45 | | - {:else} |
| 57 | + </article> |
| 58 | + {/if} |
| 59 | + </section> |
| 60 | + |
| 61 | + <section> |
| 62 | + <h2>Progress</h2> |
46 | 63 | <article> |
47 | | - <header> |
48 | | - <h2>Welcome to ProgressBar!</h2> |
49 | | - </header> |
50 | | - <footer> |
51 | | - <a href={resolve("/programs")} role="button">Browse Programs</a> |
52 | | - </footer> |
| 64 | + <ul> |
| 65 | + {#each $exercises as exercise} |
| 66 | + <li style="list-style-type:none;"> |
| 67 | + <h3> |
| 68 | + {exercise.name} |
| 69 | + </h3> |
| 70 | + <ExerciseProgress {exercise} /> |
| 71 | + <!-- <progress value={exercise.workingWeight} max={exercise.goalWeight}> --> |
| 72 | + <!-- </progress> --> |
| 73 | + </li> |
| 74 | + {/each} |
| 75 | + </ul> |
53 | 76 | </article> |
54 | | - {/if} |
| 77 | + </section> |
55 | 78 | </main> |
0 commit comments