Spaces:
Running
Running
File size: 11,386 Bytes
cb6e833 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculadora de Tabuada</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* Efeito de onda animado no background */
body::before {
content: "";
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg, #3b82f6, #8b5cf6, #ec4899);
background-size: 400% 400%;
animation: gradientBG 15s ease infinite;
z-index: -1;
opacity: 0.9;
}
@keyframes gradientBG {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
/* Animação de entrada para os resultados */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.result-item {
animation: fadeIn 0.3s ease-out forwards;
animation-delay: calc(var(--order) * 0.05s);
}
/* Efeito de hover nos botões */
.btn-hover {
transition: all 0.3s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.btn-hover:hover {
transform: translateY(-2px);
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
.btn-hover:active {
transform: translateY(0);
}
</style>
</head>
<body class="min-h-screen flex items-center justify-center p-4">
<div class="w-full max-w-md bg-white rounded-xl shadow-2xl overflow-hidden">
<!-- Cabeçalho -->
<div class="bg-gradient-to-r from-blue-500 to-purple-600 p-6 text-white">
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold">
<i class="fas fa-calculator mr-2"></i> Tabuada Mágica
</h1>
<button id="info-btn" class="text-white hover:text-blue-200 transition">
<i class="fas fa-info-circle text-xl"></i>
</button>
</div>
<p class="text-sm opacity-90 mt-1">Calcule a tabuada de qualquer número</p>
</div>
<!-- Corpo do aplicativo -->
<div class="p-6">
<div class="mb-6">
<label for="number" class="block text-sm font-medium text-gray-700 mb-1">
<i class="fas fa-hashtag mr-1 text-blue-500"></i> Digite um número:
</label>
<div class="flex">
<input
type="number"
id="number"
min="1"
class="flex-1 rounded-l-lg border border-gray-300 px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Ex: 7"
>
<button
id="calculate-btn"
class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-r-lg btn-hover transition"
>
<i class="fas fa-play mr-1"></i> Calcular
</button>
</div>
</div>
<div class="mb-4">
<label for="range" class="block text-sm font-medium text-gray-700 mb-1">
<i class="fas fa-sliders-h mr-1 text-purple-500"></i> Quantidade de multiplicações:
</label>
<div class="flex items-center">
<input
type="range"
id="range"
min="1"
max="20"
value="10"
class="flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer"
>
<span id="range-value" class="ml-3 text-gray-700 font-medium w-8 text-center">10</span>
</div>
</div>
<!-- Resultados -->
<div id="results" class="mt-8 space-y-2 hidden">
<h3 class="text-lg font-semibold text-gray-800 border-b pb-2 flex items-center">
<i class="fas fa-list-ol mr-2 text-green-500"></i> Resultados
</h3>
<div id="results-container" class="grid grid-cols-2 sm:grid-cols-3 gap-3"></div>
</div>
</div>
<!-- Rodapé -->
<div class="bg-gray-50 px-6 py-3 text-center text-sm text-gray-600">
<p>Pressione Enter para calcular</p>
</div>
</div>
<!-- Modal de informações -->
<div id="info-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
<div class="bg-white rounded-lg max-w-md w-full mx-4 p-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-gray-800">
<i class="fas fa-info-circle text-blue-500 mr-2"></i> Sobre o App
</h3>
<button id="close-modal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-3 text-gray-700">
<p>Este aplicativo calcula a tabuada de qualquer número inteiro positivo.</p>
<p><span class="font-semibold">Como usar:</span></p>
<ol class="list-decimal pl-5 space-y-1">
<li>Digite um número no campo</li>
<li>Ajuste quantas multiplicações deseja ver</li>
<li>Clique em "Calcular" ou pressione Enter</li>
</ol>
<p class="pt-2">Você pode ver a tabuada de 1 até 20 multiplicações.</p>
</div>
<div class="mt-6 flex justify-center">
<button id="close-modal-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg btn-hover transition">
<i class="fas fa-check mr-1"></i> Entendi
</button>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Elementos do DOM
const numberInput = document.getElementById('number');
const calculateBtn = document.getElementById('calculate-btn');
const rangeInput = document.getElementById('range');
const rangeValue = document.getElementById('range-value');
const resultsContainer = document.getElementById('results-container');
const resultsSection = document.getElementById('results');
const infoBtn = document.getElementById('info-btn');
const infoModal = document.getElementById('info-modal');
const closeModal = document.getElementById('close-modal');
const closeModalBtn = document.getElementById('close-modal-btn');
// Atualizar valor do range
rangeInput.addEventListener('input', function() {
rangeValue.textContent = this.value;
});
// Calcular tabuada
function calculateTimesTable() {
const number = parseInt(numberInput.value);
const range = parseInt(rangeInput.value);
if (isNaN(number) || number <= 0) {
alert('Por favor, digite um número válido maior que zero.');
return;
}
// Limpar resultados anteriores
resultsContainer.innerHTML = '';
// Gerar e exibir resultados
for (let i = 1; i <= range; i++) {
const result = number * i;
const resultItem = document.createElement('div');
resultItem.className = 'bg-gray-50 p-3 rounded-lg border border-gray-200 result-item';
resultItem.style.setProperty('--order', i);
resultItem.innerHTML = `
<div class="flex items-center">
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded-full mr-2">${i}</span>
<span class="text-gray-700">${number} × ${i} =</span>
<span class="ml-auto font-bold text-blue-600">${result}</span>
</div>
`;
resultsContainer.appendChild(resultItem);
}
// Mostrar seção de resultados
resultsSection.classList.remove('hidden');
// Rolagem suave para os resultados
setTimeout(() => {
resultsSection.scrollIntoView({ behavior: 'smooth' });
}, 300);
}
// Event listeners
calculateBtn.addEventListener('click', calculateTimesTable);
numberInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
calculateTimesTable();
}
});
// Modal de informações
infoBtn.addEventListener('click', function() {
infoModal.classList.remove('hidden');
document.body.style.overflow = 'hidden';
});
const closeModalFunc = function() {
infoModal.classList.add('hidden');
document.body.style.overflow = '';
};
closeModal.addEventListener('click', closeModalFunc);
closeModalBtn.addEventListener('click', closeModalFunc);
// Fechar modal ao clicar fora
infoModal.addEventListener('click', function(e) {
if (e.target === infoModal) {
closeModalFunc();
}
});
// Efeito de foco no input ao carregar
setTimeout(() => {
numberInput.focus();
}, 500);
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=adrianoL/tabuada-m-gica" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |