adding food logging, phase 5

This commit is contained in:
Joren de Graaf
2026-10-03 21:25:56 +02:00
parent e7ddb0ea28
commit 8d1afab9e8
20 changed files with 627 additions and 73 deletions
+3
View File
@@ -2,3 +2,6 @@
.food-product-image{display:block;max-width:180px;max-height:180px;object-fit:contain;background:#fff;border-radius:1rem;margin:0 auto 1rem}
.food-tabs,.food-actions{display:flex;gap:.5rem;flex-wrap:wrap;margin:1rem 0}.food-tabs a{padding:.55rem .9rem;border-radius:2rem;border:1px solid currentColor;text-decoration:none}.food-tabs a[aria-current=page]{background:#62bd70;color:#111;border-color:#62bd70}.food-product-list a,.food-result-button{display:flex;align-items:center;gap:.8rem;width:100%;text-align:left}.food-product-list img{width:58px;height:58px;object-fit:contain;background:#fff;border-radius:.6rem}.food-product-list strong,.food-product-list small{display:block}.food-result-button{border:0;background:none;color:inherit;font:inherit;cursor:pointer;min-height:44px}.food-barcode-form{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin:1rem 0}.food-barcode-form input{min-width:130px;flex:1}.food-attribution{font-size:.85rem;opacity:.8}
.food-scanner{max-width:620px;margin:1.5rem auto 6rem}.food-scanner-header{display:flex;align-items:center;gap:1rem}.food-scanner-header a{display:grid;place-items:center;min-width:44px;min-height:44px;font-size:2rem;text-decoration:none}.food-camera-frame{position:relative;aspect-ratio:4/3;background:#111;border-radius:1rem;overflow:hidden}.food-camera-frame video{width:100%;height:100%;object-fit:cover}.food-scan-guide{position:absolute;inset:25% 10%;border:3px solid #62bd70;border-radius:.8rem;pointer-events:none}.food-mobile-switch{display:none}@media(max-width:760px){.food-mobile-switch{position:fixed;bottom:env(safe-area-inset-bottom,0px);left:50%;transform:translateX(-50%);display:flex;gap:.3rem;background:#222;color:#fff;padding:.35rem;border-radius:2rem;z-index:20;box-shadow:0 2px 15px #0008}.food-mobile-switch a,.food-mobile-switch span{display:grid;place-items:center;min-width:110px;min-height:44px;padding:.2rem 1rem;border-radius:2rem;color:inherit;text-decoration:none}.food-mobile-switch [aria-current=page]{background:#555}}
.food-detail-title{display:flex;align-items:center;justify-content:space-between;gap:1rem}.food-favourite-form{flex:none}.food-favourite{min-width:44px;min-height:44px;border:0;background:none;color:#62bd70;font-size:2rem;cursor:pointer}.food-product-list li{display:flex;align-items:center;justify-content:space-between;gap:.5rem}.food-product-list li>a{flex:1;min-width:0}.food-product-list li>.food-favourite-form{margin:0}
/* V1 polish: keep the date and search titles from crowding the useful content. */
.food-heading{align-items:end;margin-bottom:1.1rem}.food-heading h1{font-size:clamp(2rem,3.2vw,3.2rem);line-height:1.08;margin:.25rem 0 0}.food-heading nav a:nth-child(2){border-radius:999px;padding:0 1rem}.food-form-page h1{font-size:clamp(2.3rem,4vw,3.8rem);line-height:1.05;margin:.45rem 0 1rem;overflow-wrap:anywhere}.food-product-list li>a{text-decoration:none}.food-product-list li>a:hover strong,.food-product-list li>a:focus-visible strong{text-decoration:underline}.food-list-empty{border-style:dashed!important;opacity:.72}.food-entry>a{min-width:44px;min-height:44px;display:grid;place-items:center}.food-entry-main strong{overflow-wrap:anywhere}.food-export{margin-top:1.25rem}.food-export p{margin:.3rem 0 1rem;opacity:.75}.food-export-actions{display:flex;gap:.6rem;flex-wrap:wrap}.food-export-actions a{display:inline-flex;align-items:center;min-height:44px;padding:.55rem .8rem;border:1px solid currentColor;border-radius:999px;text-decoration:none}.food-export-actions a:hover,.food-export-actions a:focus-visible{background:#62bd7028}.food-entry-form{display:grid;gap:1rem}.food-entry-form [data-food-custom-fields],.food-entry-form [data-food-save-fields]{display:grid;gap:1rem}.food-entry-form .settings-switch-row{margin:.25rem 0}.food-edit-nutrition p{line-height:1.55}.food-edit-nutrition details{margin-top:.7rem}.food-entry-form .settings-switch input[type=checkbox]{min-height:0;padding:0;border:0;border-radius:0}.food-entry-form .settings-switch__copy strong{font-weight:700}.food-form-page .food-card .form-field label{line-height:1.35}@media(max-width:760px){.food-heading{align-items:start}.food-heading nav{flex:none}.food-heading nav a:nth-child(2){padding:0 .6rem}.food-heading h1{font-size:clamp(1.55rem,6vw,2.2rem)}.food-export{margin-top:.5rem}}
+19
View File
@@ -0,0 +1,19 @@
(() => {
const select = document.querySelector('[data-food-portion-choice]');
if (!select) return;
const amount = document.querySelector('#id_amount');
const custom = document.querySelector('[data-food-custom-fields]');
const amountField = document.querySelector('[data-food-amount-field]');
const save = document.querySelector('#id_save_portion');
const saveFields = document.querySelector('[data-food-save-fields]');
const sync = () => {
const customSelected = select.value === 'custom';
custom.hidden = !customSelected;
amountField.hidden = !customSelected;
if (!customSelected) amount.value = select.selectedOptions[0].dataset.amount || '100';
saveFields.hidden = !customSelected || !save.checked;
};
select.addEventListener('change', sync);
save.addEventListener('change', sync);
sync();
})();