refactor: factoriser le code en plusieurs fichiers (#8)

- Déplace les styles inline vers css/form.css et css/cv.css
- Crée js/main.js comme point d'entrée ES Module (type="module")
- Extrait la logique identité dans js/sections/identite.js
- Ajoute les stubs js/sections/{competences,formation,experience,hobbies}.js
- Crée les dossiers sections/{identite,competences,formation,experience,hobbies}/
  avec .gitkeep et README décrivant le contenu prévu
- Met à jour index.html : liens CSS séparés, script type=module
- Met à jour README.md : avertissement ES Modules, structure des fichiers
This commit is contained in:
stanig2106
2026-04-05 13:55:45 +01:00
parent 18ec285002
commit 792542a71f
19 changed files with 451 additions and 138 deletions
+32
View File
@@ -0,0 +1,32 @@
import { collectIdentite, renderIdentite } from './sections/identite.js';
import { collectCompetences, renderCompetences } from './sections/competences.js';
import { collectFormation, renderFormation } from './sections/formation.js';
import { collectExperience, renderExperience } from './sections/experience.js';
import { collectHobbies, renderHobbies } from './sections/hobbies.js';
function generateCV() {
const identite = collectIdentite();
if (!identite.nom || !identite.prenom || !identite.email || !identite.titre) return;
renderIdentite(identite);
renderCompetences(collectCompetences());
renderFormation(collectFormation());
renderExperience(collectExperience());
renderHobbies(collectHobbies());
localStorage.setItem('cvData', JSON.stringify(identite));
const success = document.getElementById('success');
if (success) {
success.textContent = `CV prêt à être généré pour ${identite.prenom} ${identite.nom} !`;
success.style.display = 'block';
}
}
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('cv-form')?.addEventListener('submit', (e) => {
e.preventDefault();
generateCV();
});
});
+5
View File
@@ -0,0 +1,5 @@
// Stub — Section Compétences
// À implémenter : collectCompetences(), addCompetence(), renderCompetences()
export function collectCompetences() { return []; }
export function renderCompetences(_competences) { /* no-op */ }
+5
View File
@@ -0,0 +1,5 @@
// Stub — Section Expérience professionnelle
// À implémenter : collectExperience(), addExperienceEntry(), renderExperience()
export function collectExperience() { return []; }
export function renderExperience(_entries) { /* no-op */ }
+5
View File
@@ -0,0 +1,5 @@
// Stub — Section Formation
// À implémenter : collectFormation(), addFormationEntry(), renderFormation()
export function collectFormation() { return []; }
export function renderFormation(_entries) { /* no-op */ }
+5
View File
@@ -0,0 +1,5 @@
// Stub — Section Centres d'intérêt
// À implémenter : collectHobbies(), addHobby(), renderHobbies()
export function collectHobbies() { return []; }
export function renderHobbies(_hobbies) { /* no-op */ }
+30
View File
@@ -0,0 +1,30 @@
/**
* identite.js — Section Identité
* Collecte les champs nom, prénom, email, titre depuis le formulaire.
*/
/**
* @returns {{ nom: string, prenom: string, email: string, titre: string }}
*/
export function collectIdentite() {
const get = (id) => document.getElementById(id)?.value.trim() ?? '';
return {
nom: get('nom'),
prenom: get('prenom'),
email: get('email'),
titre: get('titre'),
};
}
/**
* @param {{ nom: string, prenom: string, email: string, titre: string }} identite
*/
export function renderIdentite(identite) {
const set = (id, value) => {
const el = document.getElementById(id);
if (el) el.textContent = value;
};
set('cv-nom', `${identite.prenom} ${identite.nom}`);
set('cv-titre', identite.titre);
set('cv-email', identite.email);
}