feat: transform catalog to modern grid layout with compact product cards

- Transform Card.vue from horizontal to vertical compact design
- Reduce card height with fixed image max-height (160-240px responsive)
- Center all text content (product name, prices, actions)
- Style product name with semibold font-weight, 2-line ellipsis
- Redesign price labels: subtle gray uppercase for labels, bold primary for values
- Style quantity controls: tonal icon buttons with smooth animations
- Redesign input field: solo-filled variant, compact density, subtle shadow
- Transform catalog.vue list layout to responsive grid (v-row/v-col)
- Implement responsive columns: 1 col mobile, 2 cols tablet, 3 cols desktop
- Clean up obsolete .catalog-item styles, use native Vuetify grid spacing
- Add hover effects: translateY(-6px), scale(1.08) on image, border highlight
- Add footer background (#fafafa) for visual separation
- Optimize breakpoints: 6 responsive sizes (374px, 559px, 959px, 1280px, 1920px)
- Result: Professional, compact, balanced e-commerce catalog design
This commit is contained in:
2026-05-28 23:05:57 -05:00
parent 196a5e2068
commit 6970867f7b
2 changed files with 372 additions and 384 deletions

View File

@@ -1,64 +1,99 @@
<template> <template>
<v-card class="product-card"> <v-card class="product-card" elevation="2" rounded="lg">
<v-row class="product-card-row"> <!-- Imagen del Producto -->
<!-- Columna de Imagen --> <div class="product-image-container">
<v-col cols="12" md="4" class="image-column"> <v-img
<v-img :src="product.img" class="product-img" contain></v-img> :src="product.img"
</v-col> :alt="product.name"
class="product-img"
cover
max-height="180"
>
<template v-slot:placeholder>
<div class="d-flex align-center justify-center fill-height">
<v-progress-circular indeterminate color="primary" size="32"></v-progress-circular>
</div>
</template>
</v-img>
</div>
<!-- Columna de Detalles --> <!-- Contenido de la Tarjeta -->
<v-col cols="12" md="5" class="details-column"> <v-card-text class="product-content pa-3 text-center">
<div class="product-details-content"> <!-- Título del Producto -->
<v-tooltip location="top" :text="product.name"> <v-tooltip location="top" :text="product.name">
<template v-slot:activator="{ props }"> <template v-slot:activator="{ props }">
<v-card-title class="product-name" v-bind="props" :title="product.name"> <h3 class="product-name text-subtitle-1 font-weight-medium mb-2" v-bind="props">
{{ product.name }} {{ product.name }}
</v-card-title> </h3>
</template> </template>
</v-tooltip> </v-tooltip>
<v-card-subtitle class="product-description">{{
product.description
}}</v-card-subtitle>
<div class="prices"> <!-- Sección de Precios -->
<div class="price-unit"> <div class="prices-section mb-2">
<span class="price-label">Precio unitario</span> <!-- Precio Unitario -->
<span class="price-value">{{ currency(product.price) }}</span> <div class="price-row mb-1">
</div> <span class="price-label text-caption">Precio unitario</span>
<div class="price-value text-body-1 font-weight-bold text-primary">
<div class="price-total"> {{ currency(product.price) }}
<span class="price-label">Precio total</span>
<span class="price-value total"
>{{ currency(product.price * product.quantity) }}
</span>
</div>
</div> </div>
</div> </div>
</v-col>
<!-- Precio Total -->
<!-- Columna de Controles --> <div class="price-row">
<v-col cols="12" md="3" class="controls-column"> <span class="price-label text-caption">Precio total</span>
<div class="quantity-controls"> <v-chip
<v-btn icon small class="qty-btn" @click="decrease(product)"> color="success"
<v-icon small>mdi-minus</v-icon> variant="flat"
</v-btn> size="small"
<v-text-field class="price-total-chip font-weight-bold mt-1"
v-model.number="product.quantity" >
type="number" {{ currency(product.price * product.quantity) }}
min="0" </v-chip>
class="quantity-input"
dense
outlined
hide-details
aria-label="Cantidad"
@input="handleQuantityChange"
/>
<v-btn icon small class="qty-btn qty-btn-add" @click="handleIncrease">
<v-icon small>mdi-plus</v-icon>
</v-btn>
</div> </div>
</v-col> </div>
</v-row> </v-card-text>
<!-- Footer con Controles de Cantidad -->
<v-card-actions class="product-actions pa-2 pb-3 justify-center">
<div class="quantity-controls">
<v-btn
icon
size="small"
variant="tonal"
color="error"
class="qty-btn"
@click="decrease(product)"
:disabled="product.quantity === 0"
>
<v-icon size="20">mdi-minus</v-icon>
</v-btn>
<v-text-field
v-model.number="product.quantity"
type="number"
min="0"
class="quantity-input mx-1"
variant="solo-filled"
density="compact"
hide-details
single-line
flat
aria-label="Cantidad"
@input="handleQuantityChange"
/>
<v-btn
icon
size="small"
variant="tonal"
color="success"
class="qty-btn"
@click="handleIncrease"
>
<v-icon size="20">mdi-plus</v-icon>
</v-btn>
</div>
</v-card-actions>
</v-card> </v-card>
</template> </template>
@@ -102,400 +137,325 @@ export default {
</script> </script>
<style scoped> <style scoped>
/* ===== ESTILOS BASE - MOBILE FIRST (< 560px) ===== */ /* ============================================
CARD CONTAINER
/* Card Container */ ============================================ */
.product-card { .product-card {
border: 1px solid #e0e0e0; height: 100%;
border-radius: 8px; display: flex;
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%); flex-direction: column;
transition: all 0.3s ease; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
border: 1px solid rgba(0, 0, 0, 0.08);
background: #ffffff;
overflow: hidden; overflow: hidden;
} }
.product-card:hover { .product-card:hover {
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); transform: translateY(-6px);
transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12) !important;
border-color: #bdbdbd; border-color: rgba(33, 150, 243, 0.3);
} }
/* Row Container */ /* ============================================
.product-card-row { IMAGEN DEL PRODUCTO
padding: 12px 8px; ============================================ */
margin: 0; .product-image-container {
} position: relative;
width: 100%;
/* === COLUMNA DE IMAGEN === */ height: 180px;
.image-column { overflow: hidden;
display: flex; background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
justify-content: center; border-bottom: 1px solid rgba(0, 0, 0, 0.05);
align-items: center;
padding: 0 0 16px 0;
} }
.product-img { .product-img {
width: 280px; width: 100%;
height: 280px; height: 100%;
border-radius: 12px; transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
object-fit: cover;
background: #fff;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease;
} }
.product-card:hover .product-img { .product-card:hover .product-img {
transform: scale(1.03); transform: scale(1.08);
} }
/* === COLUMNA DE DETALLES === */ /* ============================================
.details-column { CONTENIDO DE LA TARJETA
padding: 0; ============================================ */
.product-content {
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-width: 0; align-items: center;
} justify-content: flex-start;
.product-details-content {
display: flex;
flex-direction: column;
gap: 12px;
width: 100%;
} }
.product-name { .product-name {
font-size: 0.95rem; font-size: 0.95rem;
font-weight: 600; font-weight: 500;
color: #2c3e50; color: #1a1a1a;
line-height: 1.3; line-height: 1.3;
padding: 0;
text-align: center;
word-break: break-word;
max-width: 100%;
}
.product-description {
font-size: 0.8rem;
color: #7f8c8d;
line-height: 1.4;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
overflow: hidden; overflow: hidden;
text-align: center; text-overflow: ellipsis;
padding: 0; min-height: 2.5rem;
margin-bottom: 4px; letter-spacing: 0.01em;
} }
/* === PRECIOS === */ /* ============================================
.prices { SECCIÓN DE PRECIOS
============================================ */
.prices-section {
width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8px;
align-items: center; align-items: center;
gap: 4px;
} }
.price-unit, .price-row {
.price-total {
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; gap: 2px;
gap: 8px;
width: 100%;
} }
.price-label { .price-label {
font-size: 0.7rem;
color: #95a5a6;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.5px; letter-spacing: 0.8px;
white-space: nowrap; font-size: 0.65rem;
color: #9e9e9e;
font-weight: 500;
} }
.price-value { .price-value {
font-size: 0.85rem; color: #1565c0;
font-weight: 600; letter-spacing: 0.02em;
color: #2c3e50; font-size: 1.1rem;
} }
.price-value.total { .price-total-chip {
background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%); letter-spacing: 0.03em;
color: white; font-size: 0.9rem;
padding: 3px 10px; padding: 0 12px;
border-radius: 20px; height: 26px;
font-size: 0.95rem; box-shadow: 0 2px 8px rgba(76, 175, 80, 0.25);
box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
white-space: nowrap;
} }
/* === COLUMNA DE CONTROLES === */ /* ============================================
.controls-column { CONTROLES DE CANTIDAD
display: flex; ============================================ */
align-items: center; .product-actions {
justify-content: center; border-top: 1px solid rgba(0, 0, 0, 0.06);
padding: 16px 0 0 0; background: #fafafa;
} }
.quantity-controls { .quantity-controls {
display: inline-flex; display: flex;
align-items: center; align-items: center;
justify-content: center;
gap: 6px; gap: 6px;
background: #f5f5f5;
border-radius: 25px;
padding: 6px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
} }
.quantity-input { .quantity-input {
max-width: 60px; max-width: 65px;
min-width: 60px; min-width: 65px;
} }
.quantity-input input { .quantity-input :deep(.v-field) {
background-color: #ffffff !important;
border-radius: 8px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.quantity-input :deep(.v-field__input) {
text-align: center; text-align: center;
font-weight: 600; font-weight: 700;
font-size: 0.9rem; font-size: 0.95rem;
color: #1a1a1a;
padding: 4px 0;
min-height: 32px;
}
.quantity-input :deep(.v-field__field) {
padding: 0;
} }
.qty-btn { .qty-btn {
min-width: 32px !important;
width: 32px !important;
height: 32px !important;
border-radius: 50% !important;
background: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
transition: all 0.2s ease;
flex-shrink: 0; flex-shrink: 0;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
} }
.qty-btn:hover { .qty-btn:hover {
background: #e0e0e0; transform: scale(1.1);
transform: scale(1.08);
} }
.qty-btn-add { .qty-btn:active {
background: #27ae60; transform: scale(0.95);
color: white;
} }
.qty-btn-add:hover { /* ============================================
background: #219a52 !important; RESPONSIVE BREAKPOINTS
============================================ */
/* Móvil pequeño (< 375px) */
@media (max-width: 374px) {
.product-image-container {
height: 160px;
}
.product-content {
padding: 10px;
}
.product-name {
font-size: 0.9rem;
min-height: 2.4rem;
}
.price-value {
font-size: 1rem;
}
.quantity-input {
max-width: 60px;
min-width: 60px;
}
} }
/* ===== RESOLUCIÓN 375-559px (Mobile Standard) ===== */ /* Móvil estándar (375px - 559px) */
@media (min-width: 375px) and (max-width: 559px) { @media (min-width: 375px) and (max-width: 559px) {
.product-img { .product-image-container {
width: 300px; height: 170px;
height: 300px;
}
.product-card-row {
padding: 14px 10px;
} }
.product-name { .product-name {
font-size: 1rem;
}
.product-description {
font-size: 0.85rem;
}
.quantity-input {
max-width: 65px;
min-width: 65px;
}
}
/* ===== RESOLUCIÓN 560-959px (Tablet) ===== */
@media (min-width: 560px) and (max-width: 959px) {
.product-card-row {
padding: 16px 12px;
}
.image-column {
padding-bottom: 20px;
}
.product-img {
width: 300px;
height: 300px;
}
.product-details-content {
gap: 14px;
}
.product-name {
font-size: 1.05rem;
}
.product-description {
font-size: 0.85rem;
}
.prices {
gap: 10px;
}
.price-label {
font-size: 0.75rem;
}
.price-value {
font-size: 0.9rem;
}
.price-value.total {
font-size: 1rem;
padding: 4px 12px;
}
.controls-column {
padding-top: 18px;
}
.quantity-input {
max-width: 70px;
min-width: 70px;
}
.qty-btn {
min-width: 34px !important;
width: 34px !important;
height: 34px !important;
}
}
/* ===== RESOLUCIÓN ≥960px (Desktop) ===== */
@media (min-width: 960px) {
.product-card {
border-radius: 12px;
}
.product-card:hover {
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
transform: translateY(-4px);
}
.product-card:hover .product-img {
transform: scale(1.05);
}
.product-card-row {
padding: 16px;
align-items: center;
}
.image-column {
padding: 0 24px 0 0;
margin-bottom: 0;
max-width: 380px;
}
.product-img {
width: 350px;
height: 350px;
}
.details-column {
padding: 0 24px 0 0;
border-right: 1px solid #e0e0e0;
flex: 1;
align-items: flex-start;
min-width: 0;
}
.product-details-content {
gap: 16px;
align-items: flex-start;
min-width: 0;
}
.product-name {
font-size: 1.15rem;
text-align: left;
}
.product-description {
font-size: 0.9rem;
text-align: left;
}
.prices {
align-items: flex-start;
gap: 10px;
}
.price-unit,
.price-total {
justify-content: flex-start;
}
.price-label {
font-size: 0.75rem;
}
.price-value {
font-size: 0.95rem; font-size: 0.95rem;
} }
.price-value.total { .price-value {
font-size: 1.05rem; font-size: 1.05rem;
padding: 4px 12px;
} }
}
.controls-column { /* Tablet (560px - 959px) */
justify-content: flex-end; @media (min-width: 560px) and (max-width: 959px) {
margin-top: 0; .product-image-container {
padding: 0 0 0 16px; height: 190px;
min-width: 180px;
} }
.quantity-controls { .product-content {
gap: 8px; padding: 14px;
padding: 6px;
} }
.product-name {
font-size: 1rem;
min-height: 2.6rem;
}
.price-label {
font-size: 0.68rem;
}
.price-value {
font-size: 1.15rem;
}
.price-total-chip {
font-size: 0.95rem;
height: 28px;
}
.quantity-input { .quantity-input {
max-width: 70px; max-width: 70px;
min-width: 70px; min-width: 70px;
} }
.qty-btn {
min-width: 36px !important;
width: 36px !important;
height: 36px !important;
}
.qty-btn:hover {
transform: scale(1.1);
}
} }
/* ===== RESOLUCIÓN ≥1280px (Desktop Large) ===== */ /* Desktop (≥ 960px) */
@media (min-width: 1280px) { @media (min-width: 960px) {
.product-card-row { .product-image-container {
padding: 20px; height: 200px;
} }
.image-column { .product-content {
padding-right: 28px; padding: 16px 14px;
} }
.details-column {
padding-right: 28px;
}
.product-name { .product-name {
font-size: 1.05rem;
min-height: 2.7rem;
}
.price-label {
font-size: 0.7rem;
}
.price-value {
font-size: 1.2rem; font-size: 1.2rem;
} }
.product-description { .price-total-chip {
font-size: 0.95rem; font-size: 1rem;
height: 30px;
padding: 0 14px;
} }
.product-actions {
padding: 8px;
padding-bottom: 12px;
}
.quantity-input {
max-width: 70px;
min-width: 70px;
}
.qty-btn {
width: 36px;
height: 36px;
}
}
.controls-column { /* Desktop Large (≥ 1280px) */
padding-left: 20px; @media (min-width: 1280px) {
.product-image-container {
height: 220px;
}
.product-content {
padding: 18px 16px;
}
.product-name {
font-size: 1.1rem;
min-height: 2.8rem;
}
.price-value {
font-size: 1.25rem;
}
.price-total-chip {
font-size: 1.05rem;
height: 32px;
}
}
/* Desktop Extra Large (≥ 1920px) */
@media (min-width: 1920px) {
.product-image-container {
height: 240px;
}
.product-name {
font-size: 1.15rem;
min-height: 3rem;
}
.price-value {
font-size: 1.3rem;
} }
} }
</style> </style>

View File

@@ -60,21 +60,27 @@
position="top" position="top"
/> />
<!-- Lista de productos paginados --> <!-- Grid de productos paginados -->
<v-list-item <v-row class="product-grid" v-if="paginatedItems.length > 0">
v-for="item in paginatedItems" <v-col
:key="item.id" v-for="item in paginatedItems"
class="catalog-item" :key="item.id"
> cols="12"
<Card sm="6"
:product="item" md="6"
:increase="increase" lg="4"
:decrease="decrease" class="product-col"
:currency="currency" >
:updateQuantity="updateQuantity" <Card
@add-to-cart="addToCart" :product="item"
/> :increase="increase"
</v-list-item> :decrease="decrease"
:currency="currency"
:updateQuantity="updateQuantity"
@add-to-cart="addToCart"
/>
</v-col>
</v-row>
<!-- Mensaje cuando no hay productos --> <!-- Mensaje cuando no hay productos -->
<v-alert <v-alert
@@ -642,26 +648,52 @@ export default {
} }
/* ============================================ /* ============================================
ITEMS DEL CATÁLOGO GRID DE PRODUCTOS
============================================ */ ============================================ */
.catalog-item { .product-grid {
padding: 0; margin: 0 -8px;
margin-bottom: 12px;
} }
.catalog-item:last-child { .product-col {
margin-bottom: 0; padding: 8px;
display: flex;
} }
/* Asegurar que las cards ocupen toda la altura */
.product-col :deep(.product-card) {
width: 100%;
}
/* Mobile: mayor espaciado vertical */
@media (max-width: 559px) { @media (max-width: 559px) {
.catalog-item { .product-grid {
margin-bottom: 10px; margin: 0 -6px;
}
.product-col {
padding: 6px;
} }
} }
/* Tablet: espaciado medio */
@media (min-width: 560px) and (max-width: 959px) { @media (min-width: 560px) and (max-width: 959px) {
.catalog-item { .product-grid {
margin-bottom: 14px; margin: 0 -8px;
}
.product-col {
padding: 8px;
}
}
/* Desktop: espaciado óptimo */
@media (min-width: 960px) {
.product-grid {
margin: 0 -12px;
}
.product-col {
padding: 12px;
} }
} }
@@ -687,10 +719,6 @@ export default {
.pb-mobile-cart { .pb-mobile-cart {
padding-bottom: 16px !important; padding-bottom: 16px !important;
} }
.catalog-item {
margin-bottom: 16px;
}
} }
/* ============================================ /* ============================================