From d6a187c01a461d6db432c1c9c2bd9591021fe9ae Mon Sep 17 00:00:00 2001 From: troogs Date: Sat, 7 Feb 2026 18:30:03 +0100 Subject: [PATCH] Enhance routine run UI with selectable items, check icons, and weight select dropdown --- src/ASTRAIN.Client/Pages/Routines.razor | 21 +++++++----- src/ASTRAIN.Client/Pages/Routines.razor.cs | 38 +++++++++++++++++++++- src/ASTRAIN.Client/wwwroot/css/app.css | 9 +++++ 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/ASTRAIN.Client/Pages/Routines.razor b/src/ASTRAIN.Client/Pages/Routines.razor index f23f10d..62989dc 100644 --- a/src/ASTRAIN.Client/Pages/Routines.razor +++ b/src/ASTRAIN.Client/Pages/Routines.razor @@ -113,15 +113,20 @@
@foreach (var entry in RunEntries) { -
- -
- - kg +
+
@GetExerciseName(entry.ExerciseId)
+
+
+ + kg +
+
}
diff --git a/src/ASTRAIN.Client/Pages/Routines.razor.cs b/src/ASTRAIN.Client/Pages/Routines.razor.cs index 4cd8432..fe91bb0 100644 --- a/src/ASTRAIN.Client/Pages/Routines.razor.cs +++ b/src/ASTRAIN.Client/Pages/Routines.razor.cs @@ -32,6 +32,42 @@ public partial class Routines private RoutineDto? ActiveRun { get; set; } private List RunEntries { get; set; } = new(); + /// + /// Available weight options for the routine run select input. + /// 10–40 kg in 2.5 kg steps, then 40–100 kg in 5 kg steps. + /// + private static readonly List WeightOptions = BuildWeightOptions(); + + /// + /// Builds the list of available weight options for the routine run select input. + /// + /// A list of double values representing weight options. + private static List BuildWeightOptions() + { + var options = new List(); + for (var w = 10.0; w <= 40.0; w += 2.5) + { + options.Add(w); + } + + for (var w = 45.0; w <= 100.0; w += 5.0) + { + options.Add(w); + } + + return options; + } + + /// + /// Snaps a weight value to the nearest available option. + /// + /// The weight value to snap to the nearest option. + /// The nearest available weight option. + private static double SnapToNearest(double weight) + { + return WeightOptions.OrderBy(w => Math.Abs(w - weight)).First(); + } + /// protected override async Task OnInitializedAsync() { @@ -197,7 +233,7 @@ public partial class Routines .Select(e => { var last = lastRun.Entries.FirstOrDefault(x => x.ExerciseId == e.ExerciseId); - return new RoutineRunEntryDto(e.ExerciseId, last?.Weight ?? 0, false); + return new RoutineRunEntryDto(e.ExerciseId, SnapToNearest(last?.Weight ?? WeightOptions[0]), false); }).ToList(); } diff --git a/src/ASTRAIN.Client/wwwroot/css/app.css b/src/ASTRAIN.Client/wwwroot/css/app.css index af2220f..f5331d1 100644 --- a/src/ASTRAIN.Client/wwwroot/css/app.css +++ b/src/ASTRAIN.Client/wwwroot/css/app.css @@ -91,6 +91,8 @@ p { .input-sm { max-width: 110px; + appearance: none; + -webkit-appearance: none; } .primary { @@ -173,6 +175,13 @@ p { font-weight: 600; } +.item-actions { + display: flex; + align-items: center; + gap: 0.5rem; + margin-left: auto; +} + .item-subtitle { color: #bdbdbd; font-size: 0.85rem;