Es. 8+ fixes

This commit is contained in:
2026-02-07 16:17:53 +01:00
parent 6b4c232725
commit f3f5a46598
8 changed files with 343 additions and 188 deletions

View File

@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestione Utenti</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<a href="../index.html" style="position: absolute; top: 20px; left: 20px; text-decoration: none; color: #555; font-weight: bold; font-size: 14px;">← Dashboard</a>
<div class="container">
<form id="profile-form" class="profile-form">
<h1>Aggiungi un Utente</h1>
<div class="form-group">
<label for="nome">Nome Completo:</label>
<input type="text" id="nome" placeholder="Es. Marco Rossi" required>
</div>
<div class="form-group">
<label for="eta">Età:</label>
<input type="number" id="eta" placeholder="Es. 25" min="1" max="120" required>
</div>
<div class="form-group">
<label for="professione">Professione:</label>
<input type="text" id="professione" placeholder="Es. Sviluppatore" required>
</div>
<button type="button" id="btn-crea-card" class="btn-primary">+ Aggiungi Utente</button>
</form>
<div class="table-wrapper">
<h2>Utenti Registrati</h2>
<table id="users-table" class="users-table">
<thead>
<tr>
<th>Nome</th>
<th>Età</th>
<th>Professione</th>
<th>Azioni</th>
</tr>
</thead>
<tbody id="tbody">
<!-- Le righe verranno inserite qui -->
</tbody>
</table>
</div>
</div>
<script src="script.js"></script>
</body>
</html>

View File

@@ -0,0 +1,58 @@
/**
* ESERCIZIO 2: Tabella Utenti Interattiva
* Selezionare gli elementi principali dal DOM
*/
const inputNome = document.querySelector('');
const inputEta = document.querySelector('');
const inputProfessione = document.querySelector('');
const btnCreaUtente = document.querySelector('');
const tbodyUtenti = document.querySelector('');
/**
* EVENTO: Clic sul pulsante "Aggiungi Utente"
*
* Completa la funzione: Manca qualcosa?
*
* Passi:
* 1. Prevenire il comportamento di default del form
* 2. Leggere i valori dagli input
* 3. Se i dati non sono vuoti:
* - Chiamare creaRigaUtente(nome, eta, professione), passando i dati letti dagli input
* - Chiamare cancellaDatiInput() per pulire i campi
*/
btnCreaUtente.addEventListener('click', (e) => {
e.preventDefault();
const nome = inputNome.value;
const eta = inputEta.value;
const professione = inputProfessione.value;
creaRigaUtente(nome, eta, professione);
cancellaDatiInput();
});
/**
* FUNZIONE: Crea una riga della tabella con i dati dell'utente
*
* Passi:
* 1. Creare un elemento <tr> (classe "user-row")
* 2. Creare tre elementi <td> per nome, età e professione
* 3. Popolare i <td> con i dati passati dai parametri
* 4. Aggiungere tutti i <td> al <tr>
* 5. Aggiungere il <tr> nel <tbody> della tabella
*/
function creaRigaUtente(nome, eta, professione) {
}
/**
* FUNZIONE: Cancella i dati dagli input e rimette il focus sul primo campo
*
* Passi:
* 1. Impostare il valore di inputNome a stringa vuota
* 2. Impostare il valore di inputEta a stringa vuota
* 3. Impostare il valore di inputProfessione a stringa vuota
*/
function cancellaDatiInput() {
}

View File

@@ -0,0 +1,223 @@
* {
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
margin: 0;
padding: 20px;
color: #2c3e50;
}
.container {
max-width: 700px;
margin: 0 auto;
background: white;
border-radius: 12px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
padding: 30px;
}
/* ═══════════════════════════════════════════════════════════════ */
/* FORM STYLES */
/* ═══════════════════════════════════════════════════════════════ */
.profile-form {
margin-bottom: 40px;
padding-bottom: 30px;
border-bottom: 2px solid #ecf0f1;
}
.profile-form h1 {
color: #2c3e50;
margin-top: 0;
margin-bottom: 25px;
font-size: 1.8rem;
}
.form-group {
margin-bottom: 18px;
display: flex;
flex-direction: column;
}
.form-group label {
font-weight: 600;
margin-bottom: 8px;
color: #34495e;
font-size: 0.95rem;
}
.form-group input,
.form-group textarea {
padding: 12px 15px;
border: 2px solid #ecf0f1;
border-radius: 6px;
font-family: inherit;
font-size: 1rem;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.form-group input:focus,
.form-group textarea:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
.form-group textarea {
resize: vertical;
min-height: 80px;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 14px 32px;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
font-size: 1rem;
transition: transform 0.2s ease, box-shadow 0.2s ease;
align-self: flex-start;
margin-top: 10px;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}
.btn-primary:active {
transform: translateY(0);
}
/* ═══════════════════════════════════════════════════════════════ */
/* TABLE STYLES */
/* ═══════════════════════════════════════════════════════════════ */
.table-wrapper h2 {
color: #2c3e50;
margin: 0 0 20px 0;
font-size: 1.4rem;
}
.empty-message {
text-align: center;
color: #7f8c8d;
font-style: italic;
padding: 30px;
background: #f8f9fa;
border-radius: 8px;
border-left: 4px solid #3498db;
}
.empty-message.hidden {
display: none;
}
.users-table {
width: 100%;
border-collapse: collapse;
margin: 0;
}
.users-table thead {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.users-table thead th {
padding: 16px;
text-align: left;
font-weight: 600;
letter-spacing: 0.5px;
font-size: 0.95rem;
}
.users-table tbody tr {
border-bottom: 1px solid #ecf0f1;
transition: background-color 0.2s ease, transform 0.2s ease;
animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.users-table tbody tr:hover {
background-color: #f8f9fa;
}
.users-table tbody td {
padding: 16px;
color: #34495e;
word-break: break-word;
max-width: 200px;
}
.users-table tbody td:first-child {
font-weight: 600;
color: #2c3e50;
}
.users-table tbody td.azioni {
text-align: center;
width: 120px;
}
/* ═══════════════════════════════════════════════════════════════ */
/* BUTTON STYLES */
/* ═══════════════════════════════════════════════════════════════ */
.btn-elimina {
background: #e74c3c;
color: white;
border: none;
padding: 8px 14px;
border-radius: 6px;
cursor: pointer;
font-weight: 600;
font-size: 0.85rem;
transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-elimina:hover {
background: #c0392b;
transform: scale(1.1);
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}
.btn-elimina:active {
transform: scale(0.95);
}
/* ═══════════════════════════════════════════════════════════════ */
/* RESPONSIVE */
/* ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
.container {
padding: 20px;
}
.users-table tbody th,
.users-table tbody td {
padding: 12px 8px;
font-size: 0.9rem;
}
.profile-form {
width: 100%;
}
}