Switch muscle distribution to a line chart

This commit is contained in:
Peter Stockings
2026-01-30 23:57:44 +11:00
parent d03581bff4
commit 5d2f3986bd
3 changed files with 102 additions and 100 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,39 +1,44 @@
{% if muscle_distribution %} {% if muscle_distribution %}
<div class="bg-gray-50 p-2 rounded-lg border border-gray-100 flex flex-col gap-2 max-w-sm" id="muscle-breakdown" <div class="px-4 py-3 bg-white" id="muscle-breakdown"
hx-get="{{ url_for('workout.get_workout_muscle_distribution', person_id=person_id, workout_id=workout_id) }}" hx-get="{{ url_for('workout.get_workout_muscle_distribution', person_id=person_id, workout_id=workout_id) }}"
hx-trigger="topsetAdded from:body" hx-swap="outerHTML"> hx-trigger="topsetAdded from:body" hx-swap="outerHTML">
<div class="flex items-center gap-3"> <div class="flex items-center justify-between mb-2">
<!-- Mini Donut SVG --> <h4 class="text-[9px] font-black text-gray-400 uppercase tracking-[0.25em]">Muscle Distribution</h4>
<div class="relative w-16 h-16 flex-shrink-0">
<svg viewBox="0 0 100 100" class="w-full h-full"
style="transform: rotate(-90deg); transform-origin: center;">
<circle cx="50" cy="50" r="40" fill="transparent" stroke="#e5e7eb" stroke-width="14" />
{% for item in muscle_distribution %}
<circle cx="50" cy="50" r="40" fill="transparent" stroke="{{ item.color }}" stroke-width="14"
stroke-dasharray="{{ item.dasharray }}" stroke-dashoffset="{{ item.dashoffset }}" pathLength="100"
stroke-linecap="round" style="transform-origin: center;"
class="transition-all duration-300 segment-{{ loop.index }}" />
{% endfor %}
</svg>
<div class="absolute inset-0 flex items-center justify-center">
<span class="text-[10px] font-black text-gray-700 tracking-tighter">{{ muscle_distribution[0].percentage
}}%</span>
</div>
</div> </div>
<!-- Mini Legend --> <!-- Sleek Performance Bar -->
<div class="flex-grow min-w-0"> <div class="w-full h-8 flex overflow-hidden rounded-lg bg-gray-100 shadow-inner p-0.5">
<div class="flex flex-wrap gap-x-4 gap-y-2">
{% for item in muscle_distribution %} {% for item in muscle_distribution %}
<div class="flex items-center gap-1.5 whitespace-nowrap"> <div class="h-full transition-all duration-700 ease-in-out flex items-center justify-center relative group first:rounded-l-md last:rounded-r-md"
<div class="w-1.5 h-1.5 rounded-full" style="background-color: {{ item.color }}"></div> style="width: {{ item.percentage }}%; background-color: {{ item.color }};">
<span class="text-[10px] font-bold text-gray-600 uppercase">{{ item.muscle_group }}</span>
<span class="text-[10px] text-gray-400 font-medium">{{ item.percentage }}%</span> <!-- Labels with optimized typography -->
<div
class="flex items-center justify-center gap-1 leading-none text-white pointer-events-none px-1 overflow-hidden">
{% if item.percentage > 15 %}
<span class="text-[9px] font-black uppercase tracking-tighter truncate drop-shadow-sm">{{
item.muscle_group }}</span>
<span class="text-[9px] font-bold opacity-90 whitespace-nowrap">{{ item.percentage }}%</span>
{% elif item.percentage > 8 %}
<span class="text-[9px] font-black drop-shadow-sm">{{ item.percentage }}%</span>
{% endif %}
</div>
<!-- Enhanced Hover State -->
<div class="absolute inset-0 bg-white/15 opacity-0 group-hover:opacity-100 transition-opacity cursor-help">
</div>
<!-- Precision Tooltip -->
<div
class="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900/95 backdrop-blur-sm text-white text-[9px] font-black rounded opacity-0 group-hover:opacity-100 transition-all transform translate-y-1 group-hover:translate-y-0 whitespace-nowrap z-20 pointer-events-none shadow-lg border border-white/5 uppercase tracking-wider">
{{ item.muscle_group }} <span class="mx-1 opacity-40"></span> {{ item.percentage }}%
<div
class="absolute top-full left-1/2 -translate-x-1/2 -mt-1 border-4 border-transparent border-t-gray-900/95">
</div>
</div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div>
</div>
</div> </div>
{% endif %} {% endif %}

View File

@@ -45,16 +45,15 @@
<div class='p-0 md:p-4 m-0 md:m-2'> <div class='p-0 md:p-4 m-0 md:m-2'>
<div class="relative w-full h-full"> <div class="relative w-full h-full">
<!-- Modal content --> <!-- Modal content -->
<div class="relative bg-white rounded-lg shadow"> <div class="relative bg-white rounded-lg shadow overflow-hidden">
<!-- Modal header --> <!-- Modal header -->
<div class="p-2 md:p-4 border-0 md:border-b rounded-t relative"> <div class="p-4 md:p-6 border-b relative">
<div class="flex flex-col lg:flex-row justify-between items-start gap-4 mr-8"> <div class="flex flex-col w-full pr-8">
<div class="flex-grow"> <h3 class="text-2xl font-black text-gray-900 leading-tight">{{ person_name }}</h3>
<h3 class="text-xl font-bold text-gray-900">{{ person_name }}</h3>
{{ render_partial('partials/workout_tags.html', person_id=person_id, workout_id=workout_id, {{ render_partial('partials/workout_tags.html', person_id=person_id, workout_id=workout_id,
tags=tags) }} tags=tags) }}
<div class="grid grid-cols-1 md:grid-cols-2 gap-2 mt-2"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
{{ render_partial('partials/start_date.html', person_id=person_id, workout_id=workout_id, {{ render_partial('partials/start_date.html', person_id=person_id, workout_id=workout_id,
start_date=start_date) }} start_date=start_date) }}
{{ render_partial('partials/workout_note.html', person_id=person_id, workout_id=workout_id, {{ render_partial('partials/workout_note.html', person_id=person_id, workout_id=workout_id,
@@ -62,41 +61,39 @@
</div> </div>
</div> </div>
<div class="flex-shrink-0 w-full lg:w-auto">
{{ render_partial('partials/workout_breakdown.html', person_id=person_id, workout_id=workout_id,
muscle_distribution=muscle_distribution) }}
</div>
</div>
<button type="button" <button type="button"
class="absolute top-2 right-2 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" class="absolute top-4 right-4 text-gray-400 bg-transparent hover:bg-gray-100 hover:text-gray-900 rounded-lg text-sm p-2 transition-colors inline-flex items-center"
hx-get="{{ url_for('workout.delete_workout', person_id=person_id, workout_id=workout_id) }}" hx-get="{{ url_for('workout.delete_workout', person_id=person_id, workout_id=workout_id) }}"
hx-confirm="Are you sure you wish to delete this workout?" hx-push-url="true" hx-confirm="Are you sure you wish to delete this workout?" hx-push-url="true"
hx-target="#container"> hx-target="#container">
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" <svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg" data-darkreader-inline-fill="" xmlns="http://www.w3.org/2000/svg">
style="--darkreader-inline-fill:currentColor;">
<path fill-rule="evenodd" <path fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"></path> clip-rule="evenodd"></path>
</svg> </svg>
<span class="sr-only">Close modal</span> <span class="sr-only">Delete workout</span>
</button> </button>
</div> </div>
<!-- Full-Width Breakdown Stripe -->
<div class="bg-gray-50/50 border-b">
{{ render_partial('partials/workout_breakdown.html', person_id=person_id, workout_id=workout_id,
muscle_distribution=muscle_distribution) }}
</div> </div>
<div class="relative bg-white rounded-lg shadow mt-4"> <!-- Workout Content Card -->
<div class="p-2 md:p-4 border-0 md:border-b rounded-t"> <div class="p-0">
<!-- Modal footer --> <div class="p-2 md:p-4 border-0 md:border-b">
<div class="flex items-center p-1 md:p-2 rounded-b dark:border-gray-600"> <!-- Modal footer / New Set Form -->
<div class="flex items-center p-1 md:p-2 rounded-b">
{{ render_partial('partials/new_set_form.html', person_id=person_id, {{ render_partial('partials/new_set_form.html', person_id=person_id,
workout_id=workout_id, workout_id=workout_id,
exercises=exercises, exercises=exercises,
has_value=False) }} has_value=False) }}
</div> </div>
<!-- Modal body --> <!-- Modal body / Top Sets Table -->
<div class="p-3 md:p-6 space-y-6"> <div class="p-3 md:p-6 space-y-6">
<table class="items-center w-full bg-transparent border-collapse table-fixed"> <table class="items-center w-full bg-transparent border-collapse table-fixed">
<thead> <thead>
@@ -124,21 +121,21 @@
{% if top_sets|length == 0 %} {% if top_sets|length == 0 %}
<div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3" role="alert" <div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3" role="alert"
id="no-workouts"> id="no-workouts">
No top_sets found. No sets recorded for this session.
</div> </div>
{% endif %} {% endif %}
</div> </div>
<div id="exercise-progress" class="mx-0 md:mx-5"> <div id="exercise-progress" class="mx-0 md:mx-5">
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<div class="hidden" hx-get="{{ url_for('get_stats') }}" hx-vals='{"person_id": "{{ person_id }}"}' hx-trigger="load" <div class="hidden" hx-get="{{ url_for('get_stats') }}" hx-vals='{"person_id": "{{ person_id }}"}' hx-trigger="load"
hx-target="#stats" hx-swap="innerHTML"> hx-target="#stats" hx-swap="innerHTML">
</div> </div>
{% endblock %} {% endblock %}