Recipes phase 1

This commit is contained in:
Joren de Graaf
2026-10-12 01:37:51 +02:00
parent 000ec834b0
commit 500f72382a
19 changed files with 747 additions and 1 deletions
@@ -0,0 +1,4 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Delete {{ recipe.title }} · Tasknest{% endblock %}
{% block page_class %}recipes-page-content{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}"><div class="recipes-layout recipes-layout--form"><section class="recipes-edit-card recipes-delete"><h1>Delete {{ recipe.title }}?</h1><p>This removes the recipe and its ingredients. This action cannot be undone.</p><form method="post">{% csrf_token %}<button type="submit" class="button button--danger">Delete recipe</button><a href="{% url 'recipes:detail' recipe.api_id %}">Cancel</a></form></section></div>{% endblock %}
+11
View File
@@ -0,0 +1,11 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}{% if creating %}New recipe{% else %}Edit {{ recipe.title }}{% endif %} · Tasknest{% endblock %}
{% block page_class %}recipes-page-content{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}">
<div class="recipes-layout recipes-layout--form"><header class="recipes-form-header"><a href="{% if creating %}{% url 'recipes:list' %}{% else %}{% url 'recipes:detail' recipe.api_id %}{% endif %}">← Back to recipes</a><h1>{% if creating %}New recipe{% else %}Edit recipe{% endif %}</h1><p>Keep ingredients structured and instructions in Markdown.</p></header>
<form method="post" enctype="multipart/form-data" class="recipes-edit-card" data-recipe-form>{% csrf_token %}
{% if form.non_field_errors %}<div class="recipes-form-error" role="alert">{{ form.non_field_errors }}</div>{% endif %}
<section><h2>Recipe details</h2><div class="recipes-form-grid">{% for field in form %}{% if field.name != 'remove_photo' %}<div class="recipes-field recipes-field--{{ field.name }}"><label for="{{ field.id_for_label }}">{{ field.label }}</label>{{ field }}{% if field.help_text %}<small>{{ field.help_text }}</small>{% endif %}{% if field.errors %}<div class="recipes-form-error" role="alert">{{ field.errors }}</div>{% endif %}</div>{% endif %}{% endfor %}{% if recipe.photo %}<div class="recipes-field recipes-field--remove_photo"><img src="{% url 'recipes:photo' recipe.api_id %}" alt="Current recipe photo" class="recipes-current-photo"><label class="recipes-checkbox">{{ form.remove_photo }} Remove current photo</label></div>{% endif %}</div></section>
<section><div class="recipes-section-heading"><div><h2>Ingredients</h2><p>Add measured ingredients now; product matching can be refined later.</p></div><button type="button" class="recipes-outline-button" data-add-ingredient>+ Add ingredient</button></div>{{ ingredients.management_form }}{% if ingredients.non_form_errors %}<div class="recipes-form-error" role="alert">{{ ingredients.non_form_errors }}</div>{% endif %}<div class="recipes-ingredient-forms" data-ingredient-forms>{% for ingredient in ingredients %}{% include 'recipes/ingredient_row.html' %}{% endfor %}</div><template id="recipe-empty-ingredient">{% with ingredient=ingredients.empty_form %}{% include 'recipes/ingredient_row.html' %}{% endwith %}</template></section>
<div class="recipes-form-actions"><button type="submit" class="button">Save recipe</button><a href="{% if creating %}{% url 'recipes:list' %}{% else %}{% url 'recipes:detail' recipe.api_id %}{% endif %}">Cancel</a></div>
</form></div><script defer src="{% static 'recipes/form.js' %}"></script>{% endblock %}
@@ -0,0 +1,6 @@
<div class="recipes-ingredient-form" data-ingredient-row>
{% for hidden in ingredient.hidden_fields %}{{ hidden }}{% endfor %}
<div class="recipes-ingredient-form__main"><div class="recipes-field"><label for="{{ ingredient.name.id_for_label }}">Ingredient name</label>{{ ingredient.name }}{{ ingredient.name.errors }}</div><div class="recipes-field"><label for="{{ ingredient.quantity.id_for_label }}">Quantity</label>{{ ingredient.quantity }}{{ ingredient.quantity.errors }}</div><div class="recipes-field"><label for="{{ ingredient.unit.id_for_label }}">Unit</label>{{ ingredient.unit }}{{ ingredient.unit.errors }}</div></div>
<details class="recipes-ingredient-form__more"><summary>Ingredient details</summary><div class="recipes-form-grid"><div class="recipes-field"><label for="{{ ingredient.preparation_note.id_for_label }}">Preparation note</label>{{ ingredient.preparation_note }}{{ ingredient.preparation_note.errors }}</div><div class="recipes-field"><label for="{{ ingredient.display_order.id_for_label }}">Display order</label>{{ ingredient.display_order }}{{ ingredient.display_order.errors }}</div><div class="recipes-field"><label for="{{ ingredient.inventory_product.id_for_label }}">Inventory product</label>{{ ingredient.inventory_product }}{{ ingredient.inventory_product.errors }}</div><div class="recipes-field"><label for="{{ ingredient.nutrition_product.id_for_label }}">Nutrition product</label>{{ ingredient.nutrition_product }}{{ ingredient.nutrition_product.errors }}</div><label class="recipes-checkbox">{{ ingredient.is_optional }} Optional ingredient</label>{% if ingredient.DELETE %}<label class="recipes-checkbox">{{ ingredient.DELETE }} Remove ingredient</label>{% endif %}</div></details>
{% if ingredient.non_field_errors %}<div class="recipes-form-error" role="alert">{{ ingredient.non_field_errors }}</div>{% endif %}
</div>
@@ -0,0 +1,57 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Recipes · Tasknest{% endblock %}
{% block page_class %}recipes-page-content{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}">
<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">
<div><h1>Recipes</h1><p>Find, create and cook with what you have.</p></div>
<a class="button recipes-new" href="{% url 'recipes:create' %}">+ New recipe</a>
</div>
<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">
<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>
</form>
<div class="recipes-list" aria-label="Your recipes">
{% for recipe in recipes %}
<a class="recipes-list-item{% if selected.pk == recipe.pk %} recipes-list-item--selected{% endif %}" href="{% url 'recipes:detail' recipe.api_id %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}"{% if selected.pk == recipe.pk %} aria-current="page"{% endif %}>
{% if recipe.photo %}<img class="recipes-list-item__image" src="{% url 'recipes:photo' recipe.api_id %}" alt="" loading="lazy">{% else %}<span class="recipes-list-item__placeholder" aria-hidden="true">Recipe</span>{% endif %}
<span class="recipes-list-item__body"><strong>{{ recipe.title }}</strong><small>{{ recipe.total_minutes }} min · {{ recipe.default_servings|floatformat:-2 }} servings</small><span class="recipes-list-item__tags">{% if recipe.category %}<span>{{ recipe.category }}</span>{% endif %}{% for value in recipe.tags|slice:':2' %}<span>{{ value }}</span>{% endfor %}</span></span>
{% if recipe.is_favourite %}<span class="recipes-list-item__favourite" aria-label="Favourite">♥</span>{% endif %}
</a>
{% empty %}
<div class="recipes-empty-list"><p>{% if query or category or tag or favourite %}No recipes match these filters.{% else %}Your recipe library is ready.{% endif %}</p><a href="{% url 'recipes:create' %}">Create a recipe</a></div>
{% endfor %}
</div>
</aside>
<section class="recipes-detail" aria-label="Recipe details">
{% if selected %}
<div class="recipes-detail__top"><a class="recipes-back" href="{% url 'recipes:list' %}">← Back to recipes</a><div class="recipes-detail__top-actions"><form method="post" action="{% url 'recipes:favourite' selected.api_id %}">{% csrf_token %}<button type="submit" class="recipes-heart" aria-label="{% if selected.is_favourite %}Remove {{ selected.title }} from favourites{% else %}Add {{ selected.title }} to favourites{% endif %}" aria-pressed="{% if selected.is_favourite %}true{% else %}false{% endif %}">{% if selected.is_favourite %}♥{% else %}♡{% endif %}</button></form><a class="recipes-outline-button" href="{% url 'recipes:edit' selected.api_id %}">Edit</a></div></div>
<div class="recipes-hero">
{% if selected.photo %}<img src="{% url 'recipes:photo' selected.api_id %}" alt="Photo of {{ selected.title }}">{% else %}<div class="recipes-photo-placeholder" role="img" aria-label="No recipe photo yet"><span>No photo yet</span></div>{% endif %}
<div class="recipes-hero__copy"><p class="recipes-eyebrow">{% if selected.status == 'draft' %}Draft recipe{% else %}Recipe{% endif %}</p><h2>{{ selected.title }}</h2><p class="recipes-hero__meta">{{ selected.total_minutes }} min total · {{ selected.default_servings|floatformat:-2 }} servings</p><div class="recipes-chips">{% if selected.category %}<span>{{ selected.category }}</span>{% endif %}{% for value in selected.tags %}<span>{{ value }}</span>{% endfor %}</div>{% if selected.description %}<p class="recipes-hero__description">{{ selected.description }}</p>{% endif %}</div>
</div>
<div class="recipes-content-grid">
<section class="recipes-panel" aria-labelledby="recipe-ingredients-heading"><h3 id="recipe-ingredients-heading">Ingredients</h3><ul class="recipes-ingredient-list">{% for ingredient in selected.ingredients.all %}<li><span>{{ ingredient.name }}{% if ingredient.preparation_note %}<small>{{ ingredient.preparation_note }}</small>{% endif %}</span><strong>{{ ingredient.quantity|floatformat:-3 }} {{ ingredient.unit }}</strong>{% if ingredient.is_optional %}<em>Optional</em>{% endif %}</li>{% empty %}<li class="recipes-muted">No ingredients added yet.</li>{% endfor %}</ul></section>
<div class="recipes-content-stack"><section class="recipes-panel" aria-labelledby="recipe-instructions-heading"><h3 id="recipe-instructions-heading">Instructions</h3>{% if selected.instructions_markdown %}<div class="recipes-markdown-source">{{ selected.instructions_markdown|linebreaksbr }}</div>{% else %}<p class="recipes-muted">No instructions added yet.</p>{% endif %}</section>{% if selected.notes_markdown %}<section class="recipes-panel" aria-labelledby="recipe-notes-heading"><h3 id="recipe-notes-heading">Notes</h3><div class="recipes-markdown-source">{{ selected.notes_markdown|linebreaksbr }}</div></section>{% endif %}</div>
</div>
{% else %}
<div class="recipes-empty-detail"><h2>Make room for something delicious.</h2><p>Save a recipe to see its ingredients and instructions here.</p><a class="button" href="{% url 'recipes:create' %}">Create your first recipe</a></div>
{% endif %}
</section>
{% if selected %}<aside class="recipes-info" aria-label="Recipe information">
<section class="recipes-panel"><h3>At a glance</h3><dl class="recipes-facts"><div><dt>Servings</dt><dd>{{ selected.default_servings|floatformat:-2 }}</dd></div><div><dt>Preparation</dt><dd>{{ selected.preparation_minutes }} min</dd></div><div><dt>Cooking</dt><dd>{{ selected.cooking_minutes }} min</dd></div><div><dt>Status</dt><dd>{{ selected.get_status_display }}</dd></div></dl></section>
{% if selected.parent or selected.variations.all or selected.subrecipes.all %}<section class="recipes-panel"><h3>Related recipes</h3>{% if selected.parent %}<p>Variation of <a href="{% url 'recipes:detail' selected.parent.api_id %}">{{ selected.parent.title }}</a></p>{% endif %}{% for variation in selected.variations.all %}<p><a href="{% url 'recipes:detail' variation.api_id %}">{{ variation.title }}</a></p>{% endfor %}{% for item in selected.subrecipes.all %}<p>{{ item.quantity|floatformat:-3 }} {{ item.unit }} of <a href="{% url 'recipes:detail' item.component.api_id %}">{{ item.component.title }}</a></p>{% endfor %}</section>{% endif %}
<section class="recipes-panel"><h3>Actions</h3><a class="recipes-action" href="{% url 'recipes:edit' selected.api_id %}">Edit recipe</a><a class="recipes-action recipes-action--danger" href="{% url 'recipes:delete' selected.api_id %}">Delete recipe</a></section>
</aside>{% endif %}
</div>
{% endblock %}