Standards updates

This commit is contained in:
Dominic Ferrando
2025-09-20 21:34:41 -04:00
parent 9ba60fa1f3
commit b3253425e3
3 changed files with 28 additions and 7 deletions
+5 -1
View File
@@ -187,6 +187,7 @@ export type StandardsConfig = {
weightModifier: number, weightModifier: number,
weightSkew: number, weightSkew: number,
ageModifier: number, ageModifier: number,
disableGeneration: boolean
} }
export class Standards { export class Standards {
@@ -199,6 +200,7 @@ export class Standards {
weightModifier: cfg?.weightModifier ?? .1, weightModifier: cfg?.weightModifier ?? .1,
weightSkew: cfg?.weightSkew ?? .1, weightSkew: cfg?.weightSkew ?? .1,
ageModifier: cfg?.ageModifier ?? .1, ageModifier: cfg?.ageModifier ?? .1,
disableGeneration: cfg?.disableGeneration ?? false
}; };
// prepare data // prepare data
@@ -212,7 +214,9 @@ export class Standards {
} }
// generate data // generate data
const allGenerators = this.activityStandards[activity].metadata.generators; const allGenerators = this.cfg.disableGeneration ?
[] :
this.activityStandards[activity].metadata.generators;
const ageGenerators = allGenerators.filter(g => g.metric === "age"); const ageGenerators = allGenerators.filter(g => g.metric === "age");
for (const ageGenerator of ageGenerators) { for (const ageGenerator of ageGenerators) {
+1 -1
View File
@@ -17,7 +17,7 @@
<div class="drawer lg:drawer-open"> <div class="drawer lg:drawer-open">
<input id="sidebar" type="checkbox" class="drawer-toggle" /> <input id="sidebar" type="checkbox" class="drawer-toggle" />
<div class="drawer-content p-10 flex flex-col items-center justify-center"> <div class="drawer-content p-10 flex flex-col items-center">
{@render children?.()} {@render children?.()}
<label for="sidebar" class="btn btn-primary drawer-button lg:hidden"> <label for="sidebar" class="btn btn-primary drawer-button lg:hidden">
Open drawer Open drawer
+22 -5
View File
@@ -17,7 +17,7 @@
range, range,
} from "$lib/services/calculator/util"; } from "$lib/services/calculator/util";
const input = $state({ let input = $state({
activity: Activity.BenchPress, activity: Activity.BenchPress,
metrics: { metrics: {
gender: Gender.Male, gender: Gender.Male,
@@ -25,6 +25,7 @@
weight: "", weight: "",
}, },
cfg: { cfg: {
enableGeneration: true,
maxLevel: "5", maxLevel: "5",
weightModfier: ".1", weightModfier: ".1",
weightSkew: ".4", weightSkew: ".4",
@@ -44,10 +45,12 @@
weightModifier: +input.cfg.weightModfier, weightModifier: +input.cfg.weightModfier,
weightSkew: +input.cfg.weightSkew, weightSkew: +input.cfg.weightSkew,
ageModifier: +input.cfg.ageModifier, ageModifier: +input.cfg.ageModifier,
disableGeneration: !input.cfg.enableGeneration,
} as StandardsConfig, } as StandardsConfig,
}); });
$effect(() => { $effect(() => {
console.log(selected);
if (!input.metrics.age) input.metrics.weight = ""; if (!input.metrics.age) input.metrics.weight = "";
}); });
@@ -168,6 +171,13 @@
</legend> </legend>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<label class="label">
<input
type="checkbox"
bind:checked={input.cfg.enableGeneration}
class="toggle toggle-lg m-auto"
/>
</label>
<label> <label>
<span class="label mb-1">Weight modifier</span> <span class="label mb-1">Weight modifier</span>
<input <input
@@ -178,6 +188,7 @@
step=".05" step=".05"
placeholder=".1" placeholder=".1"
bind:value={input.cfg.weightModfier} bind:value={input.cfg.weightModfier}
disabled={selected.cfg.disableGeneration}
/> />
</label> </label>
<label> <label>
@@ -190,6 +201,7 @@
step=".05" step=".05"
placeholder=".1" placeholder=".1"
bind:value={input.cfg.weightSkew} bind:value={input.cfg.weightSkew}
disabled={selected.cfg.disableGeneration}
/> />
</label> </label>
<label> <label>
@@ -202,6 +214,7 @@
step=".05" step=".05"
placeholder=".1" placeholder=".1"
bind:value={input.cfg.ageModifier} bind:value={input.cfg.ageModifier}
disabled={selected.cfg.disableGeneration}
/> />
</label> </label>
</div> </div>
@@ -216,9 +229,9 @@
<div> <div>
<div class="flex items-center"> <div class="flex items-center">
<p class="text-xs label"> <p class="text-xs label">
{#if allStandards {#if !selected.cfg.disableGeneration && allStandards
.byActivity(selected.activity) .byActivity(selected.activity)
.getMetadata().generators.length} .getMetadata().generators.length}
(Generated data: {allStandards (Generated data: {allStandards
.byActivity(selected.activity) .byActivity(selected.activity)
.getMetadata() .getMetadata()
@@ -246,7 +259,11 @@
{#snippet standardsTable(activity: Activity, metrics: Metrics)} {#snippet standardsTable(activity: Activity, metrics: Metrics)}
{#snippet standardsTableRow(standard: Standard)} {#snippet standardsTableRow(standard: Standard)}
<tr class="hover:bg-base-300"> <tr class="hover:bg-base-300">
<th>{parseFloat(kgToLb(standard.metrics.weight).toFixed(2))}</th> <th>
{standard.metrics.weight
? parseFloat(kgToLb(standard.metrics.weight).toFixed(2))
: "None"}</th
>
{#each range(selected.cfg.maxLevel) as lvl} {#each range(selected.cfg.maxLevel) as lvl}
<td>{getLvlValue(activity, standard, lvl)}</td> <td>{getLvlValue(activity, standard, lvl)}</td>
{/each} {/each}