Skip to content

Commit 85c25c0

Browse files
committed
update script with config
1 parent 8225f3c commit 85c25c0

1 file changed

Lines changed: 35 additions & 30 deletions

File tree

generate-stats.js

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ const fs = require('fs');
33
// Configuration
44
const USERNAME = 'FabioDevCode';
55

6+
// Thème de couleur
7+
const BG_COLOR = '#202830';
8+
const BORDER_COLOR = '#151B23';
9+
const TITLE_COLOR = '#D1D7E0';
10+
const TEXT_COLOR = '#D1D7E0';
11+
const PERCENT_COLOR = '#9298A1';
12+
613
// Couleurs officielles GitHub
714
const LANGUAGE_COLORS = JSON.parse(fs.readFileSync('github_colors.json', 'utf8'));
815

@@ -75,7 +82,7 @@ function generateSVG(languageStats, topN = 5) {
7582
}));
7683

7784
// Générer la barre de progression
78-
let currentX = 0;
85+
let currentX = 10;
7986
const barHeight = 12;
8087
const barY = 50;
8188
const barSegments = langData.map(lang => {
@@ -91,8 +98,8 @@ function generateSVG(languageStats, topN = 5) {
9198
const item = `
9299
<g>
93100
<circle cx="20" cy="${legendY}" r="5" fill="${lang.color}"/>
94-
<text x="35" y="${legendY + 4}" font-size="14" fill="#c9d1d9">${lang.name}</text>
95-
<text x="380" y="${legendY + 4}" font-size="14" fill="#8b949e" text-anchor="end">${lang.percentage}%</text>
101+
<text x="35" y="${legendY + 4}" font-size="14" fill="${TEXT_COLOR}">${lang.name}</text>
102+
<text x="380" y="${legendY + 4}" font-size="14" fill="${PERCENT_COLOR}" text-anchor="end">${lang.percentage}%</text>
96103
</g>
97104
`;
98105
legendY += 25;
@@ -102,31 +109,31 @@ function generateSVG(languageStats, topN = 5) {
102109
const height = 70 + (topN * 25) + 20;
103110

104111
return `<?xml version="1.0" encoding="UTF-8"?>
105-
<svg width="420" height="${height}" xmlns="http://www.w3.org/2000/svg">
106-
<defs>
107-
<style>
108-
@import url('https://fonts.googleapis.com/css2?family=Segoe+UI:wght@400;500;600&amp;display=swap');
109-
* { font-family: 'Segoe UI', Ubuntu, sans-serif; }
110-
</style>
111-
</defs>
112-
113-
<!-- Background -->
114-
<rect width="420" height="${height}" fill="#0d1117" rx="10" stroke="#30363d" stroke-width="1"/>
115-
116-
<!-- Title -->
117-
<text x="210" y="30" font-size="18" fill="#58a6ff" font-weight="600" text-anchor="middle">
118-
Top Languages
119-
</text>
120-
121-
<!-- Progress Bar Container -->
122-
<rect x="10" y="${barY}" width="400" height="${barHeight}" fill="#161b22" rx="6"/>
123-
124-
<!-- Progress Bar Segments -->
125-
${barSegments}
126-
127-
<!-- Legend -->
128-
${legendItems}
129-
</svg>`;
112+
<svg width="420" height="${height}" xmlns="http://www.w3.org/2000/svg">
113+
<defs>
114+
<style>
115+
@import url('https://fonts.googleapis.com/css2?family=Segoe+UI:wght@400;500;600&amp;display=swap');
116+
* { font-family: 'Segoe UI', Ubuntu, sans-serif; }
117+
</style>
118+
</defs>
119+
120+
<!-- Background -->
121+
<rect width="420" height="${height}" fill="${BG_COLOR}" rx="10" stroke="${BORDER_COLOR}" stroke-width="1"/>
122+
123+
<!-- Title -->
124+
<text x="210" y="30" font-size="18" fill="${TITLE_COLOR}" font-weight="600" text-anchor="middle">
125+
Top Langages
126+
</text>
127+
128+
<!-- Progress Bar Container -->
129+
<rect x="10" y="${barY}" width="400" height="${barHeight}" fill="#161b2200" rx="6"/>
130+
131+
<!-- Progress Bar Segments -->
132+
${barSegments}
133+
134+
<!-- Legend -->
135+
${legendItems}
136+
</svg>`;
130137
}
131138

132139
function generateEmptySVG(topN) {
@@ -165,9 +172,7 @@ async function main() {
165172
const defaultSvg = generateSVG(languageStats, 5);
166173
fs.writeFileSync('stats.svg', defaultSvg);
167174
console.log(' ✅ stats.svg (default)');
168-
169175
console.log('\n🎉 Toutes les images ont été générées avec succès !');
170-
171176
} catch (error) {
172177
console.error('❌ Erreur lors de la génération:', error);
173178
process.exit(1);

0 commit comments

Comments
 (0)