Add intensity percentage selector with repetition hints
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace TrainingPlanner.Application;
|
||||
|
||||
public class IntensityPreset
|
||||
{
|
||||
public decimal Percent { get; set; }
|
||||
public string Repetitions { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ public class PlannerOptions
|
||||
{
|
||||
public string DefaultWorkoutName { get; set; } = string.Empty;
|
||||
public string DefaultWorkoutDuration { get; set; } = string.Empty;
|
||||
public List<IntensityPreset> IntensityPresets { get; set; } = [];
|
||||
public decimal DefaultIntensityPercent { get; set; }
|
||||
public int DefaultWeekCount { get; set; }
|
||||
public int DefaultSetsCount { get; set; }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@inject PlannerOptions Options
|
||||
|
||||
<div class="exercise-editor">
|
||||
<div class="exercise-heading">
|
||||
<label class="grow">
|
||||
@@ -22,8 +24,27 @@
|
||||
<input @bind="Exercise.Weight" @bind:event="oninput" @bind:after="Changed" placeholder="60 или Подобрать" />
|
||||
</label>
|
||||
<label>От максимума, %
|
||||
<input type="number" min="0" max="100" step="any" @bind="Exercise.IntensityPercent"
|
||||
@bind:after="Changed" placeholder="—" />
|
||||
<span class="intensity-field">
|
||||
<select aria-label="От максимума, %" class="intensity-select" @bind="Exercise.IntensityPercent" @bind:after="Changed">
|
||||
<option value="">—</option>
|
||||
@if (Exercise.IntensityPercent.HasValue && Options.IntensityPresets.All(item => item.Percent != Exercise.IntensityPercent.Value))
|
||||
{
|
||||
<option value="@Exercise.IntensityPercent.Value">@Exercise.IntensityPercent.Value% — своё значение</option>
|
||||
}
|
||||
@foreach (var preset in Options.IntensityPresets)
|
||||
{
|
||||
<option value="@preset.Percent">@preset.Percent% — @preset.Repetitions повт.</option>
|
||||
}
|
||||
</select>
|
||||
<span class="intensity-value" aria-hidden="true">
|
||||
<span>@(Exercise.IntensityPercent.HasValue ? $"{Exercise.IntensityPercent.Value}%" : "—")</span>
|
||||
@if (SelectedIntensity != null)
|
||||
{
|
||||
<span class="intensity-hint">@SelectedIntensity.Repetitions повт.</span>
|
||||
}
|
||||
</span>
|
||||
<span class="intensity-arrow" aria-hidden="true">⌄</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<label>Разминочные подходы
|
||||
@@ -40,5 +61,7 @@
|
||||
[Parameter, EditorRequired] public WorkoutExercise Exercise { get; set; } = null!;
|
||||
[Parameter] public EventCallback OnChanged { get; set; }
|
||||
|
||||
private IntensityPreset? SelectedIntensity => Options.IntensityPresets.FirstOrDefault(item => item.Percent == Exercise.IntensityPercent);
|
||||
|
||||
private Task Changed() => OnChanged.InvokeAsync();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
"Planner": {
|
||||
"DefaultWorkoutDuration": "1 час",
|
||||
"DefaultIntensityPercent": 80,
|
||||
"IntensityPresets": [
|
||||
{ "Percent": 100, "Repetitions": "1" },
|
||||
{ "Percent": 95, "Repetitions": "2–3" },
|
||||
{ "Percent": 90, "Repetitions": "3–5" },
|
||||
{ "Percent": 85, "Repetitions": "5–7" },
|
||||
{ "Percent": 80, "Repetitions": "6–10" },
|
||||
{ "Percent": 75, "Repetitions": "8–12" },
|
||||
{ "Percent": 70, "Repetitions": "10–15" },
|
||||
{ "Percent": 65, "Repetitions": "12–17" },
|
||||
{ "Percent": 60, "Repetitions": "15–20" }
|
||||
],
|
||||
"DefaultWeekCount": 4,
|
||||
"DefaultSetsCount": 3,
|
||||
"DefaultRepetitions": "10",
|
||||
|
||||
@@ -786,3 +786,10 @@ summary {
|
||||
.import-table td { border:1px solid var(--line); padding:4px; }
|
||||
.import-table input { width:100%; min-width:0; border-color:transparent; }
|
||||
.exercise-import .actions { margin-top:20px; }
|
||||
|
||||
.intensity-field { display:block; position:relative; width:100%; max-width:220px; }
|
||||
.intensity-select { width:100%; appearance:none; color:transparent; font-variant-numeric:tabular-nums; }
|
||||
.intensity-select option { color:var(--text, #202637); background:white; }
|
||||
.intensity-value { position:absolute; inset:0 34px 0 12px; display:flex; align-items:center; justify-content:space-between; gap:8px; pointer-events:none; color:var(--text, #202637); font-weight:400; font-variant-numeric:tabular-nums; }
|
||||
.intensity-hint { color:var(--muted); font-size:12px; white-space:nowrap; }
|
||||
.intensity-arrow { position:absolute; right:12px; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; }
|
||||
|
||||
Reference in New Issue
Block a user