-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7da09a1
Showing
5 changed files
with
310 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="es"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;400;700;900&family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet"> | ||
<title>Amigo Secreto</title> | ||
</head> | ||
<body> | ||
<main class="main-content"> | ||
<header class="header-banner"> | ||
<h1 class="main-title">Amigo Secreto</h1> | ||
<img src="assets/imamigo.jpg" alt="Imagen representativa de amigo secreto"> | ||
</header> | ||
|
||
<section class="input-section"> | ||
<h2 class="section-title">Digite el nombre de sus amigos</h2> | ||
<div class="input-wrapper"> | ||
<input type="text" id="amigo" class="input-name" placeholder="Escribe un nombre" aria-label="Escribe un nombre"> | ||
<button class="button-add" onclick="agregarAmigo()" aria-label="Añadir nombre">Añadir</button> | ||
</div> | ||
|
||
<ul id="listaAmigos" class="name-list" aria-labelledby="listaAmigos" role="list"></ul> | ||
<ul id="resultado" class="result-list" aria-live="polite"></ul> | ||
|
||
<div class="button-container"> | ||
<button class="button-draw" onclick="sortearAmigo()" aria-label="Sortear amigo secreto"> | ||
<img src="assets/imagenamig.jpg" alt="Ícono para sortear"> | ||
Sortear amigo | ||
</button> | ||
<button class="button-reset" onclick="reiniciarSorteo()" aria-label="Reiniciar sorteo">Reiniciar</button> | ||
</div> | ||
</section> | ||
</main> | ||
|
||
<script src="script.js" defer></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Array para almacenar los nombres de los amigos | ||
let amigos = []; | ||
|
||
// Función para agregar un amigo a la lista | ||
function agregarAmigo() { | ||
const inputAmigo = document.getElementById('amigo'); | ||
const nombreAmigo = inputAmigo.value.trim(); // Elimina espacios al inicio y final | ||
|
||
// Validación: Asegurarse de que el nombre no esté vacío | ||
if (nombreAmigo === '') { | ||
alert('Por favor, ingresa un nombre válido.'); | ||
return; // Detener la ejecución si el nombre está vacío | ||
} | ||
|
||
// Validación: Evitar nombres duplicados | ||
if (amigos.includes(nombreAmigo)) { | ||
alert('Este nombre ya ha sido agregado.'); | ||
return; // Detener la ejecución si el nombre ya existe | ||
} | ||
|
||
// Agregar el nombre al array y limpiar el campo de texto | ||
amigos.push(nombreAmigo); | ||
inputAmigo.value = ''; // Limpiar el campo de texto | ||
actualizarListaAmigos(); // Actualizar la lista en la interfaz | ||
} | ||
|
||
// Función para actualizar la lista de amigos en la interfaz | ||
function actualizarListaAmigos() { | ||
const listaAmigos = document.getElementById('listaAmigos'); | ||
listaAmigos.innerHTML = ''; // Limpiar la lista antes de actualizar | ||
|
||
// Recorrer el array de amigos y agregar cada uno a la lista | ||
amigos.forEach((amigo, index) => { | ||
const li = document.createElement('li'); | ||
li.textContent = `${index + 1}. ${amigo}`; | ||
listaAmigos.appendChild(li); | ||
}); | ||
} | ||
|
||
// Función para sortear un amigo secreto | ||
function sortearAmigo() { | ||
if (amigos.length < 2) { | ||
alert('Necesitas al menos 2 amigos para realizar el sorteo.'); | ||
return; | ||
} | ||
|
||
const resultado = document.getElementById('resultado'); | ||
resultado.innerHTML = ''; // Limpiar el resultado anterior | ||
|
||
// Crear una copia del array de amigos para no modificar el original | ||
let amigosTemp = [...amigos]; | ||
|
||
// Seleccionar un amigo al azar | ||
const amigoSecreto = amigos[Math.floor(Math.random() * amigos.length)]; | ||
const li = document.createElement('li'); | ||
li.textContent = `¡El amigo secreto es: ${amigoSecreto}!`; | ||
resultado.appendChild(li); | ||
} | ||
|
||
|
||
|
||
// Función para reiniciar el sorteo | ||
function reiniciarSorteo() { | ||
amigos = []; | ||
document.getElementById('listaAmigos').innerHTML = ''; | ||
document.getElementById('resultado').innerHTML = ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
:root { | ||
--color-primary: #80C4E9; | ||
--color-secondary: #FFF9EB; | ||
--color-tertiary: #C4C4C4; | ||
--color-button: #C4D9FF; | ||
--color-button-hover: #C5BAFF; | ||
--color-text: #27445D; | ||
--color-blue: #4635B1; | ||
} | ||
|
||
/* Estilos generales */ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
height: 100vh; | ||
background-color: var(--color-primary); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-family: "Inter", sans-serif; | ||
} | ||
|
||
.main-content { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
width: 100%; | ||
max-width: 1200px; | ||
margin: 0 auto; | ||
} | ||
|
||
/* Banner */ | ||
.header-banner { | ||
flex: 40%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 40px 0 0; | ||
} | ||
|
||
.header-banner img { | ||
max-width: 200px; | ||
height: auto; | ||
margin-left: 40px; | ||
} | ||
|
||
/* Sección de entrada */ | ||
.input-section { | ||
flex: 60%; | ||
background-color: var(--color-secondary); | ||
border: 1px solid #000; | ||
border-radius: 64px 64px 0 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
padding: 20px; | ||
width: 100%; | ||
} | ||
|
||
/* Títulos */ | ||
.main-title { | ||
font-size: 48px; | ||
font-family: "Merriweather", serif; | ||
font-weight: 900; | ||
font-style: italic; | ||
color: var(--color-blue); | ||
text-align: center; | ||
} | ||
|
||
.section-title { | ||
font-family: "Inter", serif; | ||
font-size: 36px; | ||
font-weight: 700; | ||
color: var(--color-primary); | ||
margin: 10px 0; | ||
text-align: center; | ||
} | ||
|
||
/* Contenedores de entrada y botón */ | ||
.input-wrapper { | ||
display: flex; | ||
justify-content: center; | ||
width: 100%; | ||
max-width: 600px; | ||
margin-top: 20px; | ||
} | ||
|
||
.input-name { | ||
width: 100%; | ||
padding: 10px; | ||
border: 2px solid #000; | ||
border-radius: 25px 0 0 25px; | ||
font-size: 16px; | ||
font-family: "Inter", sans-serif; | ||
} | ||
|
||
.button-container { | ||
width: 300px; | ||
justify-content: center; | ||
display: flex; | ||
gap: 10px; | ||
} | ||
|
||
/* Estilos de botón */ | ||
button { | ||
padding: 15px 30px; | ||
font-family: "Inter", sans-serif; | ||
font-size: 16px; | ||
border: 2px solid #000; | ||
border-radius: 25px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
.button-add { | ||
background-color: var(--color-tertiary); | ||
color: var(--color-text); | ||
border-radius: 0 25px 25px 0; | ||
} | ||
|
||
.button-add:hover { | ||
background-color: #a1a1a1; | ||
} | ||
|
||
.button-reset { | ||
background-color: var(--color-button); | ||
color: --color-blue; | ||
} | ||
|
||
.button-reset:hover { | ||
background-color: var(--color-button-hover); | ||
} | ||
|
||
/* Listas */ | ||
ul { | ||
list-style-type: none; | ||
color: var(--color-text); | ||
font-family: "Inter", sans-serif; | ||
font-size: 18px; | ||
margin: 20px 0; | ||
padding: 0; | ||
} | ||
|
||
.result-list li { | ||
background-color: var(--color-button); | ||
padding: 10px; | ||
margin: 5px 0; | ||
border-radius: 10px; | ||
text-align: center; | ||
font-size: 20px; | ||
color: var(--color-text); | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
/* Botón de sortear título */ | ||
.button-draw { | ||
display: flex; | ||
align-items: center; | ||
width: auto; | ||
padding: 10px 40px; | ||
color: var(--color-white); | ||
background-color: var(--color-button); | ||
font-size: 16px; | ||
} | ||
|
||
.button-draw img { | ||
max-width: 100px; | ||
height: auto; | ||
} | ||
|
||
.button-draw:hover { | ||
background-color: var(--color-button-hover); | ||
} | ||
|
||
/* Responsividad */ | ||
@media (max-width: 768px) { | ||
.main-title { | ||
font-size: 36px; | ||
} | ||
|
||
.section-title { | ||
font-size: 24px; | ||
} | ||
|
||
.input-name { | ||
font-size: 14px; | ||
} | ||
|
||
button { | ||
padding: 10px 20px; | ||
font-size: 14px; | ||
} | ||
|
||
.button-draw { | ||
padding: 8px 20px; | ||
} | ||
} |