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);
})();