208 lines
3.9 KiB
Vue
208 lines
3.9 KiB
Vue
<template>
|
|
<div class="stats-cards">
|
|
<div
|
|
v-for="card in statsCards"
|
|
:key="card.id"
|
|
class="stat-card"
|
|
:class="card.colorClass"
|
|
>
|
|
<div class="stat-icon">
|
|
<q-icon :name="card.icon" size="28px" />
|
|
</div>
|
|
<div class="stat-content">
|
|
<div class="stat-value">
|
|
<template v-if="isLoading">
|
|
<q-skeleton type="text" width="60px" />
|
|
</template>
|
|
<template v-else>
|
|
{{ card.value }}
|
|
</template>
|
|
</div>
|
|
<div class="stat-label">{{ card.label }}</div>
|
|
</div>
|
|
<div class="stat-trend" v-if="card.trend">
|
|
<q-icon
|
|
:name="card.trend > 0 ? 'trending_up' : 'trending_down'"
|
|
:color="card.trend > 0 ? 'positive' : 'negative'"
|
|
/>
|
|
<span :class="card.trend > 0 ? 'text-positive' : 'text-negative'">
|
|
{{ Math.abs(card.trend) }}%
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
|
|
interface Stats {
|
|
totalPosters: number;
|
|
postersThisMonth: number;
|
|
aiGenerations: number;
|
|
favoriteTemplates: number;
|
|
}
|
|
|
|
const props = defineProps<{
|
|
stats: Stats;
|
|
isLoading: boolean;
|
|
}>();
|
|
|
|
const statsCards = computed(() => [
|
|
{
|
|
id: 'total',
|
|
icon: 'image',
|
|
label: 'Locandine Totali',
|
|
value: props.stats.totalPosters,
|
|
colorClass: 'card-primary',
|
|
trend: null
|
|
},
|
|
{
|
|
id: 'month',
|
|
icon: 'calendar_month',
|
|
label: 'Questo Mese',
|
|
value: props.stats.postersThisMonth,
|
|
colorClass: 'card-success',
|
|
trend: 15
|
|
},
|
|
{
|
|
id: 'ai',
|
|
icon: 'auto_awesome',
|
|
label: 'Generazioni AI',
|
|
value: props.stats.aiGenerations,
|
|
colorClass: 'card-warning',
|
|
trend: null
|
|
},
|
|
{
|
|
id: 'templates',
|
|
icon: 'dashboard',
|
|
label: 'Template Usati',
|
|
value: props.stats.favoriteTemplates,
|
|
colorClass: 'card-info',
|
|
trend: null
|
|
}
|
|
]);
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.stats-cards {
|
|
display: grid;
|
|
grid-template-columns: repeat(4, 1fr);
|
|
gap: 1.5rem;
|
|
margin-top: -3rem;
|
|
position: relative;
|
|
z-index: 10;
|
|
|
|
@media (max-width: 1100px) {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
@media (max-width: 600px) {
|
|
grid-template-columns: 1fr;
|
|
margin-top: -2rem;
|
|
}
|
|
}
|
|
|
|
.stat-card {
|
|
background: white;
|
|
border-radius: 16px;
|
|
padding: 1.5rem;
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 1rem;
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
|
transition: all 0.3s ease;
|
|
position: relative;
|
|
overflow: hidden;
|
|
|
|
&:hover {
|
|
transform: translateY(-4px);
|
|
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
|
|
}
|
|
|
|
&::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 4px;
|
|
height: 100%;
|
|
}
|
|
|
|
&.card-primary::before { background: #667eea; }
|
|
&.card-success::before { background: #4caf50; }
|
|
&.card-warning::before { background: #ff9800; }
|
|
&.card-info::before { background: #2196f3; }
|
|
}
|
|
|
|
.stat-icon {
|
|
width: 56px;
|
|
height: 56px;
|
|
border-radius: 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
|
|
.card-primary & {
|
|
background: rgba(102, 126, 234, 0.1);
|
|
color: #667eea;
|
|
}
|
|
|
|
.card-success & {
|
|
background: rgba(76, 175, 80, 0.1);
|
|
color: #4caf50;
|
|
}
|
|
|
|
.card-warning & {
|
|
background: rgba(255, 152, 0, 0.1);
|
|
color: #ff9800;
|
|
}
|
|
|
|
.card-info & {
|
|
background: rgba(33, 150, 243, 0.1);
|
|
color: #2196f3;
|
|
}
|
|
}
|
|
|
|
.stat-content {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
color: #333;
|
|
line-height: 1.2;
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 0.85rem;
|
|
color: #888;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.stat-trend {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.25rem;
|
|
font-size: 0.8rem;
|
|
font-weight: 600;
|
|
position: absolute;
|
|
top: 1rem;
|
|
right: 1rem;
|
|
}
|
|
|
|
// Dark mode
|
|
.body--dark {
|
|
.stat-card {
|
|
background: #1e1e1e;
|
|
}
|
|
|
|
.stat-value {
|
|
color: #fff;
|
|
}
|
|
}
|
|
</style>
|