Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| 516feae195 |
6 changed files with 131 additions and 30 deletions
|
|
@ -381,6 +381,23 @@ const gym = [
|
|||
},
|
||||
];
|
||||
|
||||
const fast = [
|
||||
{ name: "1:1", planned_at: "2025-04-30", completed: false },
|
||||
{ name: "1:2", planned_at: "2025-05-02", completed: false },
|
||||
{ name: "2:1", planned_at: "2025-05-05", completed: false },
|
||||
{ name: "2:2", planned_at: "2025-05-07", completed: false },
|
||||
{ name: "2:3", planned_at: "2025-05-09", completed: false },
|
||||
{ name: "3:1", planned_at: "2025-05-12", completed: false },
|
||||
{ name: "3:2", planned_at: "2025-05-14", completed: false },
|
||||
{ name: "3:3", planned_at: "2025-05-16", completed: false },
|
||||
{ name: "4:1", planned_at: "2025-05-19", completed: false },
|
||||
{ name: "4:2", planned_at: "2025-05-21", completed: false },
|
||||
{ name: "4:3", planned_at: "2025-05-23", completed: false },
|
||||
{ name: "5:1", planned_at: "2025-05-26", completed: false },
|
||||
{ name: "5:2", planned_at: "2025-05-28", completed: false },
|
||||
{ name: "5:3", planned_at: "2025-05-30", completed: false },
|
||||
];
|
||||
|
||||
const diet = [
|
||||
{ date: "2025-02-10", completed: false },
|
||||
{ date: "2025-02-11", completed: false },
|
||||
|
|
@ -498,4 +515,5 @@ export default {
|
|||
cardio,
|
||||
gym,
|
||||
diet,
|
||||
fast,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,25 +6,29 @@
|
|||
import GymProgress from "./lib/GymProgress.svelte";
|
||||
import CardioProgress from "./lib/CardioProgress.svelte";
|
||||
import DietProgress from "./lib/DietProgress.svelte";
|
||||
import Info from "./lib/Info.svelte"
|
||||
import FastProgress from "./lib/FastProgress.svelte";
|
||||
import Info from "./lib/Info.svelte";
|
||||
</script>
|
||||
|
||||
<div class="chrome">
|
||||
{#if $currentView === 0}
|
||||
<Summary />
|
||||
{/if}
|
||||
{#if $currentView === 1}
|
||||
<GymProgress />
|
||||
{/if}
|
||||
{#if $currentView === 2}
|
||||
<CardioProgress />
|
||||
{/if}
|
||||
{#if $currentView === 3}
|
||||
<DietProgress />
|
||||
{/if}
|
||||
{#if $currentView === 4}
|
||||
<Info />
|
||||
{/if}
|
||||
{#if $currentView === 0}
|
||||
<Summary />
|
||||
{/if}
|
||||
{#if $currentView === 1}
|
||||
<GymProgress />
|
||||
{/if}
|
||||
{#if $currentView === 2}
|
||||
<CardioProgress />
|
||||
{/if}
|
||||
{#if $currentView === 3}
|
||||
<DietProgress />
|
||||
{/if}
|
||||
{#if $currentView === 4}
|
||||
<Info />
|
||||
{/if}
|
||||
{#if $currentView === 5}
|
||||
<FastProgress />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import DietProgress from "./DietProgress.svelte";
|
||||
import P from "./svg-path";
|
||||
import { gym, cardio, diet } from "./store";
|
||||
import { gym, cardio, diet, fast } from "./store";
|
||||
|
||||
export const DEG_TO_RAD = Math.PI / 180;
|
||||
export const RAD_TO_DEG = 180 / Math.PI;
|
||||
|
|
@ -17,7 +17,12 @@
|
|||
const x = 0;
|
||||
const y = 0;
|
||||
|
||||
const points = (radius: number, radLength: number, thickness: number) => {
|
||||
const points = (
|
||||
radius: number,
|
||||
radLength: number,
|
||||
thickness: number,
|
||||
offset?: number,
|
||||
) => {
|
||||
const borderRadius = thickness / 2;
|
||||
const outerRadius = radius;
|
||||
const innerRadius = outerRadius - thickness;
|
||||
|
|
@ -26,19 +31,20 @@
|
|||
(borderRadius / (outerRadius * FULL_CIRCLE_IN_RADIANS)) *
|
||||
FULL_CIRCLE_IN_RADIANS;
|
||||
const isLongTrack = radLength - 2 * borderRadiusAngle > Math.PI;
|
||||
const start = startAngle + (offset ?? 0);
|
||||
|
||||
return P()
|
||||
.moveTo(
|
||||
-Math.sin(startAngle) * (outerRadius - borderRadius),
|
||||
Math.cos(startAngle) * (outerRadius - borderRadius),
|
||||
-Math.sin(start) * (outerRadius - borderRadius),
|
||||
Math.cos(start) * (outerRadius - borderRadius),
|
||||
)
|
||||
.arcTo(
|
||||
borderRadius,
|
||||
borderRadius,
|
||||
false,
|
||||
true,
|
||||
-Math.sin(startAngle - borderRadiusAngle) * outerRadius,
|
||||
Math.cos(startAngle - borderRadiusAngle) * outerRadius,
|
||||
-Math.sin(start - borderRadiusAngle) * outerRadius,
|
||||
Math.cos(start - borderRadiusAngle) * outerRadius,
|
||||
)
|
||||
.arcTo(
|
||||
outerRadius,
|
||||
|
|
@ -73,16 +79,16 @@
|
|||
innerRadius,
|
||||
isLongTrack,
|
||||
false,
|
||||
-Math.sin(startAngle - borderRadiusAngle) * innerRadius,
|
||||
Math.cos(startAngle - borderRadiusAngle) * innerRadius,
|
||||
-Math.sin(start - borderRadiusAngle) * innerRadius,
|
||||
Math.cos(start - borderRadiusAngle) * innerRadius,
|
||||
)
|
||||
.arcTo(
|
||||
borderRadius,
|
||||
borderRadius,
|
||||
false,
|
||||
true,
|
||||
-Math.sin(startAngle) * (innerRadius + borderRadius),
|
||||
Math.cos(startAngle) * (innerRadius + borderRadius),
|
||||
-Math.sin(start) * (innerRadius + borderRadius),
|
||||
Math.cos(start) * (innerRadius + borderRadius),
|
||||
)
|
||||
.close()
|
||||
.stringify();
|
||||
|
|
@ -96,16 +102,21 @@
|
|||
},
|
||||
{
|
||||
c: "cardio",
|
||||
progress: $diet.filter((c) => !c.excluded).length / $cardio.length,
|
||||
progress: $cardio.filter((c) => c.completed).length / $cardio.length,
|
||||
level: 1,
|
||||
},
|
||||
{
|
||||
c: "diet",
|
||||
progress:
|
||||
$cardio.filter((c) => c.completed).length /
|
||||
$diet.filter((c) => c.completed).length /
|
||||
$diet.filter((c) => !c.excluded).length,
|
||||
level: 2,
|
||||
},
|
||||
{
|
||||
c: "fast",
|
||||
progress: $fast.filter((c) => c.completed).length / $fast.length,
|
||||
level: 3,
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
|
|
@ -132,6 +143,15 @@
|
|||
segmentHeight,
|
||||
)}
|
||||
/>
|
||||
<path
|
||||
fill="#fff"
|
||||
opacity="0.4"
|
||||
d={points(
|
||||
size / 2 - level * (segmentHeight + 4) - 4,
|
||||
progress * span * 0.98,
|
||||
4,
|
||||
)}
|
||||
/>
|
||||
{/each}
|
||||
</g>
|
||||
</g>
|
||||
|
|
@ -165,4 +185,8 @@
|
|||
.diet {
|
||||
color: #35d450;
|
||||
}
|
||||
|
||||
.fast {
|
||||
color: #ff00ff;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
39
src/lib/FastProgress.svelte
Normal file
39
src/lib/FastProgress.svelte
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<script lang="ts">
|
||||
import { fast } from "./store";
|
||||
import { dm, back } from "./common";
|
||||
const remaining = $fast.length;
|
||||
const days = ["ons", "fre", "mån"];
|
||||
let done = $derived($fast.filter((c) => c.completed).length);
|
||||
</script>
|
||||
|
||||
<header>
|
||||
<button class="clickable back" onclick={() => back()}>←</button>
|
||||
<h1>
|
||||
Fasta: {done} av {remaining}
|
||||
</h1>
|
||||
</header>
|
||||
<main>
|
||||
<progress hidden max={remaining} value={done}></progress>
|
||||
<div class="calendar">
|
||||
{#each $fast as col, i}
|
||||
<article class="clickable">
|
||||
<label>
|
||||
<input type="checkbox" bind:checked={col.completed} />
|
||||
<strong>{col.name}</strong>
|
||||
<small>{days[i % 3]} {dm(col.planned_at)}</small>
|
||||
</label>
|
||||
</article>
|
||||
{/each}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
main {
|
||||
background-color: #5dc5f8;
|
||||
border-top: 4px solid rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
article:nth-child(1) {
|
||||
grid-column: 2;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { gym, cardio, diet, currentView } from "./store";
|
||||
import { gym, fast, cardio, diet, currentView } from "./store";
|
||||
import Arc from "./Arc.svelte";
|
||||
let gymProgress = $derived($gym.filter((c) => c.completed).length);
|
||||
let cardioProgress = $derived($cardio.filter((c) => c.completed).length);
|
||||
let fastProgress = $derived($fast.filter((c) => c.completed).length);
|
||||
let dietProgress = $derived($diet.filter((c) => c.completed).length);
|
||||
let dietTotal = $derived($diet.filter((c) => !c.excluded).length);
|
||||
|
||||
const navigate = (v: 0 | 1 | 2 | 3 | 4) => {
|
||||
const navigate = (v: 0 | 1 | 2 | 3 | 4 | 5) => {
|
||||
currentView.update((_) => v);
|
||||
};
|
||||
</script>
|
||||
|
|
@ -34,6 +35,12 @@
|
|||
<i>{dietProgress} / {dietTotal}</i>
|
||||
<button class="clickable diet" onclick={() => navigate(3)}>+</button>
|
||||
</div>
|
||||
<h2>Fasta, 3d/v under maj</h2>
|
||||
<div class="progress-row">
|
||||
<progress class="fast" value={fastProgress} max={$fast.length}></progress>
|
||||
<i>{fastProgress} / {$fast.length}</i>
|
||||
<button class="clickable fast" onclick={() => navigate(5)}>+</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="top-button">
|
||||
<button class="clickable info" onclick={() => navigate(4)}> Va? </button>
|
||||
|
|
@ -64,6 +71,10 @@
|
|||
&.gym {
|
||||
--pcolor: #f62b5a;
|
||||
}
|
||||
|
||||
&.fast {
|
||||
--pcolor: #ff00ff;
|
||||
}
|
||||
}
|
||||
|
||||
progress,
|
||||
|
|
@ -185,6 +196,10 @@
|
|||
&.gym {
|
||||
--btn-bg: #f62b5a;
|
||||
}
|
||||
|
||||
&.fast {
|
||||
--btn-bg: #ff00ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export const currentView = writable(0);
|
|||
export const cardio = persisted("cardio", defaultState.cardio);
|
||||
export const gym = persisted("gym", defaultState.gym);
|
||||
export const diet = persisted("diet", defaultState.diet);
|
||||
export const fast = persisted("fast", defaultState.fast);
|
||||
|
||||
export type Exercise = {
|
||||
completed: boolean;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue