Spaces:
Running
Running
Add 1 files
Browse files- index.html +177 -8
index.html
CHANGED
|
@@ -96,6 +96,13 @@
|
|
| 96 |
font-weight: bold;
|
| 97 |
color: #4A00E0;
|
| 98 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
@keyframes pulse {
|
| 100 |
0% { transform: scale(1); }
|
| 101 |
50% { transform: scale(1.05); }
|
|
@@ -167,7 +174,7 @@
|
|
| 167 |
<label class="block text-gray-700 mb-2 flex items-center">
|
| 168 |
<span class="emoji-input">⚖️</span> Peso (kg)
|
| 169 |
</label>
|
| 170 |
-
<input type="number" id="weight" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="40" max="200
|
| 171 |
</div>
|
| 172 |
|
| 173 |
<div>
|
|
@@ -292,6 +299,25 @@
|
|
| 292 |
</div>
|
| 293 |
</div>
|
| 294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
<div class="mt-8">
|
| 296 |
<button id="calculateBtn" class="w-full gradient-bg text-white py-4 rounded-xl font-bold text-lg hover:opacity-90 transition duration-300 flex items-center justify-center pulse-animation">
|
| 297 |
<span class="emoji-input">✨</span> Calcular mis macronutrientes
|
|
@@ -387,6 +413,17 @@
|
|
| 387 |
</div>
|
| 388 |
</div>
|
| 389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
<!-- Nueva sección de alimentos recomendados -->
|
| 391 |
<div class="mt-8 bg-gradient-to-br from-gray-50 to-gray-100 rounded-2xl p-6 border-2 border-gray-200">
|
| 392 |
<h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
|
|
@@ -667,6 +704,7 @@
|
|
| 667 |
const goal = document.getElementById('goal').value;
|
| 668 |
const bodyfat = parseInt(document.getElementById('bodyfat').value) || 20;
|
| 669 |
const useCustomMacros = document.getElementById('customMacrosToggle').checked;
|
|
|
|
| 670 |
|
| 671 |
// Validaciones básicas
|
| 672 |
if (age < 15 || age > 100 || weight < 40 || weight > 200 || height < 140 || height > 220) {
|
|
@@ -775,6 +813,9 @@
|
|
| 775 |
// Generar recomendaciones
|
| 776 |
generateRecommendations(goal, dailyCalories, proteinGrams, carbsGrams, fatGrams, waterIntake, useCustomMacros);
|
| 777 |
|
|
|
|
|
|
|
|
|
|
| 778 |
// Crear/actualizar gráfico
|
| 779 |
updateChart(proteinGrams, carbsGrams, fatGrams);
|
| 780 |
|
|
@@ -785,7 +826,135 @@
|
|
| 785 |
document.getElementById('results').scrollIntoView({ behavior: 'smooth' });
|
| 786 |
}
|
| 787 |
|
| 788 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 789 |
const recommendationsEl = document.getElementById('recommendations');
|
| 790 |
recommendationsEl.innerHTML = '';
|
| 791 |
|
|
@@ -805,7 +974,7 @@
|
|
| 805 |
|
| 806 |
addRecommendation(goalRecommendation);
|
| 807 |
|
| 808 |
-
if (
|
| 809 |
addRecommendation('Estás usando una distribución personalizada de macronutrientes 🎛️. Asegúrate de seguir tus porcentajes establecidos.');
|
| 810 |
} else {
|
| 811 |
// Recomendación basada en valores por defecto
|
|
@@ -813,20 +982,20 @@
|
|
| 813 |
}
|
| 814 |
|
| 815 |
// Recomendación de proteína
|
| 816 |
-
addRecommendation(`Consume aproximadamente ${
|
| 817 |
|
| 818 |
// Recomendación de carbohidratos
|
| 819 |
if (goal === 'loss') {
|
| 820 |
-
addRecommendation(`Prioriza carbohidratos complejos (${
|
| 821 |
} else {
|
| 822 |
-
addRecommendation(`Consume ${
|
| 823 |
}
|
| 824 |
|
| 825 |
// Recomendación de grasas
|
| 826 |
-
addRecommendation(`Incluye ${
|
| 827 |
|
| 828 |
// Recomendación de agua
|
| 829 |
-
addRecommendation(`Bebe al menos ${
|
| 830 |
|
| 831 |
// Recomendación de comidas
|
| 832 |
addRecommendation('Distribuye tus macronutrientes en 3-5 comidas al día 🍽️ para mejor digestión y absorción.');
|
|
|
|
| 96 |
font-weight: bold;
|
| 97 |
color: #4A00E0;
|
| 98 |
}
|
| 99 |
+
.meal-plan-card {
|
| 100 |
+
transition: all 0.3s ease;
|
| 101 |
+
border-left: 4px solid;
|
| 102 |
+
}
|
| 103 |
+
.meal-plan-card:hover {
|
| 104 |
+
transform: translateX(5px);
|
| 105 |
+
}
|
| 106 |
@keyframes pulse {
|
| 107 |
0% { transform: scale(1); }
|
| 108 |
50% { transform: scale(1.05); }
|
|
|
|
| 174 |
<label class="block text-gray-700 mb-2 flex items-center">
|
| 175 |
<span class="emoji-input">⚖️</span> Peso (kg)
|
| 176 |
</label>
|
| 177 |
+
<input type="number" id="weight" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="40" max="200, value="70">
|
| 178 |
</div>
|
| 179 |
|
| 180 |
<div>
|
|
|
|
| 299 |
</div>
|
| 300 |
</div>
|
| 301 |
|
| 302 |
+
<!-- Nueva sección para seleccionar número de comidas -->
|
| 303 |
+
<div class="mt-6">
|
| 304 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
|
| 305 |
+
<span class="emoji-input">🍽️</span> Plan de Comidas
|
| 306 |
+
</h3>
|
| 307 |
+
|
| 308 |
+
<div class="mb-4">
|
| 309 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 310 |
+
<span class="emoji-input">⏱️</span> Número de comidas al día
|
| 311 |
+
</label>
|
| 312 |
+
<select id="mealsPerDay" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent">
|
| 313 |
+
<option value="3">3 comidas (Desayuno, Almuerzo, Cena)</option>
|
| 314 |
+
<option value="4" selected>4 comidas (Desayuno, Almuerzo, Merienda, Cena)</option>
|
| 315 |
+
<option value="5">5 comidas (Desayuno, Media mañana, Almuerzo, Merienda, Cena)</option>
|
| 316 |
+
<option value="6">6 comidas (3 comidas principales + 3 snacks)</option>
|
| 317 |
+
</select>
|
| 318 |
+
</div>
|
| 319 |
+
</div>
|
| 320 |
+
|
| 321 |
<div class="mt-8">
|
| 322 |
<button id="calculateBtn" class="w-full gradient-bg text-white py-4 rounded-xl font-bold text-lg hover:opacity-90 transition duration-300 flex items-center justify-center pulse-animation">
|
| 323 |
<span class="emoji-input">✨</span> Calcular mis macronutrientes
|
|
|
|
| 413 |
</div>
|
| 414 |
</div>
|
| 415 |
|
| 416 |
+
<!-- Nueva sección de plan de comidas -->
|
| 417 |
+
<div class="mt-8 bg-gradient-to-br from-gray-50 to-gray-100 rounded-2xl p-6 border-2 border-gray-200">
|
| 418 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
|
| 419 |
+
<span class="emoji-input">🍽️</span> Plan de Comidas Diario
|
| 420 |
+
</h3>
|
| 421 |
+
|
| 422 |
+
<div id="mealPlanContainer" class="space-y-4">
|
| 423 |
+
<!-- El plan de comidas se generará aquí dinámicamente -->
|
| 424 |
+
</div>
|
| 425 |
+
</div>
|
| 426 |
+
|
| 427 |
<!-- Nueva sección de alimentos recomendados -->
|
| 428 |
<div class="mt-8 bg-gradient-to-br from-gray-50 to-gray-100 rounded-2xl p-6 border-2 border-gray-200">
|
| 429 |
<h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
|
|
|
|
| 704 |
const goal = document.getElementById('goal').value;
|
| 705 |
const bodyfat = parseInt(document.getElementById('bodyfat').value) || 20;
|
| 706 |
const useCustomMacros = document.getElementById('customMacrosToggle').checked;
|
| 707 |
+
const mealsPerDay = parseInt(document.getElementById('mealsPerDay').value);
|
| 708 |
|
| 709 |
// Validaciones básicas
|
| 710 |
if (age < 15 || age > 100 || weight < 40 || weight > 200 || height < 140 || height > 220) {
|
|
|
|
| 813 |
// Generar recomendaciones
|
| 814 |
generateRecommendations(goal, dailyCalories, proteinGrams, carbsGrams, fatGrams, waterIntake, useCustomMacros);
|
| 815 |
|
| 816 |
+
// Generar plan de comidas
|
| 817 |
+
generateMealPlan(mealsPerDay, dailyCalories, proteinGrams, carbsGrams, fatGrams);
|
| 818 |
+
|
| 819 |
// Crear/actualizar gráfico
|
| 820 |
updateChart(proteinGrams, carbsGrams, fatGrams);
|
| 821 |
|
|
|
|
| 826 |
document.getElementById('results').scrollIntoView({ behavior: 'smooth' });
|
| 827 |
}
|
| 828 |
|
| 829 |
+
function generateMealPlan(mealsPerDay, calories, protein, carbs, fat) {
|
| 830 |
+
const mealPlanContainer = document.getElementById('mealPlanContainer');
|
| 831 |
+
mealPlanContainer.innerHTML = '';
|
| 832 |
+
|
| 833 |
+
// Calcular macros por comida
|
| 834 |
+
const proteinPerMeal = Math.round(protein / mealsPerDay);
|
| 835 |
+
const carbsPerMeal = Math.round(carbs / mealsPerDay);
|
| 836 |
+
const fatPerMeal = Math.round(fat / mealsPerDay);
|
| 837 |
+
const caloriesPerMeal = Math.round(calories / mealsPerDay);
|
| 838 |
+
|
| 839 |
+
// Definir nombres de comidas según cantidad
|
| 840 |
+
const mealNames = {
|
| 841 |
+
3: ['Desayuno', 'Almuerzo', 'Cena'],
|
| 842 |
+
4: ['Desayuno', 'Almuerzo', 'Merienda', 'Cena'],
|
| 843 |
+
5: ['Desayuno', 'Media mañana', 'Almuerzo', 'Merienda', 'Cena'],
|
| 844 |
+
6: ['Desayuno', 'Snack mañana', 'Almuerzo', 'Merienda', 'Cena', 'Snack noche']
|
| 845 |
+
};
|
| 846 |
+
|
| 847 |
+
// Generar cada comida
|
| 848 |
+
for (let i = 0; i < mealsPerDay; i++) {
|
| 849 |
+
const mealName = mealNames[mealsPerDay][i];
|
| 850 |
+
const mealType = getMealType(i, mealsPerDay);
|
| 851 |
+
|
| 852 |
+
const mealCard = document.createElement('div');
|
| 853 |
+
mealCard.className = `meal-plan-card bg-white p-4 rounded-lg shadow-sm border-l-4 ${getMealColorClass(mealType)}`;
|
| 854 |
+
|
| 855 |
+
// Sugerir alimentos según el tipo de comida
|
| 856 |
+
const foodSuggestions = getFoodSuggestions(mealType, proteinPerMeal, carbsPerMeal, fatPerMeal);
|
| 857 |
+
|
| 858 |
+
mealCard.innerHTML = `
|
| 859 |
+
<div class="flex justify-between items-start mb-2">
|
| 860 |
+
<h4 class="text-lg font-semibold text-gray-800 flex items-center">
|
| 861 |
+
<span class="emoji-input">${getMealEmoji(mealType)}</span> ${mealName}
|
| 862 |
+
</h4>
|
| 863 |
+
<span class="text-sm font-medium text-gray-500">${caloriesPerMeal} kcal</span>
|
| 864 |
+
</div>
|
| 865 |
+
<div class="grid grid-cols-3 gap-2 text-sm mb-3">
|
| 866 |
+
<div class="bg-blue-50 text-blue-700 px-2 py-1 rounded text-center">
|
| 867 |
+
<span class="font-medium">${proteinPerMeal}g</span> proteína
|
| 868 |
+
</div>
|
| 869 |
+
<div class="bg-yellow-50 text-yellow-700 px-2 py-1 rounded text-center">
|
| 870 |
+
<span class="font-medium">${carbsPerMeal}g</span> carbos
|
| 871 |
+
</div>
|
| 872 |
+
<div class="bg-red-50 text-red-700 px-2 py-1 rounded text-center">
|
| 873 |
+
<span class="font-medium">${fatPerMeal}g</span> grasas
|
| 874 |
+
</div>
|
| 875 |
+
</div>
|
| 876 |
+
<div class="text-sm text-gray-700">
|
| 877 |
+
<p class="font-medium mb-1">Sugerencias:</p>
|
| 878 |
+
<ul class="list-disc list-inside space-y-1">
|
| 879 |
+
${foodSuggestions.map(item => `<li>${item}</li>`).join('')}
|
| 880 |
+
</ul>
|
| 881 |
+
</div>
|
| 882 |
+
`;
|
| 883 |
+
|
| 884 |
+
mealPlanContainer.appendChild(mealCard);
|
| 885 |
+
}
|
| 886 |
+
}
|
| 887 |
+
|
| 888 |
+
function getMealType(mealIndex, totalMeals) {
|
| 889 |
+
if (totalMeals === 3) {
|
| 890 |
+
return mealIndex === 0 ? 'breakfast' : mealIndex === 1 ? 'lunch' : 'dinner';
|
| 891 |
+
} else if (totalMeals === 4) {
|
| 892 |
+
return mealIndex === 0 ? 'breakfast' : mealIndex === 1 ? 'lunch' : mealIndex === 2 ? 'snack' : 'dinner';
|
| 893 |
+
} else if (totalMeals === 5) {
|
| 894 |
+
return mealIndex === 0 ? 'breakfast' : mealIndex === 1 ? 'snack' : mealIndex === 2 ? 'lunch' : mealIndex === 3 ? 'snack' : 'dinner';
|
| 895 |
+
} else {
|
| 896 |
+
return mealIndex === 0 ? 'breakfast' : mealIndex % 2 === 1 ? 'snack' : mealIndex === 2 ? 'lunch' : 'dinner';
|
| 897 |
+
}
|
| 898 |
+
}
|
| 899 |
+
|
| 900 |
+
function getMealColorClass(mealType) {
|
| 901 |
+
switch(mealType) {
|
| 902 |
+
case 'breakfast': return 'border-blue-400 bg-blue-50';
|
| 903 |
+
case 'lunch': return 'border-green-400 bg-green-50';
|
| 904 |
+
case 'dinner': return 'border-purple-400 bg-purple-50';
|
| 905 |
+
case 'snack': return 'border-yellow-400 bg-yellow-50';
|
| 906 |
+
default: return 'border-gray-400 bg-gray-50';
|
| 907 |
+
}
|
| 908 |
+
}
|
| 909 |
+
|
| 910 |
+
function getMealEmoji(mealType) {
|
| 911 |
+
switch(mealType) {
|
| 912 |
+
case 'breakfast': return '🥣';
|
| 913 |
+
case 'lunch': return '🍲';
|
| 914 |
+
case 'dinner': return '🍽️';
|
| 915 |
+
case 'snack': return '🍎';
|
| 916 |
+
default: return '🍴';
|
| 917 |
+
}
|
| 918 |
+
}
|
| 919 |
+
|
| 920 |
+
function getFoodSuggestions(mealType, protein, carbs, fat) {
|
| 921 |
+
const suggestions = [];
|
| 922 |
+
|
| 923 |
+
// Proteínas
|
| 924 |
+
if (mealType === 'breakfast') {
|
| 925 |
+
suggestions.push(`Huevos (${Math.min(3, Math.round(protein/6))} unidades)`);
|
| 926 |
+
suggestions.push(`Requesón (${Math.round(protein/12*100)}g)`);
|
| 927 |
+
} else if (mealType === 'lunch' || mealType === 'dinner') {
|
| 928 |
+
suggestions.push(`Pollo (${Math.round(protein/30*100)}g)`);
|
| 929 |
+
suggestions.push(`Pescado (${Math.round(protein/25*100)}g)`);
|
| 930 |
+
} else {
|
| 931 |
+
suggestions.push(`Yogur griego (${Math.round(protein/10*100)}g)`);
|
| 932 |
+
}
|
| 933 |
+
|
| 934 |
+
// Carbohidratos
|
| 935 |
+
if (mealType === 'breakfast') {
|
| 936 |
+
suggestions.push(`Avena (${Math.round(carbs/66*100)}g)`);
|
| 937 |
+
suggestions.push(`Pan integral (${Math.round(carbs/50*100)}g)`);
|
| 938 |
+
} else if (mealType === 'lunch' || mealType === 'dinner') {
|
| 939 |
+
suggestions.push(`Arroz integral (${Math.round(carbs/28*100)}g)`);
|
| 940 |
+
suggestions.push(`Quinoa (${Math.round(carbs/21*100)}g)`);
|
| 941 |
+
} else {
|
| 942 |
+
suggestions.push(`Fruta (${Math.round(carbs/20*100)}g)`);
|
| 943 |
+
}
|
| 944 |
+
|
| 945 |
+
// Grasas
|
| 946 |
+
if (mealType === 'breakfast') {
|
| 947 |
+
suggestions.push(`Aguacate (${Math.round(fat/15*100)}g)`);
|
| 948 |
+
} else if (mealType === 'lunch' || mealType === 'dinner') {
|
| 949 |
+
suggestions.push(`Aceite de oliva (${Math.round(fat/100*10)}ml)`);
|
| 950 |
+
} else {
|
| 951 |
+
suggestions.push(`Frutos secos (${Math.round(fat/50*30)}g)`);
|
| 952 |
+
}
|
| 953 |
+
|
| 954 |
+
return suggestions;
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
function generateRecommendations(goal, dailyCalories, proteinGrams, carbsGrams, fatGrams, waterIntake, useCustomMacros) {
|
| 958 |
const recommendationsEl = document.getElementById('recommendations');
|
| 959 |
recommendationsEl.innerHTML = '';
|
| 960 |
|
|
|
|
| 974 |
|
| 975 |
addRecommendation(goalRecommendation);
|
| 976 |
|
| 977 |
+
if (useCustomMacros) {
|
| 978 |
addRecommendation('Estás usando una distribución personalizada de macronutrientes 🎛️. Asegúrate de seguir tus porcentajes establecidos.');
|
| 979 |
} else {
|
| 980 |
// Recomendación basada en valores por defecto
|
|
|
|
| 982 |
}
|
| 983 |
|
| 984 |
// Recomendación de proteína
|
| 985 |
+
addRecommendation(`Consume aproximadamente ${proteinGrams}g de proteína diarios 🍗. Buenas fuentes incluyen carnes magras, pescado 🐟, huevos 🥚 y lácteos 🧀.`);
|
| 986 |
|
| 987 |
// Recomendación de carbohidratos
|
| 988 |
if (goal === 'loss') {
|
| 989 |
+
addRecommendation(`Prioriza carbohidratos complejos (${carbsGrams}g/día) como vegetales 🥦, granos enteros 🌾 y legumbres para energía sostenida ⚡.`);
|
| 990 |
} else {
|
| 991 |
+
addRecommendation(`Consume ${carbsGrams}g de carbohidratos diarios 🍞, priorizando fuentes complejas como arroz integral 🍚, quinoa y avena 🥣.`);
|
| 992 |
}
|
| 993 |
|
| 994 |
// Recomendación de grasas
|
| 995 |
+
addRecommendation(`Incluye ${fatGrams}g de grasas saludables diarias 🥑 de fuentes como aguacate, frutos secos 🥜, aceite de oliva y pescados grasos 🐠.`);
|
| 996 |
|
| 997 |
// Recomendación de agua
|
| 998 |
+
addRecommendation(`Bebe al menos ${waterIntake} litros de agua al día 💧 para mantener una hidratación óptima.`);
|
| 999 |
|
| 1000 |
// Recomendación de comidas
|
| 1001 |
addRecommendation('Distribuye tus macronutrientes en 3-5 comidas al día 🍽️ para mejor digestión y absorción.');
|