Spostamento in cartella src per migliore organizzazione

This commit is contained in:
2026-04-08 11:42:41 +02:00
parent f7a951cea7
commit 9bec64e811
16 changed files with 0 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
function addToCart(productId, productName, price) {
// Leggi il carrello dal cookie
let cart = [];
const cookieValue = document.cookie.split('; ').find(row => row.startsWith('cart='));
if (cookieValue) {
cart = JSON.parse(decodeURIComponent(cookieValue.split('=')[1]));
}
// Controlla se il prodotto è già nel carrello
const existingItem = cart.find(item => item.id === productId);
if (existingItem) {
existingItem.quantity += 1;
} else {
cart.push({
id: productId,
name: productName,
price: price,
quantity: 1
});
}
// Salva il carrello nel cookie (scadenza 7 giorni)
const date = new Date();
date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = "cart=" + encodeURIComponent(JSON.stringify(cart)) + "; " + expires + "; path=/";
alert('Prodotto aggiunto al carrello!');
}
function removeFromCart(index) {
let cart = [];
const cookieValue = document.cookie.split('; ').find(row => row.startsWith('cart='));
if (cookieValue) {
cart = JSON.parse(decodeURIComponent(cookieValue.split('=')[1]));
}
cart.splice(index, 1);
const date = new Date();
date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
if (cart.length > 0) {
document.cookie = "cart=" + encodeURIComponent(JSON.stringify(cart)) + "; " + expires + "; path=/";
} else {
document.cookie = "cart=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
}
location.reload();
}
function clearCart() {
if (confirm('Sei sicuro di voler svuotare il carrello?')) {
document.cookie = "cart=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
location.reload();
}
}
+322
View File
@@ -0,0 +1,322 @@
body{
font-family: Arial, Helvetica, sans-serif;
}
.products-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
padding: 20px;
}
.product-card {
border: 1px solid #ddd;
border-radius: 8px;
padding: 16px;
text-align: center;
background-color: #fff;
}
.product-card img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
.product-card h3 {
margin: 10px 0;
font-size: 18px;
}
.product-card p {
margin: 5px 0;
color: #666;
}
.product-card button {
padding: 8px 16px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin-top: 10px;
}
.product-card button:hover {
background-color: #0056b3;
}
/* Stili per il form di login */
form {
max-width: 400px;
margin: 50px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #f9f9f9;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
form h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
form label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
form input[type="text"],
form input[type="password"],
form input[type="email"] {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
form button {
width: 100%;
padding: 10px;
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
form button:hover {
background-color: #218838;
}
/* Stili per la pagina prodotto */
.product-detail {
max-width: 800px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fff;
display: flex;
flex-direction: column;
}
.product-detail img {
max-width: 100%;
height: auto;
object-fit: contain;
margin-bottom: 20px;
flex-shrink: 0;
}
.product-detail > div {
flex: 1;
}
@media (min-width: 768px) {
.product-detail {
flex-direction: row;
}
.product-detail img {
max-width: 40%;
margin-bottom: 0;
margin-right: 20px;
}
}
.img-square {
position: relative;
width: 100%;
padding-top: 100%; /* crea un quadrato perfetto */
overflow: hidden;
}
.img-square img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain; /* o "cover" */
}
/* Pagina carrello */
.cart-container {
max-width: 900px;
margin: 20px auto;
padding: 20px;
}
.cart-table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.cart-table th, .cart-table td {
border: 1px solid #ddd;
padding: 12px;
text-align: left;
}
.cart-table th {
background-color: #f2f2f2;
font-weight: bold;
}
.cart-table button {
padding: 5px 10px;
background-color: #dc3545;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.cart-table button:hover {
background-color: #c82333;
}
.cart-summary {
margin-top: 20px;
text-align: right;
font-size: 18px;
font-weight: bold;
}
.empty-cart {
text-align: center;
padding: 40px;
font-size: 18px;
color: #666;
}
.clear-cart-btn {
padding: 10px 20px;
background-color: #dc3545;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin-top: 20px;
}
.clear-cart-btn:hover {
background-color: #c82333;
}
.checkout-btn {
padding: 10px 20px;
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.checkout-btn:hover {
background-color: #218838;
}
/* Layout pagina account */
.account-layout {
display: flex;
flex-wrap: wrap;
gap: 20px;
max-width: 1100px;
margin: 20px auto;
padding: 0 20px;
box-sizing: border-box;
}
.my-sidebar {
flex: 0 0 240px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fff;
padding: 20px;
}
.my-sidebar ul {
list-style: none;
margin: 0;
padding: 0;
}
.my-sidebar li {
margin-bottom: 12px;
}
.my-sidebar a {
color: #007bff;
text-decoration: none;
}
.my-sidebar a:hover {
text-decoration: underline;
}
.my-container {
flex: 1 1 580px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fff;
padding: 20px;
}
@media (max-width: 768px) {
.account-layout {
flex-direction: column;
}
.my-sidebar,
.my-container {
flex: 1 1 100%;
}
}
/* Stili per la pagina ordini */
.orders-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.order-card {
border: 1px solid #ddd;
border-radius: 8px;
padding: 20px;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.order-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.order-header h3 {
margin: 0;
color: #333;
}
.order-status {
padding: 5px 10px;
border-radius: 4px;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
}
.status-pending {
background-color: #ffc107;
color: #212529;
}
.status-completed {
background-color: #28a745;
color: white;
}
.status-cancelled {
background-color: #dc3545;
color: white;
}
.order-details p {
margin: 5px 0;
color: #666;
}