CurseTechnique/templates/public_profile.html

159 lines
5.5 KiB
HTML

{% extends "base.html" %}
{% block title %}Public Profile{% endblock %}
{% block content %}
<section class="rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
<h1 class="text-3xl font-bold tracking-tight">@{{ page.username }}</h1>
<p class="mt-2 text-sm text-slate-600">Public profile</p>
</section>
{% if page.show_entries || page.show_weights %}
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
<h2 class="text-xl font-bold tracking-tight">Recent Days</h2>
<div class="mt-3 overflow-x-auto">
<table class="w-full border-collapse">
<thead class="bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500">
<tr><th class="px-3 py-2">Date</th><th class="px-3 py-2">Calories</th><th class="px-3 py-2">Weight</th></tr>
</thead>
<tbody>
{% for row in page.recent_days %}
<tr class="border-t border-slate-200">
<td class="px-3 py-2 text-sm">
{% if page.show_entries %}
<a href="{{ row.day_href }}" class="font-semibold text-teal-700 hover:text-teal-900 hover:underline">{{ row.date_text }}</a>
{% else %}
{{ row.date_text }}
{% endif %}
</td>
<td class="px-3 py-2 text-sm">{% if page.show_entries %}{{ row.calories }}{% else %}Hidden{% endif %}</td>
<td class="px-3 py-2 text-sm">{% if page.show_weights %}{{ row.weight_label }}{% else %}Hidden{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endif %}
{% if page.show_entries || page.show_weights %}
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
<h2 class="text-xl font-bold tracking-tight text-slate-900">Recent Trends</h2>
<p class="mt-1 text-sm text-slate-600">Past 14 days</p>
<div class="mt-4 grid gap-4 lg:grid-cols-2">
{% if page.show_entries %}
<article class="rounded-2xl border border-slate-200 bg-white p-4">
<h3 class="text-sm font-semibold uppercase tracking-wide text-slate-600">Daily Calories</h3>
<div class="mt-3 h-72">
<canvas id="public-calorie-chart"></canvas>
</div>
</article>
{% endif %}
{% if page.show_weights %}
<article class="rounded-2xl border border-slate-200 bg-white p-4">
<h3 class="text-sm font-semibold uppercase tracking-wide text-slate-600">Daily Weight (lbs)</h3>
<div class="mt-3 h-72">
<canvas id="public-weight-chart"></canvas>
</div>
</article>
{% endif %}
</div>
</section>
{% endif %}
{% if page.show_reports %}
<section class="mt-4 grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
{% for card in page.report_cards %}
<article class="rounded-2xl border border-slate-200/90 bg-white p-4 shadow-sm">
<h2 class="text-base font-bold text-slate-900">{{ card.title }}</h2>
<p class="mt-1 text-xs text-slate-500">{{ card.range_label }}</p>
<p class="mt-4 text-3xl font-bold tracking-tight text-slate-900">{{ card.average_calories_per_day }}</p>
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">avg cal/day</p>
</article>
{% endfor %}
</section>
{% endif %}
{% if page.show_planning %}
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
<h2 class="text-xl font-bold tracking-tight">Planning</h2>
<dl class="mt-3 space-y-2 text-sm text-slate-700">
<div class="flex justify-between"><dt>Target weight (lbs)</dt><dd class="font-semibold">{{ page.target_weight_label }}</dd></div>
<div class="flex justify-between"><dt>Target calories</dt><dd class="font-semibold">{{ page.target_calories_label }}</dd></div>
<div class="flex justify-between"><dt>BMR</dt><dd class="font-semibold">{{ page.bmr_label }}</dd></div>
</dl>
</section>
{% endif %}
{% if !page.show_entries && !page.show_weights && !page.show_reports && !page.show_planning %}
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
<p class="text-sm text-slate-600">This user has not shared any data publicly.</p>
</section>
{% endif %}
{% endblock %}
{% block scripts %}
{% if page.show_entries || page.show_weights %}
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const labels = {{ page.chart_labels_js|safe }};
{% if page.show_entries %}
const calories = {{ page.calories_js|safe }};
new Chart(
document.getElementById("public-calorie-chart"),
{
type: "line",
data: {
labels,
datasets: [
{
label: "Daily calories",
data: calories,
borderColor: "#0f766e",
backgroundColor: "rgba(15, 118, 110, 0.15)",
fill: true,
tension: 0.25,
pointRadius: 1.5
}
]
},
options: {
maintainAspectRatio: false,
scales: { y: { beginAtZero: true } }
}
}
);
{% endif %}
{% if page.show_weights %}
const weights = {{ page.weights_js|safe }};
new Chart(
document.getElementById("public-weight-chart"),
{
type: "line",
data: {
labels,
datasets: [
{
label: "Daily weight (lbs)",
data: weights,
borderColor: "#2563eb",
backgroundColor: "rgba(37, 99, 235, 0.15)",
fill: true,
tension: 0.25,
pointRadius: 1.5,
spanGaps: true
}
]
},
options: {
maintainAspectRatio: false
}
}
);
{% endif %}
</script>
{% endif %}
{% endblock %}