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
+24
View File
@@ -64,3 +64,27 @@ body[data-theme="dark"] .food-tabs a[aria-current=page]{color:#102317}
.inventory-product-card{display:grid;gap:.8rem}.inventory-product-heading{display:flex;align-items:center;gap:1rem;min-width:0}.inventory-product-heading img{width:68px;height:68px;object-fit:contain;background:white;border-radius:.6rem}.inventory-product-heading h2{margin:0}.inventory-product-heading p{margin:.25rem 0;overflow-wrap:anywhere}.inventory-packages summary,.inventory-use summary{cursor:pointer;min-height:44px;align-content:center;font-weight:650}.inventory-package-list{display:grid;gap:.65rem;margin:.6rem 0}.inventory-package{display:flex;align-items:center;gap:.8rem;padding:.65rem;border:1px solid var(--food-border);border-radius:.7rem;min-width:0}.inventory-package>div:last-child{min-width:0}.inventory-package p{margin:.2rem 0}.inventory-package small{color:var(--food-muted)}.inventory-package-fill{flex:none;position:relative;width:42px;height:64px;border:2px solid var(--food-muted);border-radius:.3rem;overflow:hidden;background:var(--food-progress-track)}.inventory-package-fill span{position:absolute;bottom:0;left:0;right:0;background:var(--food-green);transition:height .25s ease}.inventory-use-form{display:flex;flex-wrap:wrap;gap:.6rem;align-items:end}.inventory-use-form label{display:grid;gap:.25rem;flex:1;min-width:100px}.inventory-use-form input,.inventory-use-form select{max-width:100%;min-height:44px}.inventory-use-form button{min-height:44px}.inventory-preview{border:1px solid var(--food-border);border-radius:.7rem;padding:.8rem;margin-top:.7rem}.inventory-preview h3{margin:0}.inventory-preview form{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}.inventory-preview form button,.inventory-history button{min-height:44px}.inventory-preview [role=alert]{color:#e9aa72}.inventory-history ul{padding-left:1.2rem}.inventory-history li{margin:.4rem 0}.inventory-history li form{display:inline-block;margin-left:.5rem}@media(max-width:480px){.inventory-product-heading{align-items:flex-start}.inventory-use-form{display:grid;grid-template-columns:1fr 1fr}.inventory-use-form label:nth-child(3){grid-column:1/-1}.inventory-use-form button{grid-column:1/-1}}@media(prefers-reduced-motion:reduce){.inventory-package-fill span{transition:none}}
.food-entry-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.3rem;flex:none}.food-entry-actions a{display:inline-flex;align-items:center;min-height:44px;padding:.2rem .35rem}.food-entry-actions a:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}@media(max-width:480px){.food-entry{flex-wrap:wrap}.food-entry-actions{width:100%;justify-content:flex-start}}
/* Inventory search remains available when additional filters are collapsed. */
.inventory-filters{display:block}
.inventory-filter-search label{display:block;min-width:0;margin-bottom:.3rem;font-size:.82rem;font-weight:700}
.inventory-filter-search>div{display:flex;gap:.6rem;min-width:0}
.inventory-filter-search input{flex:1;min-width:0;min-height:44px}
.inventory-filter-search button{min-height:44px}
.inventory-filter-details{min-width:0;margin-top:.65rem}
.inventory-filter-details summary{display:flex;align-items:center;min-height:44px;cursor:pointer;font-weight:700}
.inventory-filter-details summary:focus-visible{outline:2px solid var(--food-green);outline-offset:2px;border-radius:.3rem}
.inventory-filter-options{display:flex;flex-wrap:wrap;gap:.75rem;align-items:end;padding-top:.4rem}
.inventory-filter-options label{min-width:130px}
.inventory-filter-options .inventory-check{align-self:center}
@media(min-width:821px){.inventory-filter-details[open]>summary{display:none}}
@media(max-width:480px){.inventory-filters{padding:.9rem}.inventory-filter-options label{flex-basis:100%;min-width:0}}
.inventory-filter-search input{padding:.6rem .75rem;border:1px solid var(--food-border);border-radius:.65rem;color:var(--food-ink);background:var(--food-surface)}
.inventory-filter-search input:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}
.inventory-filter-details summary::after{content:'⌄';margin-left:auto;font-size:1.2rem;line-height:1}
.inventory-filter-details[open] summary::after{transform:rotate(180deg)}
.inventory-filter-options select{width:100%;min-height:44px;padding:.55rem .65rem;border:1px solid var(--food-border);border-radius:.65rem;color:var(--food-ink);background:var(--food-surface)}
.inventory-filter-options select:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}
.inventory-heading-actions{display:flex;align-items:center;justify-content:flex-end;gap:.5rem;flex-wrap:wrap}
.inventory-heading-actions .button{min-height:44px}
@media(max-width:600px){.inventory-page>.food-heading{align-items:flex-start;flex-wrap:wrap}.inventory-heading-actions{justify-content:flex-start;width:100%}}
+3 -2
View File
@@ -1,6 +1,6 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Add to Kitchen Inventory · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}">
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261012-actions">
<div class="food-form-page inventory-page"><a href="{% url 'food:inventory' %}">← Kitchen Inventory</a><h1>Add to inventory</h1>
{% if product %}
<section class="food-card inventory-product">{% if product.image_url %}<img src="{{ product.image_url }}" alt="" loading="lazy">{% endif %}<div><h2>{{ product.product_name }}</h2>{% if product.brand %}<p>{{ product.brand }}</p>{% endif %}{% if product.package_quantity %}<p>{{ product.package_quantity }}</p>{% endif %}{% if off_categories %}<p><small>Open Food Facts: {{ off_categories }}</small></p>{% endif %}</div></section>
@@ -11,8 +11,9 @@
<button class="button" type="submit">Add to inventory</button></form>
<a href="{% url 'food:inventory-add' %}">Choose another product</a>
{% else %}
{% include 'food/partials/inventory_product_actions.html' %}
<form method="get" class="food-search"><label for="inventory-query">Search saved products</label><input id="inventory-query" name="q" type="search" value="{{ query }}" autofocus><button class="button" type="submit">Search</button></form>
<ul class="food-product-list">{% for item in products %}<li><a href="{% url 'food:inventory-add' %}?product={{ item.pk }}">{% if item.image_url %}<img src="{{ item.image_url }}" alt="" loading="lazy">{% endif %}<span><strong>{{ item.product_name }}</strong>{% if item.brand %}<small>{{ item.brand }}</small>{% endif %}</span></a></li>{% empty %}<li>No saved products found.</li>{% endfor %}</ul>
<div class="food-actions"><a class="button" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a><a class="button button--secondary" href="{% url 'food:inventory-external' %}?q={{ query|urlencode }}">Search Open Food Facts</a><a class="button button--secondary" href="{% url 'food:inventory-manual' %}">Create manual product</a></div>
{% include 'food/partials/inventory_product_actions.html' %}
<form method="post" action="{% url 'food:inventory-lookup' %}" class="food-barcode-form">{% csrf_token %}<label for="inventory-barcode">Enter barcode</label><input id="inventory-barcode" name="barcode" inputmode="numeric" pattern="[0-9]+" required><button class="button button--secondary" type="submit">Look up</button></form>
{% endif %}</div><script src="{% static 'food/inventory.js' %}" defer></script>{% endblock %}
@@ -1,12 +1,15 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Kitchen Inventory · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261011-packages">
<div class="food-page inventory-page"><header class="food-heading"><div><h1>Kitchen Inventory</h1><p>What you have and where it lives.</p></div><a class="button" href="{% url 'food:inventory-add' %}">+ Add item</a></header>
<form method="get" class="food-card inventory-filters"><label>Search<input type="search" name="q" value="{{ query }}"></label><label>Location<select name="location"><option value="">All locations</option>{% for location in locations %}<option value="{{ location.pk }}" {% if selected_location == location.pk|stringformat:'s' %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select></label><label>Category<select name="category"><option value="">All categories</option>{% for category in categories %}<option value="{{ category.pk }}" {% if selected_category == category.pk|stringformat:'s' %}selected{% endif %}>{{ category.name }}</option>{% endfor %}</select></label><label>Opened<select name="opened"><option value="">All</option><option value="yes" {% if opened == 'yes' %}selected{% endif %}>Opened</option><option value="no" {% if opened == 'no' %}selected{% endif %}>Unopened</option></select></label><label>Sort<select name="sort"><option value="location" {% if sort == 'location' %}selected{% endif %}>Location</option><option value="category" {% if sort == 'category' %}selected{% endif %}>Category</option><option value="name" {% if sort == 'name' %}selected{% endif %}>Product name</option><option value="recent" {% if sort == 'recent' %}selected{% endif %}>Recently added</option><option value="best_before" {% if sort == 'best_before' %}selected{% endif %}>Best before</option></select></label><label class="inventory-check"><input type="checkbox" name="use_soon" value="1" {% if use_soon == '1' %}checked{% endif %}> Use soon</label><button class="button" type="submit">Apply</button></form>
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261012-filters">
<div class="food-page inventory-page"><header class="food-heading"><div><h1>Kitchen Inventory</h1><p>What you have and where it lives.</p></div><div class="inventory-heading-actions"><a class="button" href="{% url 'food:inventory-add' %}">+ Add item</a><a class="button button--secondary" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a></div></header>
<form method="get" class="food-card inventory-filters" role="search" aria-label="Search kitchen inventory">
<div class="inventory-filter-search"><label for="inventory-search">Search inventory</label><div><input id="inventory-search" type="search" name="q" value="{{ query }}"><button class="button" type="submit">Search</button></div></div>
<details class="inventory-filter-details" data-responsive-filters open><summary>More filters{% if selected_location or selected_category or opened or use_soon == '1' or sort != 'location' %} · Applied{% endif %}</summary><div class="inventory-filter-options"><label>Location<select name="location"><option value="">All locations</option>{% for location in locations %}<option value="{{ location.pk }}" {% if selected_location == location.pk|stringformat:'s' %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select></label><label>Category<select name="category"><option value="">All categories</option>{% for category in categories %}<option value="{{ category.pk }}" {% if selected_category == category.pk|stringformat:'s' %}selected{% endif %}>{{ category.name }}</option>{% endfor %}</select></label><label>Opened<select name="opened"><option value="">All</option><option value="yes" {% if opened == 'yes' %}selected{% endif %}>Opened</option><option value="no" {% if opened == 'no' %}selected{% endif %}>Unopened</option></select></label><label>Sort<select name="sort"><option value="location" {% if sort == 'location' %}selected{% endif %}>Location</option><option value="category" {% if sort == 'category' %}selected{% endif %}>Category</option><option value="name" {% if sort == 'name' %}selected{% endif %}>Product name</option><option value="recent" {% if sort == 'recent' %}selected{% endif %}>Recently added</option><option value="best_before" {% if sort == 'best_before' %}selected{% endif %}>Best before</option></select></label><label class="inventory-check"><input type="checkbox" name="use_soon" value="1" {% if use_soon == '1' %}checked{% endif %}> Use soon</label><button class="button" type="submit">Apply filters</button></div></details>
</form>
{% for card in cards %}<article class="food-card inventory-product-card">
<div class="inventory-product-heading">{% if card.product.image_url %}<img src="{{ card.product.image_url }}" alt="" loading="lazy">{% endif %}<div><h2>{{ card.product.product_name }}</h2>{% if card.product.brand %}<p>{{ card.product.brand }}</p>{% endif %}<p><strong>{{ card.total|floatformat:-3 }} {% if card.unit == "packs" and card.total == 1 %}pack{% else %}{{ card.unit }}{% endif %} remaining</strong> · {{ card.packages|length }} package{{ card.packages|length|pluralize }}</p></div></div>
<details class="inventory-packages"><summary>View packages</summary><div class="inventory-package-list">{% for item in card.packages %}<div class="inventory-package"><div class="inventory-package-fill" role="img" aria-label="{{ item.percentage_remaining }}% remaining"><span style="height:{{ item.percentage_remaining }}%"></span></div><div><strong>Pack {{ forloop.counter }} · {{ item.package_status|title }}</strong><p>{% if item.original_amount %}{{ item.remaining_amount|floatformat:-3 }} / {{ item.original_amount|floatformat:-3 }} {{ item.inventory_unit }} · {{ item.percentage_remaining }}% remaining{% else %}{{ item.quantity }} pack{{ item.quantity|pluralize }} · size unknown{% endif %}</p><small>{{ item.location.name }}{% if item.category %} · {{ item.category.name }}{% endif %}{% if item.best_before %} · Best before {{ item.best_before }}{% endif %}</small><div><a href="{% url 'food:inventory-edit' item.pk %}">Edit package</a></div></div></div>{% endfor %}</div></details>
<details class="inventory-use"><summary>Use amount</summary><form method="post" action="{% url 'food:inventory-preview' card.product.pk %}" hx-post="{% url 'food:inventory-preview' card.product.pk %}" hx-target="#inventory-preview-{{ card.product.pk }}-{{ card.unit }}" hx-swap="innerHTML" class="inventory-use-form">{% csrf_token %}<label>Amount<input type="number" name="amount" min="{% if card.count_unit %}1{% else %}0.001{% endif %}" step="{% if card.count_unit %}1{% else %}0.001{% endif %}" required inputmode="decimal"></label><label>Unit<select name="unit">{% for unit in card.units %}<option value="{{ unit }}" {% if unit == card.unit %}selected{% endif %}>{{ unit }}</option>{% endfor %}</select></label><label>Package (optional)<select name="package_id"><option value="">Automatic selection</option>{% for item in card.packages %}<option value="{{ item.api_id }}">Pack {{ forloop.counter }} · {% if item.remaining_amount is not None %}{{ item.remaining_amount|floatformat:-3 }} {{ item.inventory_unit }}{% else %}{{ item.quantity }} pack{{ item.quantity|pluralize }}{% endif %}</option>{% endfor %}</select></label><button class="button button--secondary" type="submit">Preview</button></form><div id="inventory-preview-{{ card.product.pk }}-{{ card.unit }}" aria-live="polite"></div></details>
</article>{% empty %}<section class="food-card"><p>No inventory items found.</p><a class="button" href="{% url 'food:inventory-add' %}">Add your first item</a></section>{% endfor %}
{% if recent_consumption %}<section class="food-card inventory-history"><h2>Recent use</h2><ul>{% for entry in recent_consumption %}<li>{{ entry.created_at|date:'j M, H:i' }} · {{ entry.product.product_name }} · {{ entry.amount|floatformat:-3 }} {{ entry.unit }}<details><summary>Package changes</summary><ul>{% for line in entry.lines.all %}<li>Pack {{ line.package.pk }}: {{ line.before_amount|floatformat:-3 }} → {{ line.after_amount|floatformat:-3 }} {{ line.unit }}</li>{% endfor %}</ul></details>{% if not entry.reversal %}<form method="post" action="{% url 'food:inventory-undo' entry.pk %}">{% csrf_token %}<button type="submit">Undo</button></form>{% else %} · Undone{% endif %}</li>{% endfor %}</ul></section>{% endif %}
</div>{% endblock %}
</div><script src="{% static 'planner/responsive_filters.js' %}?v=1" defer></script>{% endblock %}
@@ -0,0 +1,5 @@
<div class="food-actions inventory-product-actions">
<a class="button" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a>
<a class="button button--secondary" href="{% url 'food:inventory-external' %}?q={{ query|urlencode }}">Search Open Food Facts</a>
<a class="button button--secondary" href="{% url 'food:inventory-manual' %}">Create manual product</a>
</div>
+1 -1
View File
@@ -8,7 +8,7 @@
"dev:django": "VITE_USE_DEV_SERVER=false ../../tasksnest/bin/python ../manage.py runserver 0.0.0.0:1234",
"dev:hmr": "concurrently --kill-others-on-fail --names vite,django --prefix-colors cyan,green \"npm run dev:vite\" \"npm run dev:django:hmr\"",
"dev:vite": "vite",
"dev:django:hmr": "../../tasksnest/bin/python ../manage.py runserver 0.0.0.0:1234",
"dev:django:hmr": "VITE_USE_DEV_SERVER=true ../../tasksnest/bin/python ../manage.py runserver 0.0.0.0:1234",
"build": "vite build",
"preview": "vite preview"
},
@@ -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>
+25
View File
@@ -4,3 +4,28 @@
@media(prefers-reduced-motion:reduce){.recipe-match__card{transition:none}.recipe-match__confetti i{animation:none;display:none}}
.recipe-match{--recipe-surface:#fff;--recipe-line:#e4e8e2;--recipe-ink:#25292e;--recipe-muted:#687178}body[data-theme=dark] .recipe-match{--recipe-surface:#202a23;--recipe-line:#435046;--recipe-ink:#eaf0ea;--recipe-muted:#afbbb2}
.recipe-match__celebration{bottom:auto;height:320px}@media(max-width:600px){.recipe-match__celebration{height:min(76vw,320px)}}
.recipe-match__filter-panel{margin-bottom:24px;border:1px solid var(--recipe-line);border-radius:15px;background:var(--recipe-surface)}.recipe-match__filter-panel summary{display:flex;align-items:center;gap:10px;min-height:54px;padding:12px 16px;list-style:none;cursor:pointer;font-size:.88rem;font-weight:800}.recipe-match__filter-panel summary::-webkit-details-marker{display:none}.recipe-match__filter-panel summary small{margin-left:auto;color:var(--recipe-muted);font-size:.72rem;font-weight:600}.recipe-match__filter-panel summary::after{content:'⌄';margin-left:5px;color:var(--recipe-muted);font-size:1.25rem;line-height:1;transition:transform .15s ease}.recipe-match__filter-panel[open] summary::after{transform:rotate(180deg)}.recipe-match__filter-panel summary:focus-visible{outline:3px solid #a44cbe;outline-offset:3px;border-radius:12px}.recipe-match__filter-panel .recipe-match__filters{margin:0;padding:15px;border:0;border-radius:0;background:transparent}.recipe-match__image{height:280px}.recipe-match__celebration{height:280px}@media(min-width:601px){.recipe-match__filter-panel[open]>summary{display:none}}@media(max-width:600px){.recipe-match__filter-panel{margin-bottom:18px}.recipe-match__filter-panel[open] summary{border-bottom:1px solid var(--recipe-line)}.recipe-match__filter-panel .recipe-match__filters{padding:12px}.recipe-match__image,.recipe-match__celebration{height:min(70vw,280px)}}
.recipe-match__header{margin-bottom:16px}.recipe-match__eyebrow{margin-top:14px}.recipe-match__filter-panel{margin-bottom:18px}.recipe-match__counter{margin-bottom:8px}.recipe-match__actions{margin-top:16px}.recipe-match__image,.recipe-match__celebration{height:clamp(240px,26vh,280px)}@media(max-width:600px){.recipe-match__image,.recipe-match__celebration{height:min(70vw,280px)}}
body[data-theme=dark] .recipe-match__image-fallback{color:#253029}body[data-theme=dark] .recipe-match__kind{color:#a9dfb8}
@media(min-width:701px) and (max-width:820px){.site-header__inner{gap:10px;padding-inline:16px}.primary-nav{gap:10px;font-size:.82rem}}
@media(min-width:601px) and (max-width:820px){.recipe-match__filter-panel[open]>summary{display:flex;border-bottom:1px solid var(--recipe-line)}}
/* Search stays visible while native details collapse the advanced fields. */
.recipe-match__filter-panel{display:block;padding:12px 15px}
.recipe-match__search-row{display:flex;align-items:end;gap:9px}
.recipe-match__search-row label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
.recipe-match__search-row input{flex:1;min-width:0;min-height:44px;padding:9px;border:1px solid var(--recipe-line);border-radius:9px;color:var(--recipe-ink);background:var(--recipe-surface)}
.recipe-match__search-row button{min-height:44px;padding:9px 15px;border:0;border-radius:9px;color:#fff;background:#235943;font-weight:700;cursor:pointer}
.recipe-match__more-filters summary{display:flex;align-items:center;gap:10px;min-height:44px;margin-top:7px;padding:0 2px;list-style:none;cursor:pointer;font-size:.82rem;font-weight:800}
.recipe-match__more-filters summary::-webkit-details-marker{display:none}
.recipe-match__more-filters summary small{margin-left:auto;color:var(--recipe-muted);font-size:.72rem;font-weight:600}
.recipe-match__more-filters summary::after{content:'⌄';margin-left:5px;color:var(--recipe-muted);font-size:1.25rem;line-height:1;transition:transform .15s ease}
.recipe-match__more-filters[open] summary::after{transform:rotate(180deg)}
.recipe-match__more-filters summary:focus-visible{outline:3px solid #a44cbe;outline-offset:2px;border-radius:6px}
.recipe-match__filter-panel .recipe-match__filters{margin:0;padding:7px 0 0;border:0;border-radius:0;background:transparent}
.recipe-match__filters label:first-child{flex:1 1 135px}
.recipe-match__reset{justify-self:end;margin:0 0 7px}
.recipe-match__reset button{min-height:44px;padding:8px 13px;border:1px solid var(--recipe-line);border-radius:9px;color:var(--recipe-ink);background:var(--recipe-surface);font-size:.82rem;font-weight:700;cursor:pointer}
.recipe-match__reset button:hover{border-color:#a44cbe}
@media(min-width:821px){.recipe-match__more-filters[open]>summary{display:none}}
@media(max-width:600px){.recipe-match__filter-panel{padding:12px}.recipe-match__filter-panel .recipe-match__filters{padding-top:7px}.recipe-match__search-row button{padding-inline:12px}}
+9
View File
@@ -24,3 +24,12 @@ body[data-theme=dark] .recipes-markdown-editor .toastui-editor-defaultUI,body[da
.recipes-cook-entry{margin:16px 0 0}.recipes-cook-entry .button{display:inline-flex;align-items:center;min-height:44px}.recipes-cooking,.recipes-cooking-finish{max-width:960px}.recipes-cooking-grid{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(260px,1fr);gap:16px}.recipes-cooking .recipes-panel h2,.recipes-cooking-finish .recipes-panel h2{margin:0 0 12px;font-family:Fraunces,Georgia,serif;font-size:1.35rem}.recipes-cooking-heading{display:flex;align-items:start;justify-content:space-between;gap:12px}.recipes-cooking-progress{margin:4px 0 18px;color:var(--recipe-accent);font-size:.85rem;font-weight:700}.recipes-cooking-step{display:flex;align-items:start;gap:18px;min-height:180px;font-size:1.15rem;line-height:1.65}.recipes-cooking-step[hidden]{display:none}.recipes-cooking-step .recipes-markdown-source{font-size:inherit}.recipes-cooking-number{display:grid;flex:none;place-items:center;width:40px;height:40px;border-radius:50%;color:#fff;background:#235943;font-weight:700}.recipes-cooking-navigation{display:flex;justify-content:space-between;gap:12px;margin-top:18px}.recipes-cooking-navigation button{min-height:44px}.recipes-cooking-navigation button:disabled{opacity:.5;cursor:not-allowed}.recipes-cooking-ingredients ul{padding:0;margin:0;list-style:none}.recipes-cooking-ingredients li{border-bottom:1px solid var(--recipe-line)}.recipes-cooking-ingredients li:last-child{border:0}.recipes-cooking-ingredients label{display:flex;align-items:center;gap:10px;min-height:52px;font-size:.87rem}.recipes-cooking-ingredients input{flex:none;width:20px;height:20px;accent-color:var(--recipe-accent)}.recipes-cooking-ingredients span{flex:1;min-width:0}.recipes-cooking-ingredients small{display:block;color:var(--recipe-muted)}.recipes-cooking-ingredients strong{white-space:nowrap}.recipes-cooking-ingredients input:checked+span{text-decoration:line-through;color:var(--recipe-muted)}.recipes-cooking-components{margin-top:25px;border-top:1px solid var(--recipe-line)}.recipes-cooking-components h3{margin:18px 0 8px}.recipes-cooking-components details{padding:10px 0;border-bottom:1px solid var(--recipe-line)}.recipes-cooking-components summary{cursor:pointer;font-weight:700}.recipes-cooking-components .recipes-markdown-source{margin-top:12px}.recipes-cooking-footer{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:14px;margin-top:16px;padding:16px;border:1px solid var(--recipe-line);border-radius:12px;background:var(--recipe-surface)}.recipes-cooking-footer p{margin:0;color:var(--recipe-muted);font-size:.84rem}.recipes-cooking-finish>.recipes-panel{margin-bottom:14px}.recipes-completion-form{display:grid;gap:15px}.recipes-completion-form>p{margin:0;color:var(--recipe-muted);font-size:.85rem}.recipes-completion-choice{display:flex;align-items:start;gap:12px;padding:13px;border:1px solid var(--recipe-line);border-radius:10px;cursor:pointer}.recipes-completion-choice input{width:20px;height:20px;accent-color:var(--recipe-accent)}.recipes-completion-choice span{display:grid;gap:3px}.recipes-completion-choice small{color:var(--recipe-muted)}.recipes-completion-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.recipes-completion-fields label{display:grid;gap:5px;font-size:.82rem;font-weight:700}.recipes-completion-fields input,.recipes-completion-fields select{width:100%;min-height:44px;padding:8px;border:1px solid var(--recipe-line);border-radius:8px;color:var(--recipe-ink);background:var(--recipe-surface)}.recipes-completion-form>.button{justify-self:start;min-height:44px}
@media(max-width:767px){.recipes-cooking-grid{grid-template-columns:1fr}.recipes-cooking-steps{min-height:300px}.recipes-cooking-step{min-height:190px}.recipes-cooking-footer .button{width:100%;text-align:center}.recipes-completion-fields{grid-template-columns:1fr}.recipes-cooking-navigation button{flex:1}}
.recipes-cooking-meter{display:block;width:100%;height:9px;margin:-9px 0 21px;accent-color:var(--recipe-accent)}
/* Keep search available while the additional library filters are collapsed. */
.recipes-filter-details{min-width:0}
.recipes-filter-details summary{display:flex;align-items:center;min-height:44px;padding:0 2px;cursor:pointer;color:var(--recipe-ink);font-size:.82rem;font-weight:700}
.recipes-filter-details summary:focus-visible{outline:3px solid var(--recipe-accent);outline-offset:2px;border-radius:6px}
.recipes-filter-options{display:grid;gap:12px;padding-top:7px}
@media(min-width:821px){.recipes-filter-details[open]>summary{display:none}}
.recipes-filter-details summary::after{content:'⌄';margin-left:auto;font-size:1.2rem;line-height:1}
.recipes-filter-details[open] summary::after{transform:rotate(180deg)}
+7 -3
View File
@@ -2,7 +2,7 @@
{% block title %}Recipes · Tasknest{% endblock %}
{% block page_class %}recipes-page-content{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}?v=4">
<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}?v=5">
<div class="recipes-layout {% if explicit_detail %}recipes-layout--detail{% else %}recipes-layout--list{% endif %}">
<aside class="recipes-browser" aria-label="Recipe browser">
<div class="recipes-browser__heading">
@@ -12,12 +12,15 @@
<form method="get" action="{% url 'recipes:list' %}" class="recipes-filters" role="search">
<label for="recipes-search">Search recipes</label>
<div class="recipes-search-row"><input id="recipes-search" type="search" name="q" value="{{ query }}" placeholder="Search recipes or ingredients"><button type="submit">Search</button></div>
<div class="recipes-filter-grid">
<details class="recipes-filter-details" data-responsive-filters open>
<summary>More filters{% if category or tag or favourite %} · Applied{% endif %}</summary>
<div class="recipes-filter-options"><div class="recipes-filter-grid">
<label>Category<select name="category"><option value="">All categories</option>{% for value in categories %}<option value="{{ value }}"{% if value == category %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
<label>Tag<select name="tag"><option value="">All tags</option>{% for value in tags %}<option value="{{ value }}"{% if value == tag %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
</div>
<label class="recipes-favourite-filter"><input type="checkbox" name="favourite" value="1"{% if favourite %} checked{% endif %}> Favourites only</label>
<button class="recipes-filter-apply" type="submit">Apply filters</button>
<button class="recipes-filter-apply" type="submit">Apply filters</button></div>
</details>
</form>
<div class="recipes-list" aria-label="Your recipes">
{% for recipe in recipes %}
@@ -59,4 +62,5 @@
<section class="recipes-panel"><h3>Actions</h3><a class="recipes-action" href="{% url 'recipes:edit' selected.api_id %}">Edit recipe</a><form method="post" action="{% url 'recipes:create-variation' selected.api_id %}" class="recipes-action-form">{% csrf_token %}<button type="submit" class="recipes-action">Create variation</button></form>{% if last_use %}<form method="post" action="{% url 'recipes:stock-undo' last_use.pk %}" class="recipes-action-form">{% csrf_token %}<button type="submit" class="recipes-action">Undo last inventory use</button></form>{% endif %}<a class="recipes-action recipes-action--danger" href="{% url 'recipes:delete' selected.api_id %}">Delete recipe</a></section>
</aside>{% endif %}
</div>
<script src="{% static 'planner/responsive_filters.js' %}?v=1" defer></script>
{% endblock %}
+15 -8
View File
@@ -3,19 +3,25 @@
{% block page_class %}recipes-page-content{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}?v=4">
<link rel="stylesheet" href="{% static 'recipes/match.css' %}?v=2">
<link rel="stylesheet" href="{% static 'recipes/match.css' %}?v=7">
<div class="recipe-match">
<header class="recipe-match__header">
<div><a class="recipes-back" href="{% url 'recipes:list' %}">← Back to recipes</a><p class="recipe-match__eyebrow">A little cooking demo</p><h1>Recipe Match <span aria-hidden="true">♡</span></h1><p>Explore recipes one card at a time. Select a recipe to see if the demo account picked it too.</p></div>
</header>
<form class="recipe-match__filters" method="get" role="search" aria-label="Filter recipe cards">
<label>Search<input type="search" name="q" value="{{ query }}" placeholder="Title or ingredient"></label>
<label>Category<select name="category"><option value="">All categories</option>{% for value in categories %}<option value="{{ value }}"{% if value == category %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
<label>Tag<select name="tag"><option value="">All tags</option>{% for value in tags %}<option value="{{ value }}"{% if value == tag %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
<label>Time<select name="time"><option value="">Any time</option><option value="30"{% if time_limit == '30' %} selected{% endif %}>Up to 30 min</option><option value="60"{% if time_limit == '60' %} selected{% endif %}>Up to 60 min</option></select></label>
<button type="submit">Apply filters</button>
<form class="recipe-match__filter-panel" method="get" role="search" aria-label="Filter recipe cards">
<div class="recipe-match__search-row"><label for="match-search">Search recipes</label><input id="match-search" type="search" name="q" value="{{ query }}" placeholder="Title or ingredient"><button type="submit">Search</button></div>
<details class="recipe-match__more-filters" data-responsive-filters open>
<summary><span>More filters</span><small>{% if category or tag or time_limit %}Filters applied{% else %}All recipes{% endif %}</small></summary>
<div class="recipe-match__filters">
<label>Category<select name="category"><option value="">All categories</option>{% for value in categories %}<option value="{{ value }}"{% if value == category %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
<label>Tag<select name="tag"><option value="">All tags</option>{% for value in tags %}<option value="{{ value }}"{% if value == tag %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
<label>Time<select name="time"><option value="">Any time</option><option value="30"{% if time_limit == '30' %} selected{% endif %}>Up to 30 min</option><option value="60"{% if time_limit == '60' %} selected{% endif %}>Up to 60 min</option></select></label>
<button type="submit">Apply filters</button>
</div>
</details>
</form>
<section class="recipe-match__stage" aria-label="Recipe discovery">
<form class="recipe-match__reset" method="post" action="{% url 'recipes:match-reset' %}">{% csrf_token %}<button type="submit" aria-label="Start over and show all recipes">↺ Start over</button></form>
<p class="recipe-match__counter" data-match-counter aria-live="polite"></p>
<div class="recipe-match__deck" data-match-deck>
{% for recipe in recipes %}
@@ -35,5 +41,6 @@
</section>
</div>
<input type="hidden" id="recipe-match-csrf" value="{{ csrf_token }}">
<script src="{% static 'recipes/match.js' %}?v=4" defer></script>
<script src="{% static 'planner/responsive_filters.js' %}?v=1" defer></script>
<script src="{% static 'recipes/match.js' %}?v=7" defer></script>
{% endblock %}
+14
View File
@@ -53,6 +53,20 @@ class RecipeMatchTests(TestCase):
with transaction.atomic(), self.assertRaises(IntegrityError):
RecipeSelection.objects.create(user=self.user, recipe=self.recipe)
def test_reset_restores_own_cards_and_preserves_other_picks(self):
RecipeSelection.objects.create(user=self.demo, recipe=self.recipe)
RecipeSelection.objects.create(user=self.other, recipe=self.recipe)
RecipeSelection.objects.create(user=self.user, recipe=self.recipe)
url = reverse('recipes:match-reset')
self.assertEqual(self.client.get(url).status_code, 405)
self.assertNotContains(self.client.get(reverse('recipes:match')), 'Lemon salmon')
response = self.client.post(url)
self.assertRedirects(response, reverse('recipes:match'))
self.assertFalse(RecipeSelection.objects.filter(user=self.user).exists())
self.assertTrue(RecipeSelection.objects.filter(user=self.demo, recipe=self.recipe).exists())
self.assertTrue(RecipeSelection.objects.filter(user=self.other, recipe=self.recipe).exists())
self.assertContains(self.client.get(reverse('recipes:match')), 'Lemon salmon')
def test_seed_and_reset_uses_existing_demo_recipes(self):
self.recipe.status = Recipe.Status.DRAFT
self.recipe.save(update_fields=('status',))
+1
View File
@@ -7,6 +7,7 @@ app_name = 'recipes'
urlpatterns = [
path('', views.library, name='list'),
path('match/', views.match, name='match'),
path('match/reset/', views.match_reset, name='match-reset'),
path('match/<uuid:identifier>/select/', views.match_select, name='match-select'),
path('match/<uuid:identifier>/photo/', views.match_photo, name='match-photo'),
path('new/', views.create, name='create'),
+8
View File
@@ -74,6 +74,14 @@ def match(request):
})
@login_required
@require_POST
def match_reset(request):
RecipeSelection.objects.filter(user=request.user).delete()
messages.success(request, 'Your Recipe Match picks have been reset.')
return redirect('recipes:match')
@login_required
@require_POST
def match_select(request, identifier):
+3 -3
View File
@@ -161,10 +161,10 @@ USE_TZ = True
STATIC_URL = 'static/'
MEDIA_ROOT = BASE_DIR / 'private_media'
# Vite writes production assets and its manifest here. In development templates
# load modules from the Vite server configured by VITE_DEV_SERVER.
# Vite writes built assets and its manifest here. Use the Vite server only when
# explicitly requested by the HMR workflow.
VITE_DEV_SERVER = os.environ.get('VITE_DEV_SERVER', 'http://localhost:5173')
VITE_USE_DEV_SERVER = os.environ.get('VITE_USE_DEV_SERVER', str(DEBUG)).lower() in {'1', 'true', 'yes'}
VITE_USE_DEV_SERVER = os.environ.get('VITE_USE_DEV_SERVER', 'false').lower() in {'1', 'true', 'yes'}
VITE_MANIFEST_PATH = BASE_DIR / 'planner' / 'static' / 'planner' / 'dist' / '.vite' / 'manifest.json'
# Open Food Facts is queried only by explicit food search or product lookup.