Calculator UI simplification
This commit is contained in:
@@ -17,89 +17,24 @@
|
||||
|
||||
const defaultStandards = new Standards(DEFAULT_STANDARDS_DATA);
|
||||
|
||||
// TODO: try to clean this up
|
||||
let input = $state({
|
||||
activity: Activity.BenchPress,
|
||||
metrics: {
|
||||
gender: Gender.Male,
|
||||
age: "",
|
||||
weight: "",
|
||||
},
|
||||
cfg: {
|
||||
global: {
|
||||
maxLevel: String(defaultStandards.cfg.global.maxLevel),
|
||||
},
|
||||
activity: Object.fromEntries(
|
||||
Object.values(Activity).map((activity) => {
|
||||
return [
|
||||
activity,
|
||||
{
|
||||
enableGeneration:
|
||||
defaultStandards.cfg.activity[activity]
|
||||
.enableGeneration,
|
||||
weightAdvantage: String(
|
||||
defaultStandards.cfg.activity[activity]
|
||||
.weightModifier,
|
||||
),
|
||||
ageModifier: String(
|
||||
defaultStandards.cfg.activity[activity]
|
||||
.ageModifier,
|
||||
),
|
||||
difficultyModifier: String(
|
||||
defaultStandards.cfg.activity[activity]
|
||||
.difficultyModifier,
|
||||
),
|
||||
peakAge: String(
|
||||
defaultStandards.cfg.activity[activity].peakAge,
|
||||
),
|
||||
stretch: {
|
||||
upper: String(
|
||||
defaultStandards.cfg.activity[activity]
|
||||
.stretch.upper,
|
||||
),
|
||||
lower: String(
|
||||
defaultStandards.cfg.activity[activity]
|
||||
.stretch.lower,
|
||||
),
|
||||
},
|
||||
},
|
||||
];
|
||||
}),
|
||||
),
|
||||
age: null as number | null,
|
||||
weight: null as number | null, // lb
|
||||
},
|
||||
cfg: structuredClone(defaultStandards.cfg) as StandardsConfig,
|
||||
});
|
||||
|
||||
const selected = $derived({
|
||||
activity: input.activity,
|
||||
metrics: {
|
||||
gender: input.metrics.gender,
|
||||
age: +input.metrics.age,
|
||||
weight: lbToKg(+input.metrics.weight),
|
||||
age: input.metrics.age ?? 0,
|
||||
weight: lbToKg(input.metrics.weight ?? 0),
|
||||
} as Metrics,
|
||||
cfg: {
|
||||
global: {
|
||||
maxLevel: +input.cfg.global.maxLevel,
|
||||
},
|
||||
activity: Object.fromEntries(
|
||||
Object.values(Activity).map((activity) => [
|
||||
activity,
|
||||
{
|
||||
weightModifier:
|
||||
+input.cfg.activity[activity].weightAdvantage,
|
||||
ageModifier: +input.cfg.activity[activity].ageModifier,
|
||||
enableGeneration:
|
||||
input.cfg.activity[activity].enableGeneration,
|
||||
difficultyModifier:
|
||||
+input.cfg.activity[activity].difficultyModifier,
|
||||
peakAge: +input.cfg.activity[activity].peakAge,
|
||||
stretch: {
|
||||
lower: +input.cfg.activity[activity].stretch.lower,
|
||||
upper: +input.cfg.activity[activity].stretch.upper,
|
||||
},
|
||||
},
|
||||
]),
|
||||
),
|
||||
} as StandardsConfig,
|
||||
cfg: input.cfg,
|
||||
});
|
||||
|
||||
const allStandards = $derived(
|
||||
@@ -184,7 +119,7 @@
|
||||
placeholder=".1"
|
||||
bind:value={
|
||||
input.cfg.activity[selected.activity]
|
||||
.weightAdvantage
|
||||
.weightModifier
|
||||
}
|
||||
disabled={!selected.cfg.activity[selected.activity]
|
||||
.enableGeneration}
|
||||
|
||||
Reference in New Issue
Block a user