diff --git a/routes/workout.py b/routes/workout.py index cdfd761..e19c942 100644 --- a/routes/workout.py +++ b/routes/workout.py @@ -199,6 +199,19 @@ def get_workout_distribution(person_id, workout_id): distribution=distribution, category_name=category) +@workout_bp.route("/person//workout//summary", methods=['GET']) +@login_required +@validate_workout +@require_ownership +def get_workout_summary(person_id, workout_id): + top_sets = db.execute( + "SELECT exercise_id, repetitions FROM topset WHERE workout_id = %s", + [workout_id], + ) + return render_template('partials/workout_summary.html', person_id=person_id, + workout_id=workout_id, top_sets=top_sets) + + @workout_bp.route("/person//workout//topset//achievements", methods=['GET']) @validate_topset def get_topset_achievements(person_id, workout_id, topset_id): @@ -209,7 +222,7 @@ def get_topset_achievements(person_id, workout_id, topset_id): @validate_topset def get_topset(person_id, workout_id, topset_id): topset = db.get_topset(topset_id) # Keep using db.py for simple gets for now - return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id, exercise_id=topset.get('exercise_id'), exercise_name=topset.get('exercise_name'), repetitions=topset.get('repetitions'), weight=topset.get('weight')) + return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id, exercise_id=topset.get('exercise_id'), exercise_name=topset.get('exercise_name'), repetitions=topset.get('repetitions'), weight=topset.get('weight'), existing_row=True) @workout_bp.route("/person//workout//topset//edit_form", methods=['GET']) @login_required @@ -273,7 +286,7 @@ def update_topset(person_id, workout_id, topset_id): db.update_topset(exercise_id, repetitions, weight, topset_id) exercise = db.get_exercise(exercise_id) db.activityRequest.log(current_user.id, 'UPDATE_SET', 'topset', topset_id, f"Updated set {topset_id}: {repetitions} x {weight}kg {exercise['name']}") - return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id, exercise_id=exercise_id, exercise_name=exercise.get('name'), repetitions=repetitions, weight=weight) + return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id, exercise_id=exercise_id, exercise_name=exercise.get('name'), repetitions=repetitions, weight=weight, existing_row=True), 200, {"HX-Trigger": "topsetChanged"} @workout_bp.route("/person//workout//topset//delete", methods=['DELETE']) @login_required @@ -283,7 +296,7 @@ def delete_topset(person_id, workout_id, topset_id): topset = db.get_topset(topset_id) db.delete_topset(topset_id) db.activityRequest.log(current_user.id, 'DELETE_SET', 'topset', topset_id, f"Deleted set {topset_id}: {topset['exercise_name']} in workout {workout_id}") - return "" + return f'', 200, {"HX-Trigger": "topsetChanged"} @workout_bp.route("/person//workout//exercise/most_recent_topset_for_exercise", methods=['GET']) def get_most_recent_topset_for_exercise(person_id, workout_id): diff --git a/static/css/workout.css b/static/css/workout.css new file mode 100644 index 0000000..d7e4323 --- /dev/null +++ b/static/css/workout.css @@ -0,0 +1,84 @@ +/* Workout workspace: keep logging readable on wide screens. */ +.workout-workspace{max-width:1360px;margin:0 auto;padding:8px 12px 40px;color:#253449} +.workout-workspace nav{margin-bottom:28px} +.workout-header{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:24px} +.workout-eyebrow{font-size:11px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:#64748b;margin:0 0 8px} +.workout-header h1{font-size:30px;line-height:1.25;font-weight:750;letter-spacing:-.035em;margin-bottom:8px} +.workout-header h1 span{color:#64748b;font-weight:400} +.workout-layout{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:24px;align-items:start} +.workout-main,.workout-sidebar{min-width:0;display:grid;gap:20px} +.workout-card{background:#fff;border:1px solid #e1e7ec;border-radius:14px;box-shadow:0 2px 4px #182c4203;min-width:0} +.workout-logger{padding:24px;border-top:3px solid #0891a0} +.workout-section-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:22px} +.workout-section-heading h2{font-size:18px;line-height:1.4;font-weight:700;letter-spacing:-.02em} +.workout-subtle{font-size:12px;line-height:1.6;color:#64748b;font-weight:400} +.workout-section-heading p.workout-subtle{margin-top:5px} +.workout-set-fields{display:grid;grid-template-columns:minmax(140px,1fr) 84px 104px auto;align-items:end;gap:12px} +.workout-set-field{min-width:0} +.workout-set-field label{font-size:11px;letter-spacing:.03em;text-transform:none;color:#64748b;margin-bottom:7px} +.workout-set-field input{height:44px;border-radius:8px;padding:10px 12px;font-size:14px;background:#f8fafc;border-color:#dbe3e9;color:#253449} +.workout-set-field input:focus{outline:2px solid #0891a0;outline-offset:2px} +.workout-add-button{display:flex;align-items:center;justify-content:center;gap:5px;min-height:44px;padding:10px 15px;background:#087f8c;color:white;border-radius:8px;font-size:13px;font-weight:650;white-space:nowrap} +.workout-add-button:hover{background:#066975} +.workout-workspace button:focus-visible,.workout-workspace summary:focus-visible{outline:2px solid #0891a0;outline-offset:3px} +.workout-button{display:flex;align-items:center;gap:16px;padding:10px 14px;border:1px solid #dbe3e9;background:#fff;border-radius:8px;font-size:12px;cursor:pointer;list-style:none} +.workout-menu{position:relative;flex-shrink:0} +.workout-menu-content{position:absolute;right:0;top:calc(100% + 8px);z-index:20;padding:6px;background:#fff;border:1px solid #e1e7ec;border-radius:10px;min-width:180px;box-shadow:0 8px 24px #182c4214} +.workout-delete{color:#b42335;padding:10px;width:100%;text-align:left;border-radius:6px;font-size:13px} +.workout-delete:hover{background:#fff1f2} +.workout-results>.workout-section-heading{padding:22px 24px 18px;margin:0} +.workout-table{width:100%;border-collapse:collapse;table-layout:fixed;text-align:left} +.workout-table>thead th{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:#64748b;background:#f8fafc;padding:12px 20px;border-block:1px solid #e8edf1;font-weight:650} +.workout-table>thead th:first-child{width:53%} +.workout-table>thead th:last-child{width:82px;padding-inline:0} +.workout-table .workout-set-row>td{padding:18px 20px;vertical-align:middle;border-bottom:1px solid #edf0f3;font-size:13px} +.workout-table .workout-set-row>td:last-child{display:table-cell;padding:10px 6px} +.workout-table .workout-set-row>td:last-child>div{flex-direction:row} +.workout-table .workout-set-row>td:last-child button{color:#718096;border-radius:7px} +.workout-table .workout-set-row>td:last-child button:hover{color:#087f8c;background:#edf7f8} +.workout-exercise-name{display:flex;align-items:flex-start;flex-direction:column;gap:8px;overflow-wrap:anywhere} +.workout-exercise-tools{display:flex;gap:8px;flex-wrap:wrap} +.workout-exercise-tools button{gap:4px;padding:3px 0;font-size:11px;font-weight:500;color:#64748b;min-height:26px} +.workout-exercise-tools button:hover{color:#087f8c;background:transparent} +.workout-exercise-tools svg{width:13px;height:13px} +.workout-empty{display:none;padding:42px 24px;text-align:center;color:#64748b;font-size:13px;line-height:1.7} +.workout-empty strong{display:block;color:#334155;font-size:16px;margin-bottom:6px} +.workout-results:not(:has(.workout-set-row)) .workout-empty{display:block} +.workout-results:not(:has(.workout-set-row)) .workout-table{display:none} +.workout-summary{padding:22px} +.workout-summary dl{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin:18px 0 14px} +.workout-summary dl>div{display:flex;flex-direction:column-reverse;gap:4px} +.workout-summary dt{font-size:11px;color:#64748b} +.workout-summary dd{font-size:27px;line-height:1.2;letter-spacing:-.04em;font-weight:700;font-variant-numeric:tabular-nums} +.workout-disclosure>summary{position:relative;padding:20px 40px 20px 20px;font-weight:650;font-size:14px;cursor:pointer;list-style:none} +.workout-disclosure>summary:after{content:'+';position:absolute;right:20px;top:20px;color:#64748b;font-size:18px;font-weight:400} +.workout-disclosure[open]>summary:after{content:'−'} +.workout-disclosure>summary .workout-subtle{display:block;margin-top:3px} +.workout-disclosure-body{padding:0 20px 20px} +.workout-disclosure-body [id^='workout-note-'] a{float:none;padding-left:0} +.workout-disclosure-body [id^='tag-form-w-']>div{display:block} +.workout-disclosure-body [id^='tag-form-w-']>div>div{width:100%;padding:8px 0;margin:0} +.workout-breakdown h3{font-size:11px;font-weight:650;color:#64748b;margin:0 0 12px} +.workout-distribution-bar{display:flex;gap:2px;height:7px;border-radius:4px;overflow:hidden;margin-bottom:14px} +.workout-distribution-legend{display:grid;gap:11px;font-size:12px} +.workout-distribution-legend li{display:flex;justify-content:space-between;gap:10px;font-variant-numeric:tabular-nums} +.workout-distribution-legend li>span:last-child{color:#64748b} +.workout-legend-label{display:flex;align-items:center;gap:8px} +.workout-legend-label i{width:7px;height:7px;border-radius:50%;flex-shrink:0} +.workout-secondary-details{margin-top:20px;padding-top:14px;border-top:1px solid #e8edf1} +.workout-secondary-details>summary,.workout-previous-details>summary{font-size:12px;color:#64748b;cursor:pointer} +.workout-secondary-details .workout-breakdown{margin-top:20px} +.workout-previous-details{border-top:1px solid #e8edf1;margin-top:18px;padding-top:14px} +.workout-previous-details>summary span{float:right;color:#334155;font-variant-numeric:tabular-nums} +.workout-table .extra-content-container:not(:empty){background:#f8fafc;padding:18px 20px;border-bottom:1px solid #e1e7ec} +.workout-table .extra-content-container .progress-heading{padding-right:22px} +.workout-workspace .forecast-chart{height:220px} +.workout-workspace .forecast-chart path{vector-effect:non-scaling-stroke;stroke-width:1.8px} +.workout-workspace .forecast-chart circle{opacity:.6} +.workout-workspace .exercise-progress{padding:8px 0;max-width:100%} +.workout-workspace .progress-title h4{font-size:14px} +.workout-workspace .exercise-progress>h2{color:#64748b} +@media(min-width:1600px){.workout-workspace{padding-top:16px}.workout-layout{gap:28px;grid-template-columns:minmax(0,1fr) 320px}} +@media(max-width:1100px){.workout-layout{grid-template-columns:minmax(0,1fr) 260px;gap:16px}.workout-logger{padding:20px}.workout-set-fields{grid-template-columns:minmax(0,1fr) 76px 90px;gap:10px}.workout-set-submit{grid-column:1/-1}.workout-add-button{width:100%}} +@media(max-width:900px){.workout-layout{grid-template-columns:minmax(0,1fr)}.workout-sidebar{grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}.workout-set-fields{grid-template-columns:minmax(140px,1fr) 84px 104px auto}.workout-set-submit{grid-column:auto}} +@media(max-width:600px){.workout-workspace{padding:4px 0 24px}.workout-workspace nav{margin-bottom:20px}.workout-header{gap:8px;align-items:flex-start;margin-bottom:18px}.workout-header h1{font-size:24px}.workout-header h1 span{display:block;font-size:16px;letter-spacing:0;margin-top:4px}.workout-button{gap:8px;padding:8px 10px;font-size:11px}.workout-main,.workout-sidebar{gap:14px}.workout-sidebar{grid-template-columns:minmax(0,1fr)}.workout-logger{padding:18px 16px}.workout-section-heading{margin-bottom:18px}.workout-section-heading>.workout-subtle{display:none}.workout-set-fields{grid-template-columns:1fr 1fr;gap:14px 10px}.workout-set-field:first-child,.workout-set-submit{grid-column:1/-1}.workout-results>.workout-section-heading{padding:18px 14px}.workout-table>thead th{padding:10px 12px}.workout-table>thead th:first-child{width:49%}.workout-table>thead th:last-child{width:44px}.workout-table .workout-set-row>td{padding:16px 12px;font-size:12px}.workout-table .workout-set-row>td:last-child{padding:6px 0}.workout-table .workout-set-row>td:last-child>div{flex-direction:column}.workout-exercise-tools{gap:8px}.workout-exercise-tools button{font-size:10px;min-height:30px}.workout-exercise-tools svg{display:none}.workout-table .extra-content-container:not(:empty){padding:14px 10px}.workout-workspace .forecast-chart{height:190px}.workout-summary dl{margin:14px 0}.workout-summary{padding:18px 20px}} diff --git a/templates/base.html b/templates/base.html index 6a45253..5806e47 100644 --- a/templates/base.html +++ b/templates/base.html @@ -15,6 +15,7 @@ + diff --git a/templates/partials/new_set_form.html b/templates/partials/new_set_form.html index 197c04d..3e2b53e 100644 --- a/templates/partials/new_set_form.html +++ b/templates/partials/new_set_form.html @@ -2,7 +2,7 @@
-
-
-