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
+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):