TPTIP-19: карточка блюда — отдельные строки, отступ под нижнее меню
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
27019195a1
commit
116aacb168
13
index.html
13
index.html
@ -17,7 +17,7 @@
|
||||
|
||||
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
|
||||
html,body{margin:0;background:var(--bg);color:var(--text);font:16px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
||||
#app{max-width:640px;margin:0 auto;min-height:100vh;padding:12px 16px calc(84px + env(safe-area-inset-bottom))}
|
||||
#app{max-width:640px;margin:0 auto;min-height:100vh;padding:12px 16px calc(120px + env(safe-area-inset-bottom))}
|
||||
h1,h2,h3{margin:0}
|
||||
h2{font-size:1.15rem}
|
||||
h3{font-size:1rem}
|
||||
@ -83,6 +83,9 @@ input:focus,select:focus,textarea:focus,button:focus-visible{outline:2px solid v
|
||||
.item:first-child{border-top:0}
|
||||
.item .main{flex:1;min-width:0;cursor:pointer;overflow-wrap:anywhere}
|
||||
.item .main b{display:block;overflow-wrap:anywhere}
|
||||
.item .main .dish-row{display:block;margin-top:4px}
|
||||
.item.dish{flex-wrap:wrap}
|
||||
.item.dish>button{flex:none;margin-left:auto}
|
||||
.badge{display:inline-block;border-radius:999px;padding:1px 8px;font-size:.75rem;background:var(--bg);border:1px solid var(--line);color:var(--muted)}
|
||||
.ok{color:var(--ok)}.bad{color:var(--bad)}
|
||||
.quick{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
|
||||
@ -887,12 +890,12 @@ function chooseRecipe(r) {
|
||||
function recipeView(r, actions) {
|
||||
const lines = r.ingredients.split('\n').map(x => x.trim()).filter(Boolean);
|
||||
const steps = (r.steps || '').split('\n').map(x => x.trim()).filter(Boolean);
|
||||
return h('div', { class: 'item', style: 'align-items:flex-start' },
|
||||
return h('div', { class: 'item dish', style: 'align-items:flex-start' },
|
||||
r.photo ? h('img', { src: r.photo, alt: r.title, style: 'width:96px;height:96px;object-fit:cover;border-radius:12px;flex:none' }) : h('div', { style: 'width:96px;height:96px;border-radius:12px;background:var(--bg);display:flex;align-items:center;justify-content:center;font-size:2rem;flex:none' }, '🍲'),
|
||||
h('div', { class: 'main', onclick: () => { if (db.recipes.includes(r)) openRecipeForm({ entry: r }); } }, h('b', null, r.title),
|
||||
h('span', { class: 'muted small' }, '⏱ ' + r.time + ' мин'),
|
||||
r.kcal != null ? h('span', { class: 'small', 'data-nutrition': '' }, (r.grams ? 'Порция ' + fmtInt(r.grams) + ' г · ' : '') + fmtInt(r.kcal) + ' ккал · Б ' + fmt(r.protein || 0) + ' · Ж ' + fmt(r.fat || 0) + ' · У ' + fmt(r.carbs || 0)) : null,
|
||||
lines.length ? h('div', { class: 'small' }, 'Состав: ' + lines.join(', ')) : null,
|
||||
h('span', { class: 'muted small dish-row' }, '⏱ ' + r.time + ' мин'),
|
||||
r.kcal != null ? h('span', { class: 'small dish-row', 'data-nutrition': '' }, (r.grams ? 'Порция ' + fmtInt(r.grams) + ' г · ' : '') + fmtInt(r.kcal) + ' ккал · Б ' + fmt(r.protein || 0) + ' · Ж ' + fmt(r.fat || 0) + ' · У ' + fmt(r.carbs || 0)) : null,
|
||||
lines.length ? h('div', { class: 'small dish-row' }, 'Состав: ' + lines.join(', ')) : null,
|
||||
steps.length ? h('div', { class: 'small', 'data-steps': '' }, h('b', null, 'Как приготовить'), h('ol', { style: 'margin:4px 0 0;padding-left:20px' }, ...steps.map(x => h('li', null, x)))) : null),
|
||||
actions);
|
||||
}
|
||||
|
||||
@ -92,3 +92,11 @@ test('Сценарий: на пустом дне рядом с кольцами
|
||||
[...document.querySelectorAll('button')].find(b => b.textContent === 'Выбрать').click();
|
||||
assert.equal(document.querySelector('[data-empty-hint]'), null);
|
||||
});
|
||||
|
||||
test('Сценарий: время, порция и состав в карточке — отдельные строки, меню не закрывает низ', t => {
|
||||
const { dom, document } = open(); t.after(() => dom.window.close());
|
||||
const card = [...document.querySelectorAll('.item')].find(i => i.querySelector('[data-nutrition]'));
|
||||
const rows = card.querySelectorAll('.main .dish-row');
|
||||
assert.ok(rows.length >= 3, 'время, порция и состав должны быть отдельными строками');
|
||||
assert.match(source, /#app\{[^}]*padding:12px 16px calc\(1[2-9]\dpx/);
|
||||
});
|
||||
|
||||
@ -76,13 +76,14 @@ test('Сценарий: после «Выбрать» видны вес и КБ
|
||||
assert.match(row.textContent, new RegExp(n[2] + ' ккал · Б ' + n[3] + ' · Ж ' + n[4] + ' · У ' + n[5]));
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
test('Сценарий: рецепт читается на телефоне — текст переносится, а не обрезается', () => {
|
||||
const css = source.match(/\.item \.main\{[^}]*\}/)[0];
|
||||
assert.match(css, /min-width:0/);
|
||||
assert.match(css, /overflow-wrap:anywhere/);
|
||||
assert.doesNotMatch(source, /text-overflow:\s*ellipsis/);
|
||||
=======
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
test('Сценарий: на пустом дне рядом с кольцами есть подсказка, после «Выбрать» она исчезает', t => {
|
||||
const { dom, document } = open(); t.after(() => dom.window.close());
|
||||
const hint = document.querySelector('[data-empty-hint]');
|
||||
@ -91,5 +92,12 @@ test('Сценарий: на пустом дне рядом с кольцами
|
||||
assert.match(document.querySelector('[data-choose-hint]').textContent, /«Выбрать» добавит блюдо в приём пищи и в кольца/);
|
||||
[...document.querySelectorAll('button')].find(b => b.textContent === 'Выбрать').click();
|
||||
assert.equal(document.querySelector('[data-empty-hint]'), null);
|
||||
>>>>>>> d4dee26 (TPTIP-17: подсказка на пустом главном экране)
|
||||
=======
|
||||
test('Сценарий: время, порция и состав в карточке — отдельные строки, меню не закрывает низ', t => {
|
||||
const { dom, document } = open(); t.after(() => dom.window.close());
|
||||
const card = [...document.querySelectorAll('.item')].find(i => i.querySelector('[data-nutrition]'));
|
||||
const rows = card.querySelectorAll('.main .dish-row');
|
||||
assert.ok(rows.length >= 3, 'время, порция и состав должны быть отдельными строками');
|
||||
assert.match(source, /#app\{[^}]*padding:12px 16px calc\(1[2-9]\dpx/);
|
||||
>>>>>>> 576873e (TPTIP-19: карточка блюда — отдельные строки, отступ под нижнее меню)
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user