+
+
+
+
Wartości odżywcze
+
+
+
+
${total.kcal}kcal
+
${total.protein}gBiałko
+
${total.carbs}gWęgle
+
${total.fat}gTłuszcze
+
+
+
+
-
-
${total.protein} g
-
Białko
+
+
+
Porcje
+
+
+
+ ${currentServings}
+
+
+
+
-
- ${total.carbs} g
- Węglo.
-
-
- ${total.fat} g
- Tłuszcze
-
-
-
`;
-}
-
-function renderIngredientCard(name, amount, unit, nutrition, extra) {
- const displayAmount = Number.isInteger(amount) ? amount : parseFloat(amount.toFixed(1));
- const macroHtml = nutrition
- ? `
- ${nutrition.protein}g B${nutrition.fat}g T${nutrition.carbs}g W
-
`
- : '';
- const kcalHtml = nutrition
- ? `
${nutrition.kcal} kcal`
- : '';
-
- return `
- `;
}
@@ -245,21 +258,24 @@ function renderIngredients(recipe) {
const effectiveDef = INGREDIENTS[effectiveId];
const effectiveName = effectiveDef?.name || effectiveId;
const scaledAmount = ing.amount * currentServings;
- const nutrition = nutritionForAmount(effectiveId, scaledAmount, ing.unit);
- const isSwapped = effectiveId !== origId;
const isExpanded = expandedAlternatives.has(origId);
+ const rowStyle = 'background:#393937 !important; background-image:none !important; box-shadow:none !important; border:none !important;';
const toggleBtn = hasAlts
- ? `
`
+ ? `
`
: '';
- const cardBorder = isSwapped ? 'border-amber-200' : 'border-gray-200';
- const cardCls = isSwapped ? 'bg-amber-50/30' : 'bg-white';
- const cardHtml = renderIngredientCard(effectiveName, scaledAmount, ing.unit, nutrition, {
- suffix: toggleBtn,
- border: cardBorder,
- cls: cardCls,
- });
+ let rowHtml = `
`;
+ rowHtml += '
';
+ rowHtml += `
${escapeHtml(effectiveName)}
`;
+ rowHtml += '
';
+ rowHtml += toggleBtn;
+ rowHtml += `
+ ${fmtAmt(scaledAmount)}
+ ${escapeHtml(ing.unit)}
+
`;
+ rowHtml += '
';
+ rowHtml += '
';
let altListHtml = '';
if (hasAlts && isExpanded) {
@@ -268,32 +284,46 @@ function renderIngredients(recipe) {
const def = INGREDIENTS[altId];
const altName = def?.name || altId;
const isSelected = effectiveId === altId;
- const isOriginal = altId === origId;
const altNutrition = nutritionForAmount(altId, scaledAmount, ing.unit);
+ const checkbox = `
+
+ ${isSelected ? '' : ''}
+ `;
+ const nutritionLine = altNutrition
+ ? `
${altNutrition.kcal} kcal · ${altNutrition.protein}g B · ${altNutrition.fat}g T · ${altNutrition.carbs}g W
`
+ : '';
- const radioDot = `
`;
- const defaultTag = isOriginal ? `
Domyślny` : '';
-
- return renderIngredientCard(altName, scaledAmount, ing.unit, altNutrition, {
- cls: isSelected ? 'bg-gray-50' : 'bg-white hover:bg-gray-50 cursor-pointer',
- border: isSelected ? 'border-gray-900 ring-1 ring-gray-900' : 'border-gray-100',
- prefix: radioDot,
- badge: defaultTag,
- dataAttrs: `data-original-id="${escapeHtml(origId)}" data-alt-id="${escapeHtml(altId)}"`,
- });
+ return `
`;
});
altListHtml = `
-
+
${optionCards.join('')}
`;
}
- return `
${cardHtml}${altListHtml}`;
+ rowHtml += altListHtml;
+ rowHtml += '
';
+ return `
${rowHtml}`;
}).join('');
container.innerHTML = `
${renderNutritionSummary(recipe)}
-
`;
+
`;
+
+ container.querySelector('#rd-serv-minus')?.addEventListener('click', () => {
+ if (currentServings <= 1) return;
+ currentServings--;
+ renderIngredients(recipe);
+ updateKcalDisplay();
+ });
+
+ container.querySelector('#rd-serv-plus')?.addEventListener('click', () => {
+ if (currentServings >= 12) return;
+ currentServings++;
+ renderIngredients(recipe);
+ updateKcalDisplay();
+ });
container.querySelectorAll('.rd-alt-toggle').forEach((btn) => {
btn.addEventListener('click', () => {
@@ -332,16 +362,16 @@ function renderSteps(recipe) {
const steps = recipe.steps || [];
if (steps.length === 0) {
- container.innerHTML = '
Brak kroków przygotowania.
';
+ container.innerHTML = `
Brak kroków przygotowania.
`;
return;
}
container.innerHTML = `
-
+
${steps.map((step, i) => `
-
-
${i + 1}
-
+
`).join('')}
`;
}
@@ -364,36 +394,12 @@ export function setupRecipeDetail() {
}
document.querySelectorAll('.rd-tab-btn').forEach((b) => {
- b.classList.remove('text-gray-900', 'border-gray-900', 'font-semibold');
- b.classList.add('text-gray-500', 'border-transparent', 'font-medium');
+ setTabButtonState(b, false);
});
- btn.classList.remove('text-gray-500', 'border-transparent', 'font-medium');
- btn.classList.add('text-gray-900', 'border-gray-900', 'font-semibold');
+ setTabButtonState(btn, true);
});
});
- document.getElementById('rd-serv-minus')?.addEventListener('click', () => {
- if (currentServings <= 1) return;
- currentServings--;
- document.getElementById('rd-servings').textContent = currentServings;
- const recipe = RECIPES[currentRecipeId];
- if (recipe) {
- renderIngredients(recipe);
- updateKcalDisplay();
- }
- });
-
- document.getElementById('rd-serv-plus')?.addEventListener('click', () => {
- if (currentServings >= 12) return;
- currentServings++;
- document.getElementById('rd-servings').textContent = currentServings;
- const recipe = RECIPES[currentRecipeId];
- if (recipe) {
- renderIngredients(recipe);
- updateKcalDisplay();
- }
- });
-
/* ── planner — delegate to MealPlanEditor ─────── */
document.getElementById('rd-add-to-planner-btn')?.addEventListener('click', () => {