started with new design

This commit is contained in:
Khaïs COLIN 2025-10-20 14:34:24 +02:00
parent 28ea420ecb
commit 9238366137
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
6 changed files with 525 additions and 38 deletions

View file

@ -1,28 +1,51 @@
<div style="border: 1px solid black; margin: 1em; padding: 1em; background: {{ food.color }};" id="food-{{ food.id }}">
<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 hx-post="/decrease/{{ food.id }}" hx-target="#food-{{ food.id }}" hx-swap="outerHTML"
style="width: 40%; height: 3em;" {% if food.actual_servings <=0 %} disabled {% endif %}>
-
</button>
<button hx-post="/increase/{{ food.id }}" hx-target="#food-{{ food.id }}" hx-swap="outerHTML"
style="width: 40%; height: 3em;">
+
</button>
<div class="card">
<p class="food-name">
{{ food.name }}
</p>
<div class="card-inner">
<div class="amounts">
<p class="unit">
<sup>1</sup>&frasl;<sub>4</sub> Cup
</p>
<p class="kc">
{{ food.kc_per_serving }} kc
</p>
</div>
</form>
<div class="buttons">
<button class="increase">+</button>
<button class="decrease">-</button>
</div>
<div class="checkboxes">
<label class="ok">
<input type="checkbox" checked>
</label>
<label class="ok">
<input type="checkbox">
</label>
<label class="ok">
<input type="checkbox" checked>
</label>
<label class="bad">
<input type="checkbox" checked>
</label>
<label class="bad">
<input type="checkbox" checked>
</label>
<label class="bad">
<input type="checkbox">
</label>
<label class="bad">
<input type="checkbox">
</label>
<label class="bad">
<input type="checkbox">
</label>
<label class="bad">
<input type="checkbox">
</label>
<label class="bad">
<input type="checkbox">
</label>
</div>
</div>
</div>

193
templates/index-new.html Normal file
View file

@ -0,0 +1,193 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.7/dist/htmx.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Food Tracker</title>
</head>
<body>
<header>
<span>
Datum: {{ date }}
</span>
<div>
<span>
kc: {{ sum.kc }}
</span>
<span>
Protein: {{ sum.protein }}
</span>
<span>
Balaststoffe: {{ sum.bs }}
</span>
</div>
</header>
<main>
<hr>
<div class="card">
<p class="food-name">
{{ food.name }}
</p>
<div class="card-inner">
<div class="amounts">
<p class="unit">
<sup>1</sup>&frasl;<sub>4</sub> Cup
</p>
<p class="kc">
{{ food.kc_per_serving }} kc
</p>
</div>
<div class="buttons">
<button class="increase">+</button>
<button class="decrease">-</button>
</div>
<div class="checkboxes">
<div class="ok">
<input type="checkbox" checked>
</div>
<div class="ok">
<input type="checkbox">
</div>
<div class="ok">
<input type="checkbox" checked>
</div>
<div class="bad">
<input type="checkbox" checked>
</div>
<div class="bad">
<input type="checkbox" checked>
</div>
<div class="bad">
<input type="checkbox">
</div>
<div class="bad">
<input type="checkbox">
</div>
<div class="bad">
<input type="checkbox">
</div>
<div class="bad">
<input type="checkbox">
</div>
<div class="bad">
<input type="checkbox">
</div>
</div>
</div>
</div>
<hr>
</main>
</body>
<style>
html {
font-family: sans-serif;
}
body {
margin: 0;
}
header {
display: inline-block;
text-align: center;
width: 100%;
background-color: hsl(from #a8c8a6 h 40% l);
padding: 2px;
#a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6
}
header div {
width: 100%;
}
header div span {
width: 30%;
display: inline-block;
text-align: left;
}
.card {
background-color: hsl(from #a8c8a6 h 30% l);
#a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6 #a8c8a6
}
hr {
margin: 0;
border: 1px solid #655057;
}
.card p {
margin: 0;
padding: 2px;
}
.food-name {
font-size: 1.2em;
}
.buttons {
display: flex;
flex-direction: column;
height: 100%;
}
.card-inner {
display: flex;
align-items: center;
gap: 5px;
}
.card-inner div button {
display: block;
}
button {
border: 0;
border-radius: 5px;
width: 2em;
height: 2em;
}
.increase {
background-color: #cb8175;
}
.decrease {
background-color: #6d8d8a;
}
.increase:hover {
background-color: hsl(from #cb8175 h 80% l);
}
.decrease:hover {
background-color: hsl(from #6d8d8a h 40% l);
}
input[type="checkbox"] {
width: 2em;
height: 2em;
}
.checkboxes {
display: flex;
}
.ok {
accent-color: hsl(from #a8c8a6 h 90% l);
background-color: hsl(from #a8c8a6 h 60% l);
}
.bad {
accent-color: hsl(from #cb8175 h 90% l);
background-color: hsl(from #cb8175 h 60% l);
}
</style>
</html>

View file

@ -10,14 +10,142 @@
</head>
<body>
<main>
<div style="display: flex-root; margin: auto; width: fit-content;">
{% for food in foods %}
{% include "food.html" %}
{% endfor %}
{% include "sum.html" %}
<header>
<span>
Datum: {{ date }}
</span>
<div>
<span>
kc: {{ sum.kc }}
</span>
<span>
Protein: {{ sum.protein }}
</span>
<span>
Balaststoffe: {{ sum.bs }}
</span>
</div>
</header>
<main>
<hr>
{% for food in foods %}
{% include "food.html" %}
{% if !loop.last %}
<hr>
{% endif %}
{% endfor %}
</main>
</body>
<style>
html {
font-family: sans-serif;
border: 2px solid hsl(from #a8c8a6 h 40% l);
}
body {
margin: 0;
}
header {
display: inline-block;
text-align: center;
width: 100%;
background-color: hsl(from #a8c8a6 h 40% l);
}
header div {
width: 100%;
display: flex;
align-items: stretch;
}
header div span {
text-align: left;
width: inherit;
}
.card {
background-color: hsl(from #a8c8a6 h 30% l);
}
hr {
border: 0;
padding: 0;
margin: 0;
border-bottom: 1px dashed #655057;
background: #655057;
}
.card p {
margin: 0;
padding: 2px;
}
.food-name {
font-size: 1.2em;
}
.buttons {
display: flex;
flex-direction: column;
height: 100%;
}
.card-inner {
display: flex;
align-items: stretch;
gap: 5px;
}
.card-inner div button {
display: block;
}
button {
border: 0;
border-radius: 5px;
width: 2em;
height: 2em;
}
.increase {
background-color: #cb8175;
}
.decrease {
background-color: #6d8d8a;
}
.increase:hover {
background-color: hsl(from #cb8175 h 80% l);
}
.decrease:hover {
background-color: hsl(from #6d8d8a h 40% l);
}
.checkboxes {
display: flex;
align-items: stretch;
justify-content: center;
flex-grow: 1;
}
.checkboxes label {
flex-grow: 1;
align-content: center;
}
.ok {
accent-color: hsl(from #a8c8a6 h 90% l);
background-color: hsl(from #a8c8a6 h 60% l);
}
.bad {
accent-color: hsl(from #cb8175 h 90% l);
background-color: hsl(from #cb8175 h 60% l);
}
</style>
</html>