tabuada-m-gica / index.html
adrianoL's picture
Add 2 files
cb6e833 verified
<!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>