docs: README, CLAUDE.md, changelog, plans de conception
- README : fonctionnalités, installation, build, tests (302 + 20 E2E), couverture 94%, workflow mise à jour latest.yml, changelog v1.1.6 - CLAUDE.md : règles de collaboration, architecture, conventions - Plans de conception : DDD, electron-updater, accouplement, toast Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
335
docs/fonctionnalites-par-ecran.md
Normal file
335
docs/fonctionnalites-par-ecran.md
Normal file
@@ -0,0 +1,335 @@
|
||||
# Fonctionnalités par écran — Minuteur Dragodinde
|
||||
|
||||
---
|
||||
|
||||
## 1. Shell principal (App)
|
||||
|
||||
### Header
|
||||
- Bouton hamburger (☰) pour ouvrir/fermer la sidebar
|
||||
- Logo "⚔ MINUTEUR DRAGODINDE"
|
||||
- Sous-titre "Dofus 3 · Gestion multi-enclos en temps réel · vX.X.X"
|
||||
- Version injectée dynamiquement via Electron API
|
||||
- Badge "DEV" en mode développement
|
||||
|
||||
### Barre d'onglets
|
||||
- Onglet Dashboard (📊)
|
||||
- Un onglet par enclos :
|
||||
- Icône 🐉 + nom de l'enclos
|
||||
- Dot animé : vert pulsant si timer en cours, gris si inactif
|
||||
- Bouton supprimer (✕), visible si plus d'1 enclos
|
||||
- Drag-and-drop pour réordonner les onglets
|
||||
- Bouton "+ Enclos" (désactivé si max atteint)
|
||||
|
||||
### Bannière de mise à jour
|
||||
- États : disponible → téléchargement (barre de progression %) → prête → erreur
|
||||
- Bouton "Installer et redémarrer"
|
||||
- Bouton fermer (✕) sur erreur
|
||||
|
||||
### Zoom clavier
|
||||
- Ctrl + (+) : zoom avant
|
||||
- Ctrl + (-) : zoom arrière
|
||||
- Ctrl + 0 : reset 100%
|
||||
|
||||
---
|
||||
|
||||
## 2. Sidebar — Navigation latérale
|
||||
|
||||
- **Dashboard** (📊)
|
||||
- **Section "Enclos"** : liste dynamique de chaque enclos
|
||||
- Icône 🐉 + nom + dot coloré (vert=running, gris=idle)
|
||||
- **Section "Outils"** :
|
||||
- Accouplement (💑)
|
||||
- Réappro (🧬)
|
||||
- Inventaire (📦)
|
||||
- Workflows (📋)
|
||||
- **Paramètres** (⚙)
|
||||
- Indicateur visuel de la vue active
|
||||
- Fermeture auto au clic sur l'overlay
|
||||
|
||||
---
|
||||
|
||||
## 3. Dashboard — Vue d'ensemble
|
||||
|
||||
### Cartes des enclos
|
||||
Pour chaque enclos :
|
||||
- Nom de l'enclos
|
||||
- Dot animé + statut textuel ("En cours" / "Pause" / "Inactif")
|
||||
- Liste des jauges actives (badges colorés avec icônes)
|
||||
- Nombre de dragodindes + terminées (ex: "5 DD · 3/5 ✅")
|
||||
- Temps restant (countdown live) ou "✅ Terminé !"
|
||||
- Temps écoulé (live)
|
||||
- Bouton "→ Gérer cet enclos" (navigation)
|
||||
|
||||
### Statistiques globales
|
||||
- **KPI** :
|
||||
- Bébés au total
|
||||
- Dragodindes actives
|
||||
- Couples accouplés
|
||||
- Taux de réussite (%)
|
||||
- Races obtenues
|
||||
- **Histogramme des races** : barres horizontales triées par quantité, colorées par race
|
||||
- **Bouton "Réinitialiser"** : efface stats et accouplements
|
||||
|
||||
### Temps réel
|
||||
- Countdowns et temps écoulés mis à jour en continu
|
||||
- Dots animés sur les enclos en cours
|
||||
|
||||
---
|
||||
|
||||
## 4. Enclos — Vue timer principale
|
||||
|
||||
### En-tête
|
||||
- **Nom de l'enclos** : input éditable (focus vide, blur sauvegarde, Escape annule, Enter valide)
|
||||
- **Bouton "🗑 Vider l'enclos"** : supprime toutes les DD et reset
|
||||
|
||||
### Carte Jauges (max 2 actives)
|
||||
- **6 boutons toggle** : Baffeur (➖), Caresseur (➕), Foudroyeur (⚡), Abreuvoir (💧), Dragofesse (❤), Mangeoire (🍖)
|
||||
- État actif : bordure colorée
|
||||
- Verrouillé si timer en cours
|
||||
- **Exclusion mutuelle** baffeur ↔ caresseur (l'un bloque l'autre)
|
||||
- **Par jauge active** :
|
||||
- Icône + nom + badge Tier ("Tier X · ±Y/tick")
|
||||
- Input niveau (0–100 000, step 1000)
|
||||
- Avant timer : modifie le niveau
|
||||
- Pendant timer : recharge la jauge (style visuel distinct)
|
||||
- Barre de progression (% de remplissage)
|
||||
- Info : "Jauge : {niveau} · Vide en {durée}"
|
||||
|
||||
### Barre timer
|
||||
- **Bouton** : "▶ Démarrer" / "⏸ Pause" / "▶ Reprendre"
|
||||
- **Temps écoulé** (gauche) : HH:MM:SS live
|
||||
- **Alarme dans** (droite) : countdown global ou "✅" ou "--:--:--"
|
||||
|
||||
### Bannière de fin
|
||||
- "✅ Session terminée !" (visible quand toutes les cibles atteintes)
|
||||
- Bouton "🔄 Nouvelle fournée" (reset timer, conserve les niveaux de jauges)
|
||||
|
||||
### Section Dragodindes
|
||||
- Compteur "X/10"
|
||||
- Bouton "+ Ajouter une Dragodinde" (désactivé si 10 atteint)
|
||||
- Grille de cartes DD (drag-and-drop pour réordonner)
|
||||
|
||||
---
|
||||
|
||||
## 5. Carte Dragodinde (sous-composant d'Enclos)
|
||||
|
||||
### En-tête
|
||||
- Poignée de drag (⠿)
|
||||
- Nom éditable (même comportement focus/blur)
|
||||
- Bouton supprimer (✕)
|
||||
|
||||
### Pilules de stats (5)
|
||||
| Stat | Icône | Plage | Couleur |
|
||||
|------|-------|-------|---------|
|
||||
| Sérénité | 😊 | -5000 à +5000 | Violet |
|
||||
| Endurance | ⚡ | 0 à 20 000 | Jaune |
|
||||
| Maturité | 💧 | 0 à 20 000 | Cyan |
|
||||
| Amour | ❤️ | 0 à 20 000 | Rouge |
|
||||
| XP (niveau) | ⭐ | 1 à 200 | Orange |
|
||||
|
||||
- Input éditable par pilule (focus/blur)
|
||||
- Mise à jour live pendant le timer
|
||||
- Effet lumineux (glow) quand la stat atteint un cap
|
||||
- Animation delta (+X / -X) qui pop à chaque tick de 10s
|
||||
|
||||
### Cible sérénité (😊)
|
||||
- Input numérique (bornes selon jauge active : négatif si baffeur, positif si caresseur)
|
||||
- Bouton effacer (✕)
|
||||
- ETA affiché : "~Xm XXs" ou "✅" ou "➕/➖" (si jauge nécessaire non active)
|
||||
- Placeholder dynamique ("-5000 à 0" ou "0 à 5000")
|
||||
|
||||
### Cible niveau (⭐)
|
||||
- Input numérique (1–200)
|
||||
- Bouton effacer (✕)
|
||||
- ETA affiché
|
||||
|
||||
### Blocs jauges actives
|
||||
**Pour chaque jauge active :**
|
||||
|
||||
**Mangeoire (XP) — bloc spécial :**
|
||||
- En-tête : icône + "XP / NIVEAU"
|
||||
- ETA niveau 200 : "→ NIV. 200 : ~Xj Xh"
|
||||
- Barre de progression vers 200 + pourcentage
|
||||
- Valeur live (NIV. X), delta (+X xp), countdown
|
||||
|
||||
**Autres jauges :**
|
||||
- En-tête : icône + nom (coloré)
|
||||
- Valeur live, delta (pop animé), countdown
|
||||
- Barre de progression vers la cible
|
||||
|
||||
### Badge "✓ TERMINÉ"
|
||||
- Affiché quand toutes les jauges actives de cette DD ont atteint leur cible
|
||||
|
||||
---
|
||||
|
||||
## 6. Accouplement — Enregistrement de croisements
|
||||
|
||||
### Étape 1 : Sélection du parent 1
|
||||
- Barre de recherche (🔍) avec bouton effacer
|
||||
- Filtres par génération (onglets colorés : Toutes, Gen 1–10)
|
||||
- Grille de cartes race (image, nom, badge gen)
|
||||
- Message vide si aucun résultat
|
||||
|
||||
### Étape 2 : Sélection du parent 2
|
||||
- Bouton "← Retour"
|
||||
- Carte du parent 1 affichée (non cliquable)
|
||||
- Label "Choisir le partenaire :"
|
||||
- Grille des partenaires compatibles uniquement
|
||||
- Chaque carte montre "→ {bébé}" en dessous
|
||||
|
||||
### Étape 3 : Résultat
|
||||
- Bouton "← Retour"
|
||||
- Affichage en ligne : Parent 1 + Parent 2 = Bébé (cartes avec images et badges gen)
|
||||
- Input "Couples" (nombre)
|
||||
- Input "Bébés obtenus" (nombre)
|
||||
- Bouton "Enregistrer" → commande `register-accouplement`
|
||||
|
||||
---
|
||||
|
||||
## 7. Réapprovisionnement — Calcul de plan d'élevage
|
||||
|
||||
### Étape 1 : Sélection de la race cible
|
||||
- Barre de recherche (🔍) avec bouton effacer
|
||||
- Filtres par génération (Gen 2–10 uniquement)
|
||||
- Grille de cartes race (gen 2+ seulement)
|
||||
|
||||
### Étape 2 : Plan d'élevage
|
||||
- Bouton "← Retour"
|
||||
- Carte cible + input quantité (mise à jour live du plan)
|
||||
|
||||
**Matériaux (Gen 1) :**
|
||||
- Mini-cartes par race de base : image, nom, badge gen, ♂X ♀Y
|
||||
|
||||
**Étapes (Gen 2+) :**
|
||||
Par génération, pour chaque croisement :
|
||||
- En-tête "Étape X — Gen Y" (coloré)
|
||||
- Affichage : Parent A + Parent B → Bébé (mini-cartes)
|
||||
- Input "Reproducteurs" (nombre, par croisement)
|
||||
- Bouton inversion ♂/♀ (swap la direction de reproduction)
|
||||
|
||||
**Actions :**
|
||||
- Bouton "Sauvegarder le workflow"
|
||||
|
||||
---
|
||||
|
||||
## 8. Inventaire — Gestion du stock & simulation
|
||||
|
||||
### Saisie du stock
|
||||
- Résumé : "X DD en stock (Y races)"
|
||||
- Bouton "Réinitialiser" (remet tout à 0)
|
||||
- Bouton "Calculer les bébés" (lance la simulation)
|
||||
- Barre de recherche (🔍)
|
||||
- Filtres par génération (Gen 1–10)
|
||||
- Grille de cartes race :
|
||||
- Image, nom, badge gen
|
||||
- Input ♂ (mâles) + input ♀ (femelles)
|
||||
- Mise à jour du résumé en temps réel pendant la saisie
|
||||
- Persistance automatique du stock entre les changements d'écran
|
||||
|
||||
### Résultats de simulation
|
||||
- En-tête global : "{N} bébés possibles sur {G} génération(s)"
|
||||
- Bouton "Sauvegarder le workflow"
|
||||
- Par génération :
|
||||
- Badge gen + total bébés
|
||||
- Par croisement : Parent A (♂X ♀Y) + Parent B (♂X ♀Y) → Bébé (×Z)
|
||||
- Section "DD restantes (non utilisées)" : mini-cartes du stock inutilisé
|
||||
|
||||
### Algorithme
|
||||
- Allocation proportionnelle (pas glouton) : chaque parent est réparti équitablement entre les croisements qui l'utilisent
|
||||
- Cascade multi-générations (Gen 2 → Gen 10)
|
||||
|
||||
---
|
||||
|
||||
## 9. Workflows — Suivi des plans d'élevage
|
||||
|
||||
### Vue liste
|
||||
- Titre "Plans d'élevage"
|
||||
- Barre de recherche (🔍)
|
||||
- Filtres par génération (uniquement les gens qui ont des workflows)
|
||||
- Message vide si aucun workflow
|
||||
|
||||
**Par carte workflow :**
|
||||
- Image de la race cible + badge gen
|
||||
- Nom du workflow (tronqué)
|
||||
- "Cible × Quantité — Date de création"
|
||||
- Barre de progression globale (colorée) + "X/Y — Z%"
|
||||
- Bouton supprimer (✕)
|
||||
- Clic → vue détail
|
||||
|
||||
### Vue détail
|
||||
- Bouton "← Retour"
|
||||
- **Carte d'en-tête** :
|
||||
- Image + badge gen
|
||||
- Nom, cible × quantité, date
|
||||
- Barre de progression globale + pourcentage
|
||||
|
||||
**Section Matériaux de base (si présents) :**
|
||||
- Par matériau :
|
||||
- Nom de la race (coloré)
|
||||
- Mini barre de progression
|
||||
- Input de progression (nombre)
|
||||
- Label "X / Y"
|
||||
|
||||
**Sections par génération :**
|
||||
- En-tête "Génération X" (coloré)
|
||||
- Par croisement :
|
||||
- Nom race (coloré)
|
||||
- "ParentA × ParentB — X couples, repro ×Y"
|
||||
- Input de progression (nombre)
|
||||
- Label "X / Y"
|
||||
- Mini barre de progression
|
||||
|
||||
### Temps réel
|
||||
- La barre de progression globale se met à jour pendant la saisie
|
||||
- Les barres individuelles se mettent à jour en direct
|
||||
|
||||
---
|
||||
|
||||
## 10. Paramètres
|
||||
|
||||
### Carte 🔊 Son d'alarme
|
||||
- Select : Arpège, Pulsation, Fanfare, Cloche
|
||||
- Bouton ▶ (test du son sélectionné, joue directement via WebAudio)
|
||||
|
||||
### Carte 🔔 Notifications
|
||||
- **Bouton Notifs PC** : "🔔 Notifs PC activées" / "🔕 Notifs PC désactivées" (toggle)
|
||||
- **Bouton Mobile** : "📱 Mobile activé" / "📱 Activer mobile" (ouvre la modal)
|
||||
|
||||
### Modal ntfy (notifications mobiles)
|
||||
**Si non activé :**
|
||||
- Texte explicatif
|
||||
- Bouton "🔔 Activer les notifications mobiles" (génère un topic automatique)
|
||||
|
||||
**Si activé :**
|
||||
- ① QR code pour télécharger l'app ntfy (Play Store / App Store)
|
||||
- ② QR code pour s'abonner automatiquement aux notifications
|
||||
- Bouton "🔔 Tester" (envoie une notification de test)
|
||||
- Bouton "✕ Désactiver" (supprime le topic)
|
||||
- Bouton "Fermer"
|
||||
|
||||
---
|
||||
|
||||
## Comportements transversaux
|
||||
|
||||
### Focus/blur des inputs (tous les écrans)
|
||||
- Focus : vide le champ, sauvegarde la valeur précédente
|
||||
- Blur sans valeur : restaure la valeur précédente
|
||||
- Blur avec valeur : applique et sauvegarde
|
||||
- Escape : annule et restaure
|
||||
- Enter : valide (blur)
|
||||
|
||||
### Système de timer
|
||||
- Snapshot des jauges et stats au démarrage
|
||||
- Calcul par segments (recharges en cours de session)
|
||||
- Gel au cap absolu de chaque stat
|
||||
- Alarme unique quand toutes les cibles sont atteintes (son + notification PC + ntfy mobile)
|
||||
- Temps réel : requestAnimationFrame continu
|
||||
|
||||
### Persistance
|
||||
- Sauvegarde automatique après chaque mutation d'état
|
||||
- LocalStorage (web) ou fichier JSON (Electron userData)
|
||||
- Isolation des données DEV / production
|
||||
|
||||
### Drag-and-drop
|
||||
- Onglets enclos : réordonnancement par glisser-déposer
|
||||
- Cartes dragodindes : réordonnancement dans le même enclos
|
||||
2113
docs/plans/2026-03-27-ddd-architecture-plan.md
Normal file
2113
docs/plans/2026-03-27-ddd-architecture-plan.md
Normal file
File diff suppressed because it is too large
Load Diff
920
docs/plans/2026-04-04-accouplement-redesign.md
Normal file
920
docs/plans/2026-04-04-accouplement-redesign.md
Normal file
@@ -0,0 +1,920 @@
|
||||
# Refonte Graphique — Écran Accouplement
|
||||
|
||||
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
||||
|
||||
**Goal:** Refondre l'écran d'accouplement pour passer d'un wizard séquentiel à un layout single-page avec panneaux Parent 1 / Centre / Parent 2 + grille de races, style Obsidienne glassmorphism.
|
||||
|
||||
**Architecture:** Réécriture complète du HTML généré par `AccouplementView.ts` + remplacement des styles `.accoup-*` dans `components.css` par de nouveaux styles dans `obsidienne.css`. La logique métier (imports Race, CommandBus) reste identique.
|
||||
|
||||
**Tech Stack:** TypeScript, CSS (tokens Obsidienne/MD3), Material Symbols Outlined, `getDDImage()` helper existant.
|
||||
|
||||
---
|
||||
|
||||
### Task 1 : Nouveaux styles CSS Obsidienne pour l'accouplement
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/styles/obsidienne.css` (ajouter en fin de fichier)
|
||||
- Modify: `src/presentation/styles/components.css:314-401` (supprimer les anciens styles `.accoup-*`)
|
||||
|
||||
**Contexte:** La maquette utilise du glassmorphism (fond semi-transparent + backdrop-blur + bordure purple subtile), des `rounded-2xl` (16px), des chips pill pour les générations, et un layout grid 12 colonnes. On traduit tout ça en CSS vanilla avec les tokens `--md-*` déjà définis dans `variables.css`.
|
||||
|
||||
**Step 1 : Supprimer les anciens styles accouplement de components.css**
|
||||
|
||||
Supprimer les lignes 314-331 et 401 de `components.css` (tout ce qui commence par `.accoup-` et `.accouplement-view`).
|
||||
|
||||
**Step 2 : Ajouter les nouveaux styles dans obsidienne.css**
|
||||
|
||||
Ajouter en fin de fichier :
|
||||
|
||||
```css
|
||||
/* ── Accouplement View ── */
|
||||
.accoup-view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* Parent Selection Grid (3 columns: parent1 | center | parent2) */
|
||||
.accoup-parents {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
gap: 24px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.accoup-parent-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.accoup-parent-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.accoup-parent-title {
|
||||
font-family: 'Manrope', sans-serif;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 700;
|
||||
color: var(--md-on-surface);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.accoup-gender-badge {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.accoup-gender-badge.male {
|
||||
color: var(--md-secondary);
|
||||
background: rgba(134, 20, 90, 0.2);
|
||||
}
|
||||
.accoup-gender-badge.female {
|
||||
color: var(--md-primary);
|
||||
background: rgba(193, 133, 253, 0.2);
|
||||
}
|
||||
|
||||
/* Placeholder card (empty parent slot) */
|
||||
.accoup-placeholder {
|
||||
height: 180px;
|
||||
border-radius: 16px;
|
||||
background: rgba(23, 23, 33, 0.6);
|
||||
backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(168, 85, 247, 0.15);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.accoup-placeholder:hover {
|
||||
background: rgba(255, 255, 255, 0.07);
|
||||
}
|
||||
|
||||
.accoup-placeholder-inner {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.accoup-placeholder-icon {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 auto 10px;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
.accoup-placeholder:hover .accoup-placeholder-icon {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.accoup-placeholder-icon .material-symbols-outlined {
|
||||
font-size: 28px;
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.accoup-placeholder-text {
|
||||
font-size: 11px;
|
||||
color: var(--md-on-surface-variant);
|
||||
}
|
||||
|
||||
/* Selected parent card (replacing placeholder) */
|
||||
.accoup-selected-parent {
|
||||
height: 180px;
|
||||
border-radius: 16px;
|
||||
background: rgba(23, 23, 33, 0.6);
|
||||
backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(168, 85, 247, 0.3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
.accoup-selected-parent:hover {
|
||||
border-color: rgba(168, 85, 247, 0.5);
|
||||
}
|
||||
.accoup-selected-parent .race-card-avatar {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
}
|
||||
.accoup-selected-parent .race-card-avatar img {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
}
|
||||
.accoup-selected-parent-name {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: var(--md-on-surface);
|
||||
}
|
||||
.accoup-selected-parent-badge {
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
padding: 2px 8px;
|
||||
border-radius: 6px;
|
||||
color: #fff;
|
||||
}
|
||||
.accoup-selected-parent-clear {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: none;
|
||||
color: var(--md-on-surface-variant);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.accoup-selected-parent-clear:hover {
|
||||
background: rgba(255, 110, 132, 0.2);
|
||||
color: var(--md-error);
|
||||
}
|
||||
|
||||
/* Center pairing column */
|
||||
.accoup-center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
padding: 16px 0;
|
||||
min-width: 160px;
|
||||
}
|
||||
|
||||
.accoup-heart {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, var(--md-primary), var(--md-secondary));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4px 16px rgba(203, 151, 255, 0.2);
|
||||
}
|
||||
.accoup-heart .material-symbols-outlined {
|
||||
color: #000;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.accoup-center-inputs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.accoup-center-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.accoup-center-label {
|
||||
display: block;
|
||||
font-size: 10px;
|
||||
font-family: 'Manrope', sans-serif;
|
||||
font-weight: 700;
|
||||
color: var(--md-on-surface-variant);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.accoup-center-input {
|
||||
width: 100%;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 12px;
|
||||
padding: 8px 12px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--md-primary);
|
||||
outline: none;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.accoup-center-input:focus {
|
||||
border-color: var(--md-primary);
|
||||
box-shadow: 0 0 0 1px var(--md-primary);
|
||||
}
|
||||
.accoup-center-input.secondary {
|
||||
color: var(--md-secondary);
|
||||
}
|
||||
.accoup-center-input.secondary:focus {
|
||||
border-color: var(--md-secondary);
|
||||
box-shadow: 0 0 0 1px var(--md-secondary);
|
||||
}
|
||||
|
||||
.accoup-register-btn {
|
||||
padding: 10px 24px;
|
||||
background: linear-gradient(135deg, var(--md-primary), var(--md-primary-container));
|
||||
color: var(--md-on-primary);
|
||||
font-family: 'Manrope', sans-serif;
|
||||
font-weight: 800;
|
||||
font-size: 11px;
|
||||
border: none;
|
||||
border-radius: 9999px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 16px rgba(203, 151, 255, 0.3);
|
||||
transition: transform 0.1s, box-shadow 0.2s;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
.accoup-register-btn:hover {
|
||||
box-shadow: 0 6px 20px rgba(203, 151, 255, 0.4);
|
||||
}
|
||||
.accoup-register-btn:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
.accoup-register-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Grid panel (glass) */
|
||||
.accoup-grid-panel {
|
||||
background: rgba(23, 23, 33, 0.6);
|
||||
backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(168, 85, 247, 0.15);
|
||||
border-radius: 24px;
|
||||
padding: 24px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
/* Gen chips */
|
||||
.accoup-gen-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding-bottom: 20px;
|
||||
margin-bottom: 24px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.accoup-gen-chips-label {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
color: var(--md-on-surface-variant);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.accoup-gen-chip {
|
||||
padding: 6px 16px;
|
||||
border-radius: 9999px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
color: var(--md-on-surface-variant);
|
||||
transition: background 0.2s, color 0.2s;
|
||||
}
|
||||
.accoup-gen-chip:hover {
|
||||
color: var(--md-on-surface);
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
.accoup-gen-chip.active {
|
||||
background: var(--md-primary);
|
||||
color: var(--md-on-primary);
|
||||
}
|
||||
|
||||
/* Search (kept from existing, restyled) */
|
||||
.accoup-search-wrap {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.accoup-search {
|
||||
flex: 1;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 12px;
|
||||
color: var(--md-on-surface);
|
||||
padding: 10px 40px 10px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
.accoup-search:focus {
|
||||
border-color: var(--md-primary);
|
||||
}
|
||||
.accoup-search-clear {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--md-on-surface-variant);
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
padding: 4px;
|
||||
transition: color 0.15s;
|
||||
}
|
||||
.accoup-search-clear:hover {
|
||||
color: var(--md-on-surface);
|
||||
}
|
||||
|
||||
/* Dragon cards grid */
|
||||
.accoup-race-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.accoup-race-card {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 16px;
|
||||
padding: 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
|
||||
text-align: center;
|
||||
}
|
||||
.accoup-race-card:hover {
|
||||
border-color: rgba(203, 151, 255, 0.4);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.accoup-race-card.selecting {
|
||||
border-color: rgba(203, 151, 255, 0.15);
|
||||
}
|
||||
.accoup-race-card.selecting:hover {
|
||||
border-color: rgba(203, 151, 255, 0.5);
|
||||
}
|
||||
|
||||
.accoup-race-card-img {
|
||||
position: relative;
|
||||
aspect-ratio: 1;
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.accoup-race-card-img .race-card-avatar {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
.accoup-race-card:hover .race-card-avatar {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.accoup-race-card-img .race-card-avatar img {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
}
|
||||
|
||||
.accoup-race-card-gen {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 6px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
font-size: 8px;
|
||||
font-weight: 700;
|
||||
color: var(--md-tertiary, #ffe083);
|
||||
}
|
||||
|
||||
.accoup-race-card-name {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: var(--md-on-surface);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.accoup-race-card-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.accoup-race-card-sub {
|
||||
font-size: 9px;
|
||||
color: var(--md-on-surface-variant);
|
||||
}
|
||||
|
||||
/* Empty state */
|
||||
.accoup-empty {
|
||||
text-align: center;
|
||||
color: var(--md-on-surface-variant);
|
||||
padding: 40px;
|
||||
font-style: italic;
|
||||
font-size: 13px;
|
||||
}
|
||||
```
|
||||
|
||||
**Step 3 : Vérifier le build**
|
||||
|
||||
Run: `npm run build` (depuis Windows)
|
||||
Expected: Build réussi sans erreur CSS.
|
||||
|
||||
**Step 4 : Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/styles/obsidienne.css src/presentation/styles/components.css
|
||||
git commit -m "refactor(accouplement): remplace anciens styles par design Obsidienne glassmorphism"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2 : Réécriture du HTML — layout single-page avec panneaux parents + grille
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/components/AccouplementView.ts` (réécriture complète du rendering)
|
||||
|
||||
**Contexte:** On remplace le wizard 3 étapes par un layout unique :
|
||||
- **Haut** : grille 3 colonnes (Parent 1 | Centre cœur+inputs+register | Parent 2)
|
||||
- **Bas** : panneau glass avec chips génération + recherche + grille de races
|
||||
- Quand on clique une race, elle remplit le slot parent approprié (P1 si vide, sinon P2)
|
||||
- Quand les 2 parents sont sélectionnés, le bouton Enregistrer devient actif
|
||||
|
||||
**Step 1 : Réécrire le state et la structure**
|
||||
|
||||
Remplacer l'interface `AccoupState` et toute la classe :
|
||||
|
||||
```typescript
|
||||
import type { CommandBus } from '@application/handlers/CommandBus';
|
||||
import type { QueryBus } from '@application/handlers/QueryBus';
|
||||
import { RACES_DATA, GEN_COLORS, RACE_GEN, BREEDING_BY_PARENTS, COMPATIBLE_PARTNERS, raceColor } from '@domain/value-objects/Race';
|
||||
import { getDDImage } from '@presentation/helpers/dd-image';
|
||||
import { esc } from '@presentation/helpers/format';
|
||||
|
||||
interface AccoupState {
|
||||
parent1: string | null;
|
||||
parent2: string | null;
|
||||
filterGen: number | null;
|
||||
search: string;
|
||||
couples: string;
|
||||
babies: string;
|
||||
selectingSlot: 1 | 2;
|
||||
}
|
||||
|
||||
export class AccouplementView {
|
||||
private el: HTMLElement | null = null;
|
||||
private accoupState: AccoupState = {
|
||||
parent1: null, parent2: null,
|
||||
filterGen: null, search: '',
|
||||
couples: '', babies: '',
|
||||
selectingSlot: 1,
|
||||
};
|
||||
private dirty = true;
|
||||
|
||||
constructor(
|
||||
private commandBus: CommandBus,
|
||||
private queryBus: QueryBus,
|
||||
) {}
|
||||
|
||||
render(container: HTMLElement): void {
|
||||
this.el = document.createElement('div');
|
||||
this.el.className = 'accoup-view';
|
||||
container.appendChild(this.el);
|
||||
this.dirty = true;
|
||||
this.update();
|
||||
}
|
||||
|
||||
update(): void {
|
||||
if (!this.el || !this.dirty) return;
|
||||
this.dirty = false;
|
||||
this.renderSinglePage();
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.el?.remove();
|
||||
this.el = null;
|
||||
}
|
||||
|
||||
/* ── All races list (cached) ── */
|
||||
private getAllRaces(): { name: string; gen: number }[] {
|
||||
const all: { name: string; gen: number }[] = [];
|
||||
for (const base of ['Rousse', 'Amande', 'Dorée'])
|
||||
all.push({ name: base, gen: 1 });
|
||||
for (const [g, rs] of Object.entries(RACES_DATA))
|
||||
for (const r of rs)
|
||||
all.push({ name: r.name, gen: parseInt(g) });
|
||||
return all;
|
||||
}
|
||||
|
||||
/* ── Filtered races based on gen filter, search, and partner compatibility ── */
|
||||
private getFilteredRaces(): { name: string; gen: number }[] {
|
||||
const { filterGen, search, parent1, selectingSlot } = this.accoupState;
|
||||
let races = this.getAllRaces();
|
||||
|
||||
// If selecting parent 2, only show compatible partners
|
||||
if (selectingSlot === 2 && parent1) {
|
||||
const partners = COMPATIBLE_PARTNERS[parent1] ?? [];
|
||||
const partnerNames = new Set(partners.map(p => p.partner));
|
||||
races = races.filter(r => partnerNames.has(r.name));
|
||||
}
|
||||
|
||||
const q = search.trim().toLowerCase();
|
||||
return races.filter(r =>
|
||||
(filterGen ? r.gen === filterGen : true) &&
|
||||
(q ? r.name.toLowerCase().includes(q) : true)
|
||||
);
|
||||
}
|
||||
|
||||
/* ── Baby name from parents ── */
|
||||
private getBabyName(): string | null {
|
||||
const { parent1, parent2 } = this.accoupState;
|
||||
if (!parent1 || !parent2) return null;
|
||||
return BREEDING_BY_PARENTS[parent1 + '|' + parent2] ?? null;
|
||||
}
|
||||
|
||||
/* ── Single page render ── */
|
||||
private renderSinglePage(): void {
|
||||
if (!this.el) return;
|
||||
const { parent1, parent2, filterGen, search, couples, babies, selectingSlot } = this.accoupState;
|
||||
const baby = this.getBabyName();
|
||||
const hasBoth = !!(parent1 && parent2 && baby);
|
||||
|
||||
let html = '';
|
||||
|
||||
/* ── Parent panels row ── */
|
||||
html += `<div class="accoup-parents">`;
|
||||
|
||||
// Parent 1 section
|
||||
html += `<section class="accoup-parent-section">`;
|
||||
html += `<div class="accoup-parent-header">
|
||||
<span class="accoup-parent-title">Parent 1</span>
|
||||
<span class="accoup-gender-badge male">MÂLE REQUIS</span>
|
||||
</div>`;
|
||||
if (parent1) {
|
||||
const gen1 = RACE_GEN[parent1] ?? 1;
|
||||
html += `<div class="accoup-selected-parent" data-clear="1">
|
||||
${getDDImage(parent1)}
|
||||
<span class="accoup-selected-parent-name">${esc(parent1)}</span>
|
||||
<span class="accoup-selected-parent-badge" style="background:${GEN_COLORS[gen1] ?? '#888'}">Gen ${gen1}</span>
|
||||
<button class="accoup-selected-parent-clear" data-clear="1" title="Retirer">
|
||||
<span class="material-symbols-outlined" style="font-size:14px">close</span>
|
||||
</button>
|
||||
</div>`;
|
||||
} else {
|
||||
html += `<div class="accoup-placeholder" data-select-slot="1">
|
||||
<div class="accoup-placeholder-inner">
|
||||
<div class="accoup-placeholder-icon">
|
||||
<span class="material-symbols-outlined" style="color:var(--md-primary)">add</span>
|
||||
</div>
|
||||
<p class="accoup-placeholder-text">Cliquer pour choisir un mâle</p>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
html += `</section>`;
|
||||
|
||||
// Center column
|
||||
html += `<div class="accoup-center">`;
|
||||
html += `<div class="accoup-heart">
|
||||
<span class="material-symbols-outlined mso-fill">favorite</span>
|
||||
</div>`;
|
||||
html += `<div class="accoup-center-inputs">
|
||||
<div class="accoup-center-field">
|
||||
<label class="accoup-center-label">Nombre de couples</label>
|
||||
<input class="accoup-center-input" id="accoup-couples" type="number" min="1" value="${esc(couples)}" placeholder="1">
|
||||
</div>
|
||||
<div class="accoup-center-field">
|
||||
<label class="accoup-center-label">Bébés obtenus</label>
|
||||
<input class="accoup-center-input secondary" id="accoup-babies" type="number" min="0" value="${esc(babies)}" placeholder="0">
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
// Baby preview (if both parents selected)
|
||||
if (hasBoth && baby) {
|
||||
const babyGen = RACE_GEN[baby] ?? 0;
|
||||
html += `<div style="text-align:center;margin-top:4px">
|
||||
<div style="font-size:10px;color:var(--md-on-surface-variant);text-transform:uppercase;letter-spacing:0.08em;margin-bottom:6px">Résultat</div>
|
||||
${getDDImage(baby)}
|
||||
<div style="font-size:12px;font-weight:700;color:var(--md-on-surface);margin-top:4px">${esc(baby)}</div>
|
||||
<span class="accoup-selected-parent-badge" style="background:${GEN_COLORS[babyGen] ?? '#888'};font-size:8px">Gen ${babyGen}</span>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
html += `<button class="accoup-register-btn" id="accoup-register" ${hasBoth ? '' : 'disabled'}>ENREGISTRER</button>`;
|
||||
html += `</div>`;
|
||||
|
||||
// Parent 2 section
|
||||
html += `<section class="accoup-parent-section">`;
|
||||
html += `<div class="accoup-parent-header">
|
||||
<span class="accoup-parent-title">Parent 2</span>
|
||||
<span class="accoup-gender-badge female">FEMELLE REQUISE</span>
|
||||
</div>`;
|
||||
if (parent2) {
|
||||
const gen2 = RACE_GEN[parent2] ?? 1;
|
||||
html += `<div class="accoup-selected-parent" data-clear="2">
|
||||
${getDDImage(parent2)}
|
||||
<span class="accoup-selected-parent-name">${esc(parent2)}</span>
|
||||
<span class="accoup-selected-parent-badge" style="background:${GEN_COLORS[gen2] ?? '#888'}">Gen ${gen2}</span>
|
||||
<button class="accoup-selected-parent-clear" data-clear="2" title="Retirer">
|
||||
<span class="material-symbols-outlined" style="font-size:14px">close</span>
|
||||
</button>
|
||||
</div>`;
|
||||
} else {
|
||||
html += `<div class="accoup-placeholder" data-select-slot="2">
|
||||
<div class="accoup-placeholder-inner">
|
||||
<div class="accoup-placeholder-icon">
|
||||
<span class="material-symbols-outlined" style="color:var(--md-secondary)">add</span>
|
||||
</div>
|
||||
<p class="accoup-placeholder-text">Cliquer pour choisir une femelle</p>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
html += `</section>`;
|
||||
html += `</div>`; // .accoup-parents
|
||||
|
||||
/* ── Grid panel ── */
|
||||
html += `<div class="accoup-grid-panel">`;
|
||||
|
||||
// Gen chips
|
||||
html += `<div class="accoup-gen-chips">`;
|
||||
html += `<span class="accoup-gen-chips-label">Générations</span>`;
|
||||
html += `<button class="accoup-gen-chip${filterGen === null ? ' active' : ''}" data-gen="all">Toutes</button>`;
|
||||
for (let g = 1; g <= 10; g++) {
|
||||
html += `<button class="accoup-gen-chip${filterGen === g ? ' active' : ''}" data-gen="${g}">Gen ${g}</button>`;
|
||||
}
|
||||
html += `</div>`;
|
||||
|
||||
// Search
|
||||
html += `<div class="accoup-search-wrap">
|
||||
<input class="accoup-search" id="accoup-search-input" type="text"
|
||||
placeholder="Rechercher une race…" value="${esc(search)}" autocomplete="off">
|
||||
${search ? `<button class="accoup-search-clear" title="Effacer"><span class="material-symbols-outlined" style="font-size:16px">close</span></button>` : ''}
|
||||
</div>`;
|
||||
|
||||
// Race grid
|
||||
const filtered = this.getFilteredRaces();
|
||||
if (filtered.length === 0) {
|
||||
html += `<div class="accoup-empty">Aucune race trouvée</div>`;
|
||||
} else {
|
||||
const selecting = (!parent1 || !parent2);
|
||||
html += `<div class="accoup-race-grid">`;
|
||||
for (const race of filtered) {
|
||||
const genCol = GEN_COLORS[race.gen] ?? '#888';
|
||||
html += `<div class="accoup-race-card${selecting ? ' selecting' : ''}" data-race="${esc(race.name)}">
|
||||
<div class="accoup-race-card-img">
|
||||
${getDDImage(race.name)}
|
||||
<div class="accoup-race-card-gen" style="color:${genCol}">GEN ${race.gen}</div>
|
||||
</div>
|
||||
<div class="accoup-race-card-name">${esc(race.name)}</div>
|
||||
</div>`;
|
||||
}
|
||||
html += `</div>`;
|
||||
}
|
||||
|
||||
html += `</div>`; // .accoup-grid-panel
|
||||
|
||||
this.el.innerHTML = html;
|
||||
this.bindEvents();
|
||||
|
||||
// Restore search focus if active
|
||||
if (search) {
|
||||
const inp = this.el.querySelector<HTMLInputElement>('#accoup-search-input');
|
||||
if (inp) { inp.focus(); inp.setSelectionRange(inp.value.length, inp.value.length); }
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Event binding ── */
|
||||
private bindEvents(): void {
|
||||
if (!this.el) return;
|
||||
|
||||
// Gen chips
|
||||
this.el.querySelectorAll('.accoup-gen-chip').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
const val = (btn as HTMLElement).dataset.gen;
|
||||
this.accoupState.filterGen = val === 'all' ? null : parseInt(val!);
|
||||
this.dirty = true; this.update();
|
||||
});
|
||||
});
|
||||
|
||||
// Search
|
||||
const searchInput = this.el.querySelector<HTMLInputElement>('#accoup-search-input');
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener('input', () => {
|
||||
this.accoupState.search = searchInput.value;
|
||||
this.dirty = true; this.update();
|
||||
});
|
||||
}
|
||||
const clearBtn = this.el.querySelector('.accoup-search-clear');
|
||||
if (clearBtn) {
|
||||
clearBtn.addEventListener('click', () => {
|
||||
this.accoupState.search = '';
|
||||
this.dirty = true; this.update();
|
||||
});
|
||||
}
|
||||
|
||||
// Placeholder clicks (select slot)
|
||||
this.el.querySelectorAll<HTMLElement>('[data-select-slot]').forEach(ph => {
|
||||
ph.addEventListener('click', () => {
|
||||
this.accoupState.selectingSlot = parseInt(ph.dataset.selectSlot!) as 1 | 2;
|
||||
// No re-render needed, just changes which slot gets filled
|
||||
});
|
||||
});
|
||||
|
||||
// Clear parent buttons
|
||||
this.el.querySelectorAll<HTMLElement>('[data-clear]').forEach(btn => {
|
||||
if (btn.tagName === 'BUTTON') {
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const slot = parseInt(btn.dataset.clear!);
|
||||
if (slot === 1) {
|
||||
this.accoupState.parent1 = null;
|
||||
this.accoupState.parent2 = null; // Reset P2 too since partners depend on P1
|
||||
this.accoupState.selectingSlot = 1;
|
||||
} else {
|
||||
this.accoupState.parent2 = null;
|
||||
this.accoupState.selectingSlot = 2;
|
||||
}
|
||||
this.dirty = true; this.update();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Race card clicks
|
||||
this.el.querySelectorAll<HTMLElement>('.accoup-race-card').forEach(card => {
|
||||
card.addEventListener('click', () => {
|
||||
const race = card.dataset.race!;
|
||||
if (!this.accoupState.parent1) {
|
||||
this.accoupState.parent1 = race;
|
||||
this.accoupState.selectingSlot = 2;
|
||||
this.accoupState.filterGen = null;
|
||||
this.accoupState.search = '';
|
||||
} else if (!this.accoupState.parent2) {
|
||||
this.accoupState.parent2 = race;
|
||||
}
|
||||
this.dirty = true; this.update();
|
||||
});
|
||||
});
|
||||
|
||||
// Couples / babies inputs
|
||||
const couplesInput = this.el.querySelector<HTMLInputElement>('#accoup-couples');
|
||||
const babiesInput = this.el.querySelector<HTMLInputElement>('#accoup-babies');
|
||||
if (couplesInput) {
|
||||
let prev = couplesInput.value;
|
||||
couplesInput.addEventListener('focus', () => { prev = couplesInput.value; couplesInput.value = ''; });
|
||||
couplesInput.addEventListener('blur', () => {
|
||||
if (couplesInput.value === '') couplesInput.value = prev;
|
||||
this.accoupState.couples = couplesInput.value;
|
||||
});
|
||||
}
|
||||
if (babiesInput) {
|
||||
let prev = babiesInput.value;
|
||||
babiesInput.addEventListener('focus', () => { prev = babiesInput.value; babiesInput.value = ''; });
|
||||
babiesInput.addEventListener('blur', () => {
|
||||
if (babiesInput.value === '') babiesInput.value = prev;
|
||||
this.accoupState.babies = babiesInput.value;
|
||||
});
|
||||
}
|
||||
|
||||
// Register button
|
||||
const registerBtn = this.el.querySelector('#accoup-register');
|
||||
if (registerBtn) {
|
||||
registerBtn.addEventListener('click', () => {
|
||||
const { parent1, parent2 } = this.accoupState;
|
||||
if (!parent1 || !parent2) return;
|
||||
const baby = BREEDING_BY_PARENTS[parent1 + '|' + parent2] ?? '';
|
||||
if (!baby) return;
|
||||
const c = parseInt(this.accoupState.couples) || 0;
|
||||
const b = parseInt(this.accoupState.babies) || 0;
|
||||
if (c <= 0) return;
|
||||
|
||||
this.commandBus.execute({
|
||||
type: 'register-accouplement',
|
||||
parent1,
|
||||
parent2,
|
||||
baby,
|
||||
gen: RACE_GEN[baby] ?? 0,
|
||||
couples: c,
|
||||
babiesObtained: b,
|
||||
});
|
||||
|
||||
// Reset
|
||||
this.accoupState = {
|
||||
parent1: null, parent2: null,
|
||||
filterGen: null, search: '',
|
||||
couples: '', babies: '',
|
||||
selectingSlot: 1,
|
||||
};
|
||||
this.dirty = true; this.update();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2 : Vérifier la compilation**
|
||||
|
||||
Run: `npm run build` (depuis Windows)
|
||||
Expected: Build réussi, pas d'erreurs TypeScript.
|
||||
|
||||
**Step 3 : Tester visuellement**
|
||||
|
||||
Run: `npm start`
|
||||
- Naviguer vers l'écran Accouplement
|
||||
- Vérifier le layout 3 colonnes (Parent 1 | Cœur+inputs | Parent 2)
|
||||
- Cliquer une race → remplit Parent 1
|
||||
- La grille se filtre pour montrer les partenaires compatibles
|
||||
- Cliquer un partenaire → remplit Parent 2
|
||||
- Le bébé apparaît au centre + bouton Enregistrer actif
|
||||
- Le bouton × vide un parent
|
||||
- Les chips génération et la recherche fonctionnent
|
||||
|
||||
**Step 4 : Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/components/AccouplementView.ts
|
||||
git commit -m "feat(accouplement): refonte layout single-page Obsidienne avec panneaux parents"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3 : Nettoyage et polish
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/styles/components.css` (vérifier qu'il ne reste rien d'accoup)
|
||||
- Verify: `src/presentation/components/AccouplementView.ts`
|
||||
|
||||
**Step 1 : Vérifier qu'aucun ancien style `.accoup-*` ne reste dans components.css**
|
||||
|
||||
Chercher `accoup` dans `components.css`. Si des restes existent, les supprimer.
|
||||
|
||||
**Step 2 : Vérifier que le flow complet fonctionne**
|
||||
|
||||
Test manuel :
|
||||
1. Sélectionner "Rousse" → P1 se remplit, grille montre partenaires compatibles
|
||||
2. Sélectionner un partenaire → P2 se remplit, bébé apparaît au centre
|
||||
3. Entrer couples=2, bébés=1
|
||||
4. Cliquer "Enregistrer" → reset complet
|
||||
5. Bouton × sur P1 → reset P1 et P2
|
||||
6. Bouton × sur P2 → reset P2 seulement
|
||||
7. Filtrer par Gen 2 → seules les races Gen 2 apparaissent
|
||||
8. Rechercher "Rou" → filtre textuel fonctionne
|
||||
|
||||
**Step 3 : Commit final**
|
||||
|
||||
```bash
|
||||
git add -A
|
||||
git commit -m "chore(accouplement): nettoyage styles et polish refonte"
|
||||
```
|
||||
62
docs/plans/2026-04-04-electron-updater-design.md
Normal file
62
docs/plans/2026-04-04-electron-updater-design.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Migration electron-updater + Gitea — Design
|
||||
|
||||
## Objectif
|
||||
|
||||
Remplacer le système de mise à jour custom (download HTTP manuel + script batch NSIS) par `electron-updater`, tout en conservant Gitea comme hébergeur de releases.
|
||||
|
||||
## Contrainte Gitea
|
||||
|
||||
Gitea ne supporte pas l'URL `/releases/latest/download/{filename}` (issue #31408 ouverte). On utilise donc une approche hybride :
|
||||
1. Appel API Gitea pour découvrir la dernière version
|
||||
2. `electron-updater` (generic provider) pour le cycle download → vérification sha512 → installation NSIS → restart
|
||||
|
||||
## Workflow de release
|
||||
|
||||
1. `npm run build` → génère `.exe` + `latest.yml` dans `dist/`
|
||||
2. Créer le tag git, push
|
||||
3. Sur Gitea : créer la release, uploader le `.exe` ET `latest.yml`
|
||||
|
||||
## Architecture
|
||||
|
||||
### Flux côté app
|
||||
|
||||
```
|
||||
Démarrage (3s) → GET /api/v1/repos/mickael/dd-timer/releases/latest
|
||||
→ Compare versions (tag_name vs app.getVersion())
|
||||
→ Si update dispo :
|
||||
autoUpdater.setFeedURL({
|
||||
provider: "generic",
|
||||
url: "https://gitea.mickael-pol.fr/mickael/dd-timer/releases/download/{tag}/"
|
||||
})
|
||||
autoUpdater.checkForUpdates()
|
||||
→ electron-updater lit latest.yml
|
||||
→ Télécharge le .exe (download-progress events)
|
||||
→ update-downloaded → prêt à installer
|
||||
→ quitAndInstall() au clic utilisateur
|
||||
```
|
||||
|
||||
### Changements par fichier
|
||||
|
||||
| Fichier | Action |
|
||||
|---------|--------|
|
||||
| `package.json` | Ajouter `electron-updater` dep + config `publish` generic |
|
||||
| `main.ts` | Supprimer download HTTP, redirections, script batch. Garder appel API Gitea. Ajouter autoUpdater events. |
|
||||
| `preload.ts` | Inchangé (mêmes IPC channels) |
|
||||
| `UpdateBanner.ts` | Inchangé |
|
||||
|
||||
### IPC channels (conservés)
|
||||
|
||||
- `update-available` → bannière disponible
|
||||
- `update-downloading` → bannière téléchargement
|
||||
- `update-progress` → { percent }
|
||||
- `update-ready` → bouton "Installer et redémarrer"
|
||||
- `update-error` → message erreur
|
||||
- `install-update` → déclenche quitAndInstall()
|
||||
|
||||
## Avantages
|
||||
|
||||
- Suppression du script batch hack (~80 lignes)
|
||||
- Vérification d'intégrité sha512 automatique
|
||||
- Gestion NSIS install + restart native
|
||||
- Code main.ts simplifié (~40 lignes vs ~200)
|
||||
- Zéro infra supplémentaire
|
||||
390
docs/plans/2026-04-04-electron-updater-implementation.md
Normal file
390
docs/plans/2026-04-04-electron-updater-implementation.md
Normal file
@@ -0,0 +1,390 @@
|
||||
# Migration electron-updater + Gitea — Implementation Plan
|
||||
|
||||
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
||||
|
||||
**Goal:** Remplacer le système de mise à jour custom (download HTTP + script batch) par `electron-updater`, en gardant Gitea comme source de releases.
|
||||
|
||||
**Architecture:** Approche hybride — appel API Gitea pour découvrir la dernière version (car Gitea n'a pas d'URL fixe "latest"), puis `electron-updater` (generic provider) pour le cycle download → vérification sha512 → installation NSIS → restart. Les IPC channels restent identiques pour que `UpdateBanner.ts` et `preload.ts` n'aient aucun changement.
|
||||
|
||||
**Tech Stack:** electron-updater 6.x, Electron 32.x, TypeScript
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Installer electron-updater et configurer package.json
|
||||
|
||||
**Files:**
|
||||
- Modify: `package.json`
|
||||
|
||||
**Step 1: Installer la dépendance**
|
||||
|
||||
```bash
|
||||
npm install electron-updater
|
||||
```
|
||||
|
||||
> `electron-updater` doit être dans `dependencies` (pas `devDependencies`) car il tourne dans l'app packagée.
|
||||
|
||||
**Step 2: Ajouter la config `publish` dans la section `build`**
|
||||
|
||||
Dans `package.json`, ajouter dans `"build"` :
|
||||
|
||||
```json
|
||||
"publish": {
|
||||
"provider": "generic",
|
||||
"url": "https://gitea.mickael-pol.fr/mickael/dd-timer/releases/download/latest"
|
||||
}
|
||||
```
|
||||
|
||||
> Cette URL est un placeholder — au runtime, on la remplace dynamiquement via `setFeedURL()`.
|
||||
> Son seul rôle est de déclencher la génération de `latest.yml` par electron-builder.
|
||||
|
||||
**Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add package.json package-lock.json
|
||||
git commit -m "chore: add electron-updater dependency + publish config"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: Réécrire la section mise à jour dans main.ts
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/infrastructure/electron/main.ts:1-16` (imports)
|
||||
- Modify: `src/infrastructure/electron/main.ts:37-48` (UpdateInfo + state vars)
|
||||
- Delete: `src/infrastructure/electron/main.ts:254-450` (tout le bloc update custom)
|
||||
- Add: nouveau bloc update avec electron-updater (~60 lignes)
|
||||
|
||||
**Step 1: Ajouter l'import electron-updater, supprimer les imports inutiles**
|
||||
|
||||
Remplacer les imports en haut du fichier :
|
||||
|
||||
```typescript
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
Tray,
|
||||
Menu,
|
||||
nativeImage,
|
||||
ipcMain,
|
||||
Notification,
|
||||
dialog,
|
||||
} from 'electron';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
```
|
||||
|
||||
> Supprimer : `import https from 'https'`, `import http from 'http'`, `import os from 'os'`, `import { spawn } from 'child_process'` — ils ne sont plus nécessaires pour les mises à jour.
|
||||
>
|
||||
> **Attention** : `https` et `http` sont encore utilisés par le bloc ntfy (lignes 214-243). Vérifier si d'autres usages existent avant de supprimer. Si ntfy les utilise → garder `https` et `http`. Supprimer seulement `os` et `spawn` si plus aucun usage.
|
||||
|
||||
**Step 2: Simplifier les variables d'état**
|
||||
|
||||
Remplacer l'interface `UpdateInfo` et les variables `updateInfo` / `downloading` :
|
||||
|
||||
```typescript
|
||||
interface UpdateInfo {
|
||||
version: string;
|
||||
}
|
||||
|
||||
let updateInfo: UpdateInfo | null = null;
|
||||
```
|
||||
|
||||
> On supprime `downloadUrl`, `assetName`, `releaseNotes` — electron-updater gère tout ça.
|
||||
> On supprime `downloading` — electron-updater gère l'état.
|
||||
|
||||
**Step 3: Supprimer tout le bloc update custom**
|
||||
|
||||
Supprimer entièrement (lignes 254-450) :
|
||||
- `compareVersions()`
|
||||
- Interfaces `GiteaAsset`, `GiteaRelease`
|
||||
- `checkForUpdates()`
|
||||
- `startDownload()`
|
||||
- `sendUpdateError()`
|
||||
- `launchUpdater()`
|
||||
|
||||
**Step 4: Écrire le nouveau système de mise à jour**
|
||||
|
||||
Ajouter à la place du code supprimé :
|
||||
|
||||
```typescript
|
||||
// ─── COMPARAISON DE VERSIONS ────────────────────────────────────────────────
|
||||
function compareVersions(a: string, b: string): number {
|
||||
const pa = a.replace(/^v/, '').split('.').map(Number);
|
||||
const pb = b.replace(/^v/, '').split('.').map(Number);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if ((pb[i] || 0) > (pa[i] || 0)) return 1;
|
||||
if ((pb[i] || 0) < (pa[i] || 0)) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ─── ELECTRON-UPDATER : CONFIGURATION ───────────────────────────────────────
|
||||
autoUpdater.autoDownload = true;
|
||||
autoUpdater.autoInstallOnAppQuit = false;
|
||||
|
||||
// ─── ELECTRON-UPDATER : EVENTS ──────────────────────────────────────────────
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
updateInfo = { version: info.version };
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update-available', updateInfo);
|
||||
}
|
||||
fireNotification(
|
||||
`Mise a jour v${info.version} disponible !`,
|
||||
'Téléchargement en cours...'
|
||||
);
|
||||
rebuildTrayMenu();
|
||||
});
|
||||
|
||||
autoUpdater.on('download-progress', (progress) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update-progress', { percent: Math.round(progress.percent) });
|
||||
}
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update-ready', updateInfo ?? {});
|
||||
}
|
||||
});
|
||||
|
||||
autoUpdater.on('error', (err) => {
|
||||
console.error('Update error:', err.message);
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update-error', { message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// ─── VÉRIFICATION VIA API GITEA ─────────────────────────────────────────────
|
||||
function checkForUpdates(silent = false): void {
|
||||
const https = require('https') as typeof import('https');
|
||||
const options: import('https').RequestOptions = {
|
||||
hostname: GITEA_HOST,
|
||||
port: 443,
|
||||
path: `/api/v1/repos/${GITEA_USER}/${GITEA_REPO}/releases?limit=1`,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'User-Agent': `MinuteurDragodinde/${CURRENT_VERSION}`,
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
const req = https.request(options, (res) => {
|
||||
let data = '';
|
||||
res.on('data', (chunk: string) => { data += chunk; });
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const releases = JSON.parse(data);
|
||||
if (!Array.isArray(releases) || releases.length === 0) return;
|
||||
const release = releases[0];
|
||||
const latestVersion = release.tag_name;
|
||||
if (!latestVersion || compareVersions(CURRENT_VERSION, latestVersion) <= 0) {
|
||||
if (!silent && mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update-not-available');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Pointer electron-updater vers le tag de la release
|
||||
const tag = latestVersion.startsWith('v') ? latestVersion : `v${latestVersion}`;
|
||||
autoUpdater.setFeedURL({
|
||||
provider: 'generic',
|
||||
url: `https://${GITEA_HOST}/${GITEA_USER}/${GITEA_REPO}/releases/download/${tag}`,
|
||||
});
|
||||
|
||||
// electron-updater prend le relais : lit latest.yml, télécharge, vérifie
|
||||
autoUpdater.checkForUpdates();
|
||||
} catch (e: unknown) {
|
||||
console.error('Update check parse error:', (e as Error).message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (e: Error) => console.error('Update check error:', e.message));
|
||||
req.end();
|
||||
}
|
||||
```
|
||||
|
||||
**Step 5: Mettre à jour le handler `install-update`**
|
||||
|
||||
Remplacer :
|
||||
```typescript
|
||||
ipcMain.on('install-update', () => startDownload());
|
||||
```
|
||||
|
||||
Par :
|
||||
```typescript
|
||||
ipcMain.on('install-update', () => {
|
||||
autoUpdater.quitAndInstall(true, true);
|
||||
});
|
||||
```
|
||||
|
||||
> `quitAndInstall(isSilent, isForceRunAfter)` : installe en silencieux et relance l'app.
|
||||
|
||||
**Step 6: Mettre à jour le tray menu**
|
||||
|
||||
Dans `rebuildTrayMenu()`, remplacer le click du menu update :
|
||||
|
||||
```typescript
|
||||
if (updateInfo) {
|
||||
items.push({ type: 'separator' });
|
||||
items.push({
|
||||
label: `⬆ Mise a jour v${updateInfo.version} disponible !`,
|
||||
click: () => autoUpdater.quitAndInstall(true, true),
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
**Step 7: Simplifier le bloc did-finish-load**
|
||||
|
||||
Le bloc `did-finish-load` (ligne 115-133) reste identique — il envoie déjà `update-available` si `updateInfo` existe.
|
||||
|
||||
**Step 8: Commit**
|
||||
|
||||
```bash
|
||||
git add src/infrastructure/electron/main.ts
|
||||
git commit -m "feat: migrate update system to electron-updater"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: Vérifier que preload.ts et UpdateBanner.ts n'ont pas besoin de changement
|
||||
|
||||
**Files:**
|
||||
- Read: `src/infrastructure/electron/preload.ts`
|
||||
- Read: `src/presentation/components/UpdateBanner.ts`
|
||||
|
||||
**Step 1: Vérifier les IPC channels**
|
||||
|
||||
Les channels IPC n'ont pas changé :
|
||||
- `update-available` → `{ version }` ✓
|
||||
- `update-downloading` → **ATTENTION** : l'ancien code envoyait `update-downloading`, mais electron-updater n'a pas cet event. Il passe directement de `update-available` à `download-progress`. Le banner state `downloading` est activé par `onUpdateDownloading` OU `onUpdateProgress`. Vérifier que `UpdateBanner` gère bien la transition.
|
||||
|
||||
**Step 2: Envoyer `update-downloading` explicitement**
|
||||
|
||||
Dans les events autoUpdater, ajouter après `update-available` :
|
||||
|
||||
```typescript
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
updateInfo = { version: info.version };
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update-available', updateInfo);
|
||||
// Envoyer aussi downloading car autoDownload = true
|
||||
mainWindow.webContents.send('update-downloading', { version: info.version });
|
||||
}
|
||||
fireNotification(
|
||||
`Mise a jour v${info.version} disponible !`,
|
||||
'Téléchargement en cours...'
|
||||
);
|
||||
rebuildTrayMenu();
|
||||
});
|
||||
```
|
||||
|
||||
> Cela garantit que `UpdateBanner` passe bien en état `downloading` comme avant.
|
||||
|
||||
**Step 3: Commit (si changement)**
|
||||
|
||||
```bash
|
||||
git add src/infrastructure/electron/main.ts
|
||||
git commit -m "fix: send update-downloading event for banner compatibility"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: Vérifier la génération de latest.yml
|
||||
|
||||
**Step 1: Lancer un build**
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
**Step 2: Vérifier que `dist/latest.yml` existe**
|
||||
|
||||
```bash
|
||||
ls dist/latest.yml
|
||||
cat dist/latest.yml
|
||||
```
|
||||
|
||||
Contenu attendu (exemple) :
|
||||
```yaml
|
||||
version: 1.1.5
|
||||
files:
|
||||
- url: Minuteur-Dragodinde-Setup-1.1.5.exe
|
||||
sha512: <hash>
|
||||
size: <size>
|
||||
path: Minuteur-Dragodinde-Setup-1.1.5.exe
|
||||
sha512: <hash>
|
||||
releaseDate: '2026-04-04T...'
|
||||
```
|
||||
|
||||
**Step 3: Vérifier que le .exe est aussi généré**
|
||||
|
||||
```bash
|
||||
ls dist/Minuteur-Dragodinde-Setup-*.exe
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: Mettre à jour le CHANGELOG
|
||||
|
||||
**Files:**
|
||||
- Modify: `CHANGELOG.md`
|
||||
|
||||
**Step 1: Ajouter l'entrée**
|
||||
|
||||
Ajouter sous `## v1.1.6` (ou créer `## v1.1.7` si nouvelle version) :
|
||||
|
||||
```markdown
|
||||
### Mise à jour automatique
|
||||
|
||||
- **Migration electron-updater** : remplacement du système custom (download HTTP + script batch) par `electron-updater` (generic provider)
|
||||
- Vérification sha512 automatique des mises à jour
|
||||
- Installation NSIS native (plus de script batch hack)
|
||||
- Restart automatique après installation
|
||||
- Code simplifié (~40 lignes vs ~200)
|
||||
- Compatible Gitea : découverte via API + `latest.yml` uploadé en asset de release
|
||||
```
|
||||
|
||||
**Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add CHANGELOG.md
|
||||
git commit -m "docs: add electron-updater migration to CHANGELOG"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: Mettre à jour le workflow de release
|
||||
|
||||
**Step 1: Documenter le nouveau process**
|
||||
|
||||
Le nouveau workflow de release est :
|
||||
|
||||
1. Mettre à jour `version` dans `package.json`
|
||||
2. `npm run build`
|
||||
3. Deux fichiers sont générés dans `dist/` :
|
||||
- `Minuteur-Dragodinde-Setup-X.Y.Z.exe`
|
||||
- `latest.yml`
|
||||
4. Commit + tag + push :
|
||||
```bash
|
||||
git add -A && git commit -m "vX.Y.Z"
|
||||
git tag vX.Y.Z && git push && git push --tags
|
||||
```
|
||||
5. Sur Gitea → Releases → Créer release avec le tag
|
||||
6. **Uploader les 2 fichiers** : le `.exe` ET `latest.yml`
|
||||
|
||||
> **IMPORTANT** : `latest.yml` DOIT être uploadé à chaque release, sinon electron-updater ne pourra pas vérifier l'intégrité du fichier.
|
||||
|
||||
---
|
||||
|
||||
## Récapitulatif des fichiers modifiés
|
||||
|
||||
| Fichier | Action |
|
||||
|---------|--------|
|
||||
| `package.json` | Ajout dep `electron-updater` + config `publish` |
|
||||
| `package-lock.json` | Mis à jour automatiquement |
|
||||
| `src/infrastructure/electron/main.ts` | Réécriture section update (~200 lignes → ~60 lignes) |
|
||||
| `src/infrastructure/electron/preload.ts` | **Aucun changement** |
|
||||
| `src/presentation/components/UpdateBanner.ts` | **Aucun changement** |
|
||||
| `CHANGELOG.md` | Entrée migration |
|
||||
55
docs/plans/2026-04-05-toast-notifications-design.md
Normal file
55
docs/plans/2026-04-05-toast-notifications-design.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Toast Notifications — Design
|
||||
|
||||
**Goal:** Ajouter un systeme de toast notifications (bas droite) pour confirmer les actions et afficher les erreurs, en remplacement des `alert()` natifs.
|
||||
|
||||
## Types
|
||||
|
||||
| Type | Icone | Couleur | Duree |
|
||||
|------|-------|---------|-------|
|
||||
| `success` | `check_circle` | Vert | 3s |
|
||||
| `error` | `error` | Rouge | 5s |
|
||||
|
||||
## Composant Toast.ts
|
||||
|
||||
Singleton avec file de toasts. API : `Toast.show(type, message)`.
|
||||
|
||||
- Max 3 toasts visibles (les plus anciens sont evincés)
|
||||
- Empilage vertical vers le haut
|
||||
- Animation : slide-in droite + fade-out a l'expiration
|
||||
|
||||
## Style
|
||||
|
||||
- Position : `bottom: 24px; right: 24px`, z-index eleve
|
||||
- Glassmorphism Obsidienne (fond semi-transparent, blur, border subtle)
|
||||
- Icone + texte sur une ligne, lisere gauche colore selon le type
|
||||
- Pas de bouton d'action (undo/redo sera separe)
|
||||
|
||||
## Integration
|
||||
|
||||
- `App.ts` monte le conteneur `#toast-container` dans le DOM
|
||||
- Chaque composant appelle `Toast.show()` apres `commandBus.execute()`
|
||||
- Remplacer les `alert()` de `WorkflowsView.ts` par des toasts error
|
||||
|
||||
## Actions couvertes
|
||||
|
||||
### Success
|
||||
- Suppression enclos
|
||||
- Suppression DD
|
||||
- Import workflows
|
||||
- Enregistrement accouplement
|
||||
- Reset statistiques
|
||||
- Clear enclos
|
||||
- Nouvelle fournee
|
||||
- Export workflows
|
||||
|
||||
### Error
|
||||
- Import workflows : fichier invalide, JSON invalide
|
||||
- Toute erreur de validation future
|
||||
|
||||
## Fichiers
|
||||
|
||||
- **Creer** : `src/presentation/components/Toast.ts`
|
||||
- **Modifier** : `src/presentation/styles/obsidienne.css`
|
||||
- **Modifier** : `src/presentation/components/App.ts`
|
||||
- **Modifier** : `src/presentation/components/WorkflowsView.ts`
|
||||
- **Modifier** : composants avec actions destructives/importantes
|
||||
440
docs/plans/2026-04-05-toast-notifications-plan.md
Normal file
440
docs/plans/2026-04-05-toast-notifications-plan.md
Normal file
@@ -0,0 +1,440 @@
|
||||
# Toast Notifications Implementation Plan
|
||||
|
||||
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
||||
|
||||
**Goal:** Ajouter un systeme de toast notifications (success/error) en bas a droite pour donner du feedback apres les actions utilisateur.
|
||||
|
||||
**Architecture:** Composant singleton `Toast` avec file d'attente, monte dans le DOM par `App.ts`. Chaque composant appelle `Toast.show()` apres ses actions. Les `alert()` natifs sont remplaces par des toasts error.
|
||||
|
||||
**Tech Stack:** TypeScript, CSS animations, Material Symbols Outlined
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Creer le composant Toast.ts
|
||||
|
||||
**Files:**
|
||||
- Create: `src/presentation/components/Toast.ts`
|
||||
|
||||
**Step 1: Creer le fichier Toast.ts**
|
||||
|
||||
```typescript
|
||||
export type ToastType = 'success' | 'error';
|
||||
|
||||
interface ToastItem {
|
||||
id: number;
|
||||
type: ToastType;
|
||||
message: string;
|
||||
}
|
||||
|
||||
const ICON: Record<ToastType, string> = {
|
||||
success: 'check_circle',
|
||||
error: 'error',
|
||||
};
|
||||
|
||||
const DURATION: Record<ToastType, number> = {
|
||||
success: 3000,
|
||||
error: 5000,
|
||||
};
|
||||
|
||||
const MAX_VISIBLE = 3;
|
||||
|
||||
let nextId = 0;
|
||||
let container: HTMLElement | null = null;
|
||||
const items: ToastItem[] = [];
|
||||
|
||||
export const Toast = {
|
||||
mount(parent: HTMLElement): void {
|
||||
container = document.createElement('div');
|
||||
container.id = 'toast-container';
|
||||
parent.appendChild(container);
|
||||
},
|
||||
|
||||
show(type: ToastType, message: string): void {
|
||||
if (!container) return;
|
||||
|
||||
const id = nextId++;
|
||||
items.push({ id, type, message });
|
||||
|
||||
// Evincer les plus anciens si > MAX_VISIBLE
|
||||
while (items.length > MAX_VISIBLE) {
|
||||
const old = items.shift()!;
|
||||
const oldEl = container.querySelector(`[data-toast-id="${old.id}"]`);
|
||||
if (oldEl) oldEl.remove();
|
||||
}
|
||||
|
||||
const el = document.createElement('div');
|
||||
el.className = `toast toast-${type}`;
|
||||
el.dataset['toastId'] = String(id);
|
||||
el.innerHTML = `<span class="toast-icon material-symbols-outlined">${ICON[type]}</span><span class="toast-msg">${message}</span>`;
|
||||
container.appendChild(el);
|
||||
|
||||
// Trigger animation
|
||||
requestAnimationFrame(() => el.classList.add('toast-visible'));
|
||||
|
||||
setTimeout(() => {
|
||||
el.classList.remove('toast-visible');
|
||||
el.classList.add('toast-exit');
|
||||
el.addEventListener('animationend', () => {
|
||||
el.remove();
|
||||
const idx = items.findIndex(i => i.id === id);
|
||||
if (idx !== -1) items.splice(idx, 1);
|
||||
}, { once: true });
|
||||
}, DURATION[type]);
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
**Step 2: Run tests**
|
||||
|
||||
Run: `npm test` (depuis Windows)
|
||||
Expected: PASS (aucun test casse, nouveau fichier sans test pour l'instant)
|
||||
|
||||
**Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/components/Toast.ts
|
||||
git commit -m "feat(toast): creer le composant Toast singleton"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: Ajouter les styles CSS
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/styles/obsidienne.css`
|
||||
|
||||
**Step 1: Ajouter les styles toast a la fin de obsidienne.css**
|
||||
|
||||
Ajouter avant le dernier `}` ou a la fin du fichier :
|
||||
|
||||
```css
|
||||
/* ────────────────────<E29480><E29480><EFBFBD>────────────────────────────
|
||||
TOAST NOTIFICATIONS
|
||||
───────────────────────<E29480><E29480><EFBFBD>───────────────────────── */
|
||||
#toast-container {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
right: 24px;
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
gap: 8px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.toast {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 12px 20px;
|
||||
border-radius: 12px;
|
||||
background: rgba(30, 20, 50, 0.85);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
color: #e0e0e0;
|
||||
font-size: 0.92rem;
|
||||
font-family: var(--font-body);
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
|
||||
pointer-events: auto;
|
||||
opacity: 0;
|
||||
transform: translateX(100%);
|
||||
transition: none;
|
||||
min-width: 260px;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.toast-visible {
|
||||
animation: toast-in 0.3s ease forwards;
|
||||
}
|
||||
|
||||
.toast-exit {
|
||||
animation: toast-out 0.3s ease forwards;
|
||||
}
|
||||
|
||||
.toast-icon {
|
||||
font-size: 1.3rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.toast-msg {
|
||||
flex: 1;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.toast-success {
|
||||
border-left: 3px solid #4caf50;
|
||||
}
|
||||
.toast-success .toast-icon {
|
||||
color: #4caf50;
|
||||
}
|
||||
|
||||
.toast-error {
|
||||
border-left: 3px solid #f44336;
|
||||
}
|
||||
.toast-error .toast-icon {
|
||||
color: #f44336;
|
||||
}
|
||||
|
||||
@keyframes toast-in {
|
||||
from { opacity: 0; transform: translateX(100%); }
|
||||
to { opacity: 1; transform: translateX(0); }
|
||||
}
|
||||
|
||||
@keyframes toast-out {
|
||||
from { opacity: 1; transform: translateX(0); }
|
||||
to { opacity: 0; transform: translateX(100%); }
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2: Verifier visuellement**
|
||||
|
||||
Run: `npm start` (depuis Windows)
|
||||
Verifier que l'app demarre sans erreur CSS.
|
||||
|
||||
**Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/styles/obsidienne.css
|
||||
git commit -m "style(toast): ajouter les styles glassmorphism pour les toasts"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: Monter le conteneur Toast dans App.ts
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/components/App.ts:1-74`
|
||||
|
||||
**Step 1: Ajouter l'import Toast**
|
||||
|
||||
Apres la ligne `import { UpdateBanner } from './UpdateBanner';` (ligne 14), ajouter :
|
||||
|
||||
```typescript
|
||||
import { Toast } from './Toast';
|
||||
```
|
||||
|
||||
**Step 2: Monter le conteneur dans render()**
|
||||
|
||||
Apres le montage du update banner (apres la ligne `this.updateBanner.render(bannerRoot);`, environ ligne 73), ajouter :
|
||||
|
||||
```typescript
|
||||
// Mount toast container
|
||||
const appShell = this.root.querySelector('.app-shell') as HTMLElement;
|
||||
Toast.mount(appShell);
|
||||
```
|
||||
|
||||
**Step 3: Run tests**
|
||||
|
||||
Run: `npm test` (depuis Windows)
|
||||
Expected: PASS
|
||||
|
||||
**Step 4: Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/components/App.ts
|
||||
git commit -m "feat(toast): monter le conteneur Toast dans App.ts"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: Remplacer les alert() dans WorkflowsView.ts
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/components/WorkflowsView.ts:349,653,665`
|
||||
|
||||
**Step 1: Ajouter l'import**
|
||||
|
||||
En haut de `WorkflowsView.ts`, ajouter :
|
||||
|
||||
```typescript
|
||||
import { Toast } from './Toast';
|
||||
```
|
||||
|
||||
**Step 2: Remplacer les alert() par des toasts error**
|
||||
|
||||
Ligne ~653 — remplacer :
|
||||
```typescript
|
||||
alert('Aucun plan valide trouvé dans le fichier.');
|
||||
```
|
||||
par :
|
||||
```typescript
|
||||
Toast.show('error', 'Aucun plan valide trouvé dans le fichier.');
|
||||
```
|
||||
|
||||
Ligne ~665 — remplacer :
|
||||
```typescript
|
||||
alert('Le fichier sélectionné n\'est pas un JSON valide.');
|
||||
```
|
||||
par :
|
||||
```typescript
|
||||
Toast.show('error', 'Le fichier sélectionné n\'est pas un JSON valide.');
|
||||
```
|
||||
|
||||
**Step 3: Ajouter un toast success apres import reussi**
|
||||
|
||||
Apres la ligne `this.commandBus.execute({ type: 'import-workflows', ... })` (ligne ~660), avant `this.dirty = true;`, ajouter :
|
||||
|
||||
```typescript
|
||||
Toast.show('success', `${valid.length} plan(s) importé(s) avec succès.`);
|
||||
```
|
||||
|
||||
**Step 4: Ajouter un toast success apres suppression workflow**
|
||||
|
||||
Ligne ~350, apres `this.commandBus.execute({ type: 'delete-workflow', ... })`, ajouter :
|
||||
|
||||
```typescript
|
||||
Toast.show('success', `Plan "${name}" supprimé.`);
|
||||
```
|
||||
|
||||
**Step 5: Run tests**
|
||||
|
||||
Run: `npm test` (depuis Windows)
|
||||
Expected: PASS
|
||||
|
||||
**Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/components/WorkflowsView.ts
|
||||
git commit -m "feat(toast): remplacer alert() par toasts dans WorkflowsView"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: Ajouter les toasts dans les autres composants
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/components/App.ts:176` (delete-enclos)
|
||||
- Modify: `src/presentation/components/EnclosView.ts:206,274` (clear-enclos, nouvelle-fournee)
|
||||
- Modify: `src/presentation/components/Dashboard.ts:229` (reset-stats)
|
||||
- Modify: `src/presentation/components/AccouplementView.ts:434` (register-accouplement)
|
||||
- Modify: `src/presentation/components/DragodindeCard.ts:216` (remove-dragodinde)
|
||||
|
||||
**Step 1: App.ts — toast apres suppression enclos**
|
||||
|
||||
Ajouter l'import `Toast` (deja fait en Task 3). Apres `this.commandBus.execute({ type: 'delete-enclos', enclosId: id });` (ligne ~176), ajouter :
|
||||
|
||||
```typescript
|
||||
Toast.show('success', 'Enclos supprimé.');
|
||||
```
|
||||
|
||||
**Step 2: EnclosView.ts — toasts clear et nouvelle fournee**
|
||||
|
||||
Ajouter l'import en haut :
|
||||
```typescript
|
||||
import { Toast } from './Toast';
|
||||
```
|
||||
|
||||
Apres `this.commandBus.execute({ type: 'clear-enclos', enclosId: eId });` (ligne ~206), ajouter :
|
||||
```typescript
|
||||
Toast.show('success', 'Enclos vidé.');
|
||||
```
|
||||
|
||||
Apres `this.commandBus.execute({ type: 'nouvelle-fournee', enclosId: eId });` (ligne ~274), ajouter :
|
||||
```typescript
|
||||
Toast.show('success', 'Nouvelle fournée lancée.');
|
||||
```
|
||||
|
||||
**Step 3: Dashboard.ts — toast reset stats**
|
||||
|
||||
Ajouter l'import :
|
||||
```typescript
|
||||
import { Toast } from './Toast';
|
||||
```
|
||||
|
||||
Apres `this.commandBus.execute({ type: 'reset-stats' });` (ligne ~229), ajouter :
|
||||
```typescript
|
||||
Toast.show('success', 'Statistiques réinitialisées.');
|
||||
```
|
||||
|
||||
**Step 4: AccouplementView.ts — toast enregistrement**
|
||||
|
||||
Ajouter l'import :
|
||||
```typescript
|
||||
import { Toast } from './Toast';
|
||||
```
|
||||
|
||||
Apres le `this.commandBus.execute({ type: 'register-accouplement', ... })` (ligne ~434), ajouter :
|
||||
```typescript
|
||||
Toast.show('success', 'Accouplement enregistré.');
|
||||
```
|
||||
|
||||
**Step 5: DragodindeCard.ts — toast suppression DD**
|
||||
|
||||
Ajouter l'import :
|
||||
```typescript
|
||||
import { Toast } from './Toast';
|
||||
```
|
||||
|
||||
Apres `this.commandBus.execute({ type: 'remove-dragodinde', ... })` (ligne ~216), ajouter :
|
||||
```typescript
|
||||
Toast.show('success', 'Dragodinde retirée.');
|
||||
```
|
||||
|
||||
**Step 6: Run tests**
|
||||
|
||||
Run: `npm test` (depuis Windows)
|
||||
Expected: PASS
|
||||
|
||||
**Step 7: Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/components/App.ts src/presentation/components/EnclosView.ts src/presentation/components/Dashboard.ts src/presentation/components/AccouplementView.ts src/presentation/components/DragodindeCard.ts
|
||||
git commit -m "feat(toast): ajouter toasts success sur toutes les actions importantes"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: Ajouter un toast pour l'export workflows
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/presentation/components/WorkflowsView.ts`
|
||||
|
||||
**Step 1: Trouver la methode d'export**
|
||||
|
||||
Chercher la methode qui gere le clic sur le bouton d'export (probablement `exportWorkflows` ou similaire avec `showSaveDialog`). Apres l'ecriture reussie du fichier, ajouter :
|
||||
|
||||
```typescript
|
||||
Toast.show('success', 'Plans exportés avec succès.');
|
||||
```
|
||||
|
||||
**Step 2: Run tests**
|
||||
|
||||
Run: `npm test` (depuis Windows)
|
||||
Expected: PASS
|
||||
|
||||
**Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/presentation/components/WorkflowsView.ts
|
||||
git commit -m "feat(toast): toast success apres export workflows"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 7: Tests E2E pour les toasts
|
||||
|
||||
**Files:**
|
||||
- Modify: `tests/e2e/breeding.spec.ts`
|
||||
|
||||
**Step 1: Ajouter un test E2E pour le toast d'enregistrement**
|
||||
|
||||
Dans le test "Definir nombre de couples et bebes puis enregistrer", apres le clic sur Enregistrer, ajouter une verification :
|
||||
|
||||
```typescript
|
||||
// Verifier que le toast success apparait
|
||||
await expect(page.locator('.toast-success')).toBeVisible({ timeout: 3000 });
|
||||
await expect(page.locator('.toast-msg')).toContainText('Accouplement enregistré');
|
||||
```
|
||||
|
||||
**Step 2: Rebuild et run E2E**
|
||||
|
||||
Run: `npm run build && npx playwright test tests/e2e/breeding.spec.ts` (depuis Windows)
|
||||
Expected: PASS
|
||||
|
||||
**Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add tests/e2e/breeding.spec.ts
|
||||
git commit -m "test(toast): test E2E toast apres enregistrement accouplement"
|
||||
```
|
||||
Reference in New Issue
Block a user