latest changes

This commit is contained in:
Joren de Graaf
2026-10-14 18:02:27 +02:00
parent 2934662d7a
commit b72283818c
19 changed files with 201 additions and 28 deletions
@@ -0,0 +1,17 @@
.checkin-score-details summary{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:2px 8px;min-height:48px;list-style:none;cursor:pointer}
.checkin-score-details summary::-webkit-details-marker{display:none}
.checkin-score-details summary::after{content:'⌄';grid-column:2;grid-row:1;color:#64746a;font-size:1.25rem;line-height:1}
.checkin-score-details[open] summary::after{transform:rotate(180deg)}
.checkin-score-details summary:focus-visible{outline:3px solid #377a53;outline-offset:3px;border-radius:6px}
.checkin-score-details__title{grid-column:1;grid-row:1;color:#235943;font-family:Fraunces,Georgia,serif;font-size:1rem;font-weight:700}
.checkin-score-details__summary{grid-column:1/-1;grid-row:2;color:#56645b;font-size:.78rem;line-height:1.35;overflow-wrap:anywhere}
.checkin-period__content,.bowel-period__content,.checkin-score-details__sleep-fields{margin-top:12px}
.checkin-score-details--sleep{grid-column:1/-1;min-width:0;padding:12px 15px;border:1px solid #dce3da;border-radius:12px;background:#f8faf7}
.checkin-form--sleep>.field:first-of-type{grid-column:1/-1;max-width:190px}
.checkin-score-details__sleep-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.checkin-score-details__sleep-fields .checkin-form__note{grid-column:1/-1}
@media(max-width:500px){.checkin-score-details__sleep-fields{grid-template-columns:1fr}}
body[data-theme=dark] .checkin-score-details__title{color:#9bd5ae}
body[data-theme=dark] .checkin-score-details__summary,body[data-theme=dark] .checkin-score-details summary::after{color:#b5c5b9}
body[data-theme=dark] .checkin-score-details--sleep{border-color:#3b473f;background:#29342d}
body[data-theme=dark] .checkin-score-details summary:focus-visible{outline-color:#9bd5ae}
@@ -0,0 +1,42 @@
(() => {
const score = (panel, name, label, suffix) => {
const value = panel.querySelector(`[name="${name}"]`)?.value.trim();
return value === undefined || value === '' ? null : `${label} ${value}${suffix}`;
};
const updateSummary = (panel) => {
const period = panel.dataset.checkinPeriod;
let scores;
if (panel.dataset.checkinKind === 'pain') {
scores = [
score(panel, `${period}_neck_pain_severity`, 'Neck', '/10'),
score(panel, `${period}_headache_severity`, 'Headache', '/10'),
];
} else if (panel.dataset.checkinKind === 'gut') {
scores = [score(panel, `${period}_severity`, 'Gut', '/10')];
} else {
scores = [
score(panel, 'rested_score', 'Rested', '/10'),
score(panel, 'watch_sleep_score', 'Watch', '%'),
];
}
const summary = panel.querySelector('[data-checkin-summary]');
const entered = scores.filter(Boolean);
summary.textContent = entered.length ? entered.join(' · ') : 'No scores recorded';
};
const initialise = (root = document) => {
root.querySelectorAll('[data-checkin-summary-panel]').forEach(updateSummary);
};
document.addEventListener('DOMContentLoaded', () => initialise());
document.addEventListener('htmx:afterSwap', (event) => initialise(event.detail.elt));
document.addEventListener('input', (event) => {
const panel = event.target.closest?.('[data-checkin-summary-panel]');
if (panel) updateSummary(panel);
});
document.addEventListener('change', (event) => {
const panel = event.target.closest?.('[data-checkin-summary-panel]');
if (panel) updateSummary(panel);
});
})();
@@ -0,0 +1,9 @@
(() => {
const viewport = window.matchMedia('(max-width: 820px)');
const panels = document.querySelectorAll('[data-responsive-filters]');
const update = () => {
panels.forEach((panel) => { panel.open = !viewport.matches; });
};
update();
viewport.addEventListener('change', update);
})();
+3 -1
View File
@@ -1,8 +1,9 @@
{% extends 'planner/base.html' %}
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Health · Tasknest{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'planner/checkin_sections.css' %}?v=2">
<section class="hero" aria-labelledby="health-heading">
<div>
<p class="eyebrow">Personal health tracking</p>
@@ -20,4 +21,5 @@
{% include 'planner/partials/hydration_widget.html' %}
</aside>
</div>
<script src="{% static 'planner/checkin_sections.js' %}?v=1" defer></script>
{% endblock %}
@@ -4,9 +4,9 @@
{% csrf_token %}{% if bowel_form.non_field_errors %}<div class="form-errors">{{ bowel_form.non_field_errors }}</div>{% endif %}
<div class="field">{{ bowel_form.check_in_date.label_tag }}{{ bowel_form.check_in_date }}{{ bowel_form.check_in_date.errors }}</div>
<div class="bowel-periods">
<div class="bowel-period"><h3>Morning</h3><div class="field">{{ bowel_form.morning_severity.label_tag }}{{ bowel_form.morning_severity }}{{ bowel_form.morning_severity.errors }}</div><div class="field">{{ bowel_form.morning_note.label_tag }}{{ bowel_form.morning_note }}{{ bowel_form.morning_note.errors }}</div></div>
<div class="bowel-period"><h3>Afternoon</h3><div class="field">{{ bowel_form.afternoon_severity.label_tag }}{{ bowel_form.afternoon_severity }}{{ bowel_form.afternoon_severity.errors }}</div><div class="field">{{ bowel_form.afternoon_note.label_tag }}{{ bowel_form.afternoon_note }}{{ bowel_form.afternoon_note.errors }}</div></div>
<div class="bowel-period"><h3>Evening</h3><div class="field">{{ bowel_form.evening_severity.label_tag }}{{ bowel_form.evening_severity }}{{ bowel_form.evening_severity.errors }}</div><div class="field">{{ bowel_form.evening_note.label_tag }}{{ bowel_form.evening_note }}{{ bowel_form.evening_note.errors }}</div></div>
<details class="bowel-period checkin-score-details" data-checkin-summary-panel data-checkin-kind="gut" data-checkin-period="morning"{% if bowel_form.morning_severity.errors or bowel_form.morning_note.errors %} open{% endif %}><summary><span class="checkin-score-details__title">Morning</span><span class="checkin-score-details__summary" data-checkin-summary>No score recorded</span></summary><div class="bowel-period__content"><div class="field">{{ bowel_form.morning_severity.label_tag }}{{ bowel_form.morning_severity }}{{ bowel_form.morning_severity.errors }}</div><div class="field">{{ bowel_form.morning_note.label_tag }}{{ bowel_form.morning_note }}{{ bowel_form.morning_note.errors }}</div></div></details>
<details class="bowel-period checkin-score-details" data-checkin-summary-panel data-checkin-kind="gut" data-checkin-period="afternoon"{% if bowel_form.afternoon_severity.errors or bowel_form.afternoon_note.errors %} open{% endif %}><summary><span class="checkin-score-details__title">Afternoon</span><span class="checkin-score-details__summary" data-checkin-summary>No score recorded</span></summary><div class="bowel-period__content"><div class="field">{{ bowel_form.afternoon_severity.label_tag }}{{ bowel_form.afternoon_severity }}{{ bowel_form.afternoon_severity.errors }}</div><div class="field">{{ bowel_form.afternoon_note.label_tag }}{{ bowel_form.afternoon_note }}{{ bowel_form.afternoon_note.errors }}</div></div></details>
<details class="bowel-period checkin-score-details" data-checkin-summary-panel data-checkin-kind="gut" data-checkin-period="evening"{% if bowel_form.evening_severity.errors or bowel_form.evening_note.errors %} open{% endif %}><summary><span class="checkin-score-details__title">Evening</span><span class="checkin-score-details__summary" data-checkin-summary>No score recorded</span></summary><div class="bowel-period__content"><div class="field">{{ bowel_form.evening_severity.label_tag }}{{ bowel_form.evening_severity }}{{ bowel_form.evening_severity.errors }}</div><div class="field">{{ bowel_form.evening_note.label_tag }}{{ bowel_form.evening_note }}{{ bowel_form.evening_note.errors }}</div></div></details>
</div><div class="form-actions"><button class="button button--compact" type="submit">Save gut health check-in</button></div>
</form>
<section class="checkin-calendar" aria-labelledby="bowel-calendar-heading"><header class="checkin-calendar__header">
@@ -30,9 +30,9 @@
<div class="field checkin-form__physio"><label class="checkbox-field">{{ check_in_form.had_physiotherapy }} <span>{{ check_in_form.had_physiotherapy.label }}</span></label></div>
</div>
<div class="checkin-periods">
<section class="checkin-period" aria-labelledby="morning-checkin-heading"><h4 id="morning-checkin-heading">Morning</h4><div class="checkin-period__scores"><div class="field{% if check_in_form.morning_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.morning_neck_pain_severity.label_tag }}{{ check_in_form.morning_neck_pain_severity }}<small>{{ check_in_form.morning_neck_pain_severity.help_text }}</small>{% for error in check_in_form.morning_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.morning_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.morning_headache_severity.label_tag }}{{ check_in_form.morning_headache_severity }}<small>{{ check_in_form.morning_headache_severity.help_text }}</small>{% for error in check_in_form.morning_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.morning_note.errors %} field--error{% endif %}">{{ check_in_form.morning_note.label_tag }}{{ check_in_form.morning_note }}{% for error in check_in_form.morning_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></section>
<section class="checkin-period" aria-labelledby="afternoon-checkin-heading"><h4 id="afternoon-checkin-heading">Afternoon</h4><div class="checkin-period__scores"><div class="field{% if check_in_form.afternoon_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.afternoon_neck_pain_severity.label_tag }}{{ check_in_form.afternoon_neck_pain_severity }}<small>{{ check_in_form.afternoon_neck_pain_severity.help_text }}</small>{% for error in check_in_form.afternoon_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.afternoon_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.afternoon_headache_severity.label_tag }}{{ check_in_form.afternoon_headache_severity }}<small>{{ check_in_form.afternoon_headache_severity.help_text }}</small>{% for error in check_in_form.afternoon_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.afternoon_note.errors %} field--error{% endif %}">{{ check_in_form.afternoon_note.label_tag }}{{ check_in_form.afternoon_note }}{% for error in check_in_form.afternoon_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></section>
<section class="checkin-period" aria-labelledby="evening-checkin-heading"><h4 id="evening-checkin-heading">Evening</h4><div class="checkin-period__scores"><div class="field{% if check_in_form.evening_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.evening_neck_pain_severity.label_tag }}{{ check_in_form.evening_neck_pain_severity }}<small>{{ check_in_form.evening_neck_pain_severity.help_text }}</small>{% for error in check_in_form.evening_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.evening_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.evening_headache_severity.label_tag }}{{ check_in_form.evening_headache_severity }}<small>{{ check_in_form.evening_headache_severity.help_text }}</small>{% for error in check_in_form.evening_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.evening_note.errors %} field--error{% endif %}">{{ check_in_form.evening_note.label_tag }}{{ check_in_form.evening_note }}{% for error in check_in_form.evening_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></section>
<details class="checkin-period checkin-score-details" data-checkin-summary-panel data-checkin-kind="pain" data-checkin-period="morning"{% if check_in_form.morning_neck_pain_severity.errors or check_in_form.morning_headache_severity.errors or check_in_form.morning_note.errors %} open{% endif %}><summary><span class="checkin-score-details__title">Morning</span><span class="checkin-score-details__summary" data-checkin-summary>No scores recorded</span></summary><div class="checkin-period__content"><div class="checkin-period__scores"><div class="field{% if check_in_form.morning_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.morning_neck_pain_severity.label_tag }}{{ check_in_form.morning_neck_pain_severity }}<small>{{ check_in_form.morning_neck_pain_severity.help_text }}</small>{% for error in check_in_form.morning_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.morning_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.morning_headache_severity.label_tag }}{{ check_in_form.morning_headache_severity }}<small>{{ check_in_form.morning_headache_severity.help_text }}</small>{% for error in check_in_form.morning_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.morning_note.errors %} field--error{% endif %}">{{ check_in_form.morning_note.label_tag }}{{ check_in_form.morning_note }}{% for error in check_in_form.morning_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div></details>
<details class="checkin-period checkin-score-details" data-checkin-summary-panel data-checkin-kind="pain" data-checkin-period="afternoon"{% if check_in_form.afternoon_neck_pain_severity.errors or check_in_form.afternoon_headache_severity.errors or check_in_form.afternoon_note.errors %} open{% endif %}><summary><span class="checkin-score-details__title">Afternoon</span><span class="checkin-score-details__summary" data-checkin-summary>No scores recorded</span></summary><div class="checkin-period__content"><div class="checkin-period__scores"><div class="field{% if check_in_form.afternoon_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.afternoon_neck_pain_severity.label_tag }}{{ check_in_form.afternoon_neck_pain_severity }}<small>{{ check_in_form.afternoon_neck_pain_severity.help_text }}</small>{% for error in check_in_form.afternoon_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.afternoon_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.afternoon_headache_severity.label_tag }}{{ check_in_form.afternoon_headache_severity }}<small>{{ check_in_form.afternoon_headache_severity.help_text }}</small>{% for error in check_in_form.afternoon_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.afternoon_note.errors %} field--error{% endif %}">{{ check_in_form.afternoon_note.label_tag }}{{ check_in_form.afternoon_note }}{% for error in check_in_form.afternoon_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div></details>
<details class="checkin-period checkin-score-details" data-checkin-summary-panel data-checkin-kind="pain" data-checkin-period="evening"{% if check_in_form.evening_neck_pain_severity.errors or check_in_form.evening_headache_severity.errors or check_in_form.evening_note.errors %} open{% endif %}><summary><span class="checkin-score-details__title">Evening</span><span class="checkin-score-details__summary" data-checkin-summary>No scores recorded</span></summary><div class="checkin-period__content"><div class="checkin-period__scores"><div class="field{% if check_in_form.evening_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.evening_neck_pain_severity.label_tag }}{{ check_in_form.evening_neck_pain_severity }}<small>{{ check_in_form.evening_neck_pain_severity.help_text }}</small>{% for error in check_in_form.evening_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.evening_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.evening_headache_severity.label_tag }}{{ check_in_form.evening_headache_severity }}<small>{{ check_in_form.evening_headache_severity.help_text }}</small>{% for error in check_in_form.evening_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.evening_note.errors %} field--error{% endif %}">{{ check_in_form.evening_note.label_tag }}{{ check_in_form.evening_note }}{% for error in check_in_form.evening_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div></details>
</div>
<div class="form-actions"><button class="button button--compact" type="submit">Save pain check-in</button></div>
</form>
@@ -44,9 +44,11 @@
<h3 class="checkin-form__heading">Sleep</h3>
{% if sleep_check_in_form.non_field_errors %}<div class="form-errors">{{ sleep_check_in_form.non_field_errors }}</div>{% endif %}
<div class="field{% if sleep_check_in_form.wake_up_date.errors %} field--error{% endif %}">{{ sleep_check_in_form.wake_up_date.label_tag }}{{ sleep_check_in_form.wake_up_date }}{% for error in sleep_check_in_form.wake_up_date.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<details class="checkin-score-details checkin-score-details--sleep" data-checkin-summary-panel data-checkin-kind="sleep"{% if sleep_check_in_form.rested_score.errors or sleep_check_in_form.watch_sleep_score.errors or sleep_check_in_form.note.errors %} open{% endif %}><summary><span class="checkin-score-details__title">Sleep scores</span><span class="checkin-score-details__summary" data-checkin-summary>No scores recorded</span></summary><div class="checkin-score-details__sleep-fields">
<div class="field{% if sleep_check_in_form.rested_score.errors %} field--error{% endif %}">{{ sleep_check_in_form.rested_score.label_tag }}{{ sleep_check_in_form.rested_score }}{% for error in sleep_check_in_form.rested_score.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<div class="field{% if sleep_check_in_form.watch_sleep_score.errors %} field--error{% endif %}">{{ sleep_check_in_form.watch_sleep_score.label_tag }}{{ sleep_check_in_form.watch_sleep_score }}{% for error in sleep_check_in_form.watch_sleep_score.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<div class="field checkin-form__note{% if sleep_check_in_form.note.errors %} field--error{% endif %}">{{ sleep_check_in_form.note.label_tag }}{{ sleep_check_in_form.note }}{% for error in sleep_check_in_form.note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
</div></details>
<div class="form-actions"><button class="button button--compact" type="submit">Save sleep check-in</button></div>
</form>
</div>