put food card in separate template
This commit is contained in:
parent
dd0ac1e4c7
commit
e05a4d0ccd
3 changed files with 24 additions and 23 deletions
BIN
foods.db
BIN
foods.db
Binary file not shown.
23
templates/food.html
Normal file
23
templates/food.html
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<div style="border: 1px solid black; margin: 1em; padding: 1em;">
|
||||
<div style="text-align: center;">
|
||||
<p>
|
||||
<b>{{ food.name }}</b>
|
||||
</p>
|
||||
{{ food.portion }} ({{ food.kc_per_serving }} kc.)
|
||||
<br>
|
||||
<progress max="{{food.target_servings}}" value="{{food.actual_servings}}" {% if food.actual_servings>
|
||||
food.target_servings %}
|
||||
style="accent-color: red;"
|
||||
{% endif %}>
|
||||
</progress>
|
||||
{{ food.actual_servings }}/{{ food.target_servings }}
|
||||
</div>
|
||||
<br>
|
||||
<form method="post">
|
||||
<div style="text-align: center;">
|
||||
<button formaction="/decrease/{{ food.id }}" style="width: 40%; height: 3em;" {% if food.actual_servings <=0 %}
|
||||
disabled {% endif %}>-</button>
|
||||
<button formaction="/increase/{{ food.id }}" style="width: 40%; height: 3em;">+</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -12,29 +12,7 @@
|
|||
<main>
|
||||
<div style="display: flex-root; margin: auto; width: fit-content;">
|
||||
{% for food in foods %}
|
||||
<div style="border: 1px solid black; margin: 1em; padding: 1em;">
|
||||
<div style="text-align: center;">
|
||||
<p>
|
||||
<b>{{ food.name }}</b>
|
||||
</p>
|
||||
{{ food.portion }} ({{ food.kc_per_serving }} kc.)
|
||||
<br>
|
||||
<progress max="{{food.target_servings}}" value="{{food.actual_servings}}" {% if food.actual_servings>
|
||||
food.target_servings %}
|
||||
style="accent-color: red;"
|
||||
{% endif %}>
|
||||
</progress>
|
||||
{{ food.actual_servings }}/{{ food.target_servings }}
|
||||
</div>
|
||||
<br>
|
||||
<form method="post">
|
||||
<div style="text-align: center;">
|
||||
<button formaction="/decrease/{{ food.id }}" style="width: 40%; height: 3em;" {% if food.actual_servings <=0
|
||||
%} disabled {% endif %}>-</button>
|
||||
<button formaction="/increase/{{ food.id }}" style="width: 40%; height: 3em;">+</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% include "food.html" %}
|
||||
{% endfor %}
|
||||
<div style="background-color: lightblue; margin: 1em;">
|
||||
<b style="font-size: 24px; padding: 1em;">Total: {{ sum }} kc.</b>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue