140 lines
3.3 KiB
Plaintext
140 lines
3.3 KiB
Plaintext
---
|
|
// components/ShoppingCard.astro
|
|
const { item, remaining, total, unit, category } = Astro.props;
|
|
|
|
// Calcul du pourcentage pour la jauge
|
|
const percentage = Math.max(0, Math.min(100, (remaining / total) * 100));
|
|
const isLow = remaining > 0 && percentage < 25;
|
|
const isEmpty = remaining <= 0;
|
|
---
|
|
|
|
<article
|
|
class={`tcg-card shopping-card ${isEmpty ? "empty" : ""} ${isLow ? "low" : ""}`}
|
|
>
|
|
<div class="card-inner">
|
|
<header class="card-header">
|
|
<span class="card-name">{item}</span>
|
|
<span class="card-icon">{isEmpty ? "❌" : "📦"}</span>
|
|
</header>
|
|
|
|
<div class="visual-container">
|
|
<div class="stock-display">
|
|
<span class="remaining-num">{remaining}</span>
|
|
<span class="unit-text">{unit}</span>
|
|
</div>
|
|
|
|
<div class="progress-track">
|
|
<div class="progress-fill" style={`width: ${percentage}%`}>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<div class="category-badge">{category || "Logistique"}</div>
|
|
<p class="stock-total">Capacité max: {total} {unit}</p>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
|
|
<style>
|
|
.shopping-card {
|
|
--primary: #10b981;
|
|
background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
|
|
border: 1px solid #e2e8f0;
|
|
border-radius: 12px;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.shopping-card.low {
|
|
--primary: #f59e0b;
|
|
}
|
|
.shopping-card.empty {
|
|
--primary: #ef4444;
|
|
opacity: 0.7;
|
|
}
|
|
|
|
.card-inner {
|
|
padding: 15px;
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 15px;
|
|
font-family: "Philosopher", serif;
|
|
font-weight: bold;
|
|
color: #1e293b;
|
|
}
|
|
|
|
.visual-container {
|
|
background: #f8fafc;
|
|
border-radius: 8px;
|
|
padding: 20px 10px;
|
|
text-align: center;
|
|
border: 1px inset rgba(0, 0, 0, 0.02);
|
|
}
|
|
|
|
.stock-display {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
|
|
.remaining-num {
|
|
font-size: 2.2rem;
|
|
font-weight: 900;
|
|
color: #1e293b;
|
|
line-height: 1;
|
|
}
|
|
|
|
.unit-text {
|
|
font-size: 0.7rem;
|
|
color: #94a3b8;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.progress-track {
|
|
width: 100%;
|
|
height: 6px;
|
|
background: #e2e8f0;
|
|
border-radius: 10px;
|
|
margin-top: 15px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.progress-fill {
|
|
height: 100%;
|
|
background: var(--primary);
|
|
box-shadow: 0 0 8px var(--primary);
|
|
transition: width 0.8s ease-out;
|
|
}
|
|
|
|
.card-body {
|
|
margin-top: 15px;
|
|
text-align: center;
|
|
}
|
|
|
|
.category-badge {
|
|
font-size: 0.6rem;
|
|
font-weight: bold;
|
|
color: var(--primary);
|
|
background: rgba(0, 0, 0, 0.03);
|
|
padding: 3px 10px;
|
|
border-radius: 20px;
|
|
display: inline-block;
|
|
text-transform: uppercase;
|
|
border: 1px solid rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.stock-total {
|
|
font-size: 0.6rem;
|
|
color: #cbd5e1;
|
|
margin-top: 8px;
|
|
}
|
|
</style>
|