diff --git a/src/App.tsx b/src/App.tsx index d2d36fe..f9f8958 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -18,7 +18,6 @@ import data from "./assets/DATA"; import { useTranslation } from "react-i18next"; import i18n from './i18n'; import {createRoot} from "react-dom/client"; -import GitHubStatsSection from 'components/GitHubStatsSection'; function App() { // Initialise le thème depuis localStorage ou détecte le thème système @@ -83,8 +82,6 @@ function App() { ...item, type: item.type as "work" | "education" | "achievement" }))} /> -
-

diff --git a/src/components/GitHubStatsSection.tsx b/src/components/GitHubStatsSection.tsx deleted file mode 100644 index cf866aa..0000000 --- a/src/components/GitHubStatsSection.tsx +++ /dev/null @@ -1,234 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { useTranslation } from 'react-i18next'; -import { FaGithub, FaStar, FaCodeBranch, FaCode, FaCalendarAlt } from 'react-icons/fa'; - -interface GitHubStats { - totalRepos: number; - totalStars: number; - totalForks: number; - totalCommits: number; - languages: { [key: string]: number }; - contributions: Array<{ date: string; count: number }>; -} - -const GitHubStatsSection: React.FC = () => { - const [stats, setStats] = useState(null); - const [loading, setLoading] = useState(true); - const { t } = useTranslation(); - - - useEffect(() => { - const fetchStats = async () => { - try { - const username = "BreizhHardware"; // à adapter si besoin - const token = import.meta.env.VITE_GITHUB_TOKEN; - // Infos utilisateur REST - const userRes = await fetch(`https://api.github.com/users/${username}`, { - headers: { - Authorization: `Bearer ${token}`, - Accept: "application/vnd.github.v3+json", - }, - }); - const userData = await userRes.json(); - - // Repos pour stars/forks REST - const reposRes = await fetch(`https://api.github.com/users/${username}/repos?per_page=100`, { - headers: { - Authorization: `Bearer ${token}`, - Accept: "application/vnd.github.v3+json", - }, - }); - const reposData = await reposRes.json(); - - // Calculs REST - const totalStars = reposData.reduce((acc: number, repo: any) => acc + repo.stargazers_count, 0); - const totalForks = reposData.reduce((acc: number, repo: any) => acc + repo.forks_count, 0); - // Langages - const langCount: { [key: string]: number } = {}; - reposData.forEach((repo: any) => { - if (repo.language) { - langCount[repo.language] = (langCount[repo.language] || 0) + 1; - } - }); - const totalRepos = userData.public_repos; - - // GraphQL pour contributions - const today = new Date(); - const lastYear = new Date(today); - lastYear.setFullYear(today.getFullYear() - 1); - const fromDate = lastYear.toISOString(); // format complet ISO 8601 - const toDate = today.toISOString(); - const graphQLQuery = { - query: ` - query { - user(login: "${username}") { - contributionsCollection(from: \"${fromDate}\", to: \"${toDate}\") { - contributionCalendar { - totalContributions - weeks { - contributionDays { - date - contributionCount - } - } - } - } - } - } - ` - }; - const graphQLRes = await fetch("https://api.github.com/graphql", { - method: "POST", - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "application/json", - }, - body: JSON.stringify(graphQLQuery), - }); - const graphQLData = await graphQLRes.json(); - const calendar = graphQLData.data.user.contributionsCollection.contributionCalendar; - const totalCommits = calendar.totalContributions; - // Flatten days - const contributions: Array<{ date: string; count: number }> = []; - calendar.weeks.forEach((week: any) => { - week.contributionDays.forEach((day: any) => { - contributions.push({ date: day.date, count: day.contributionCount }); - }); - }); - - setStats({ - totalRepos, - totalStars, - totalForks, - totalCommits, - languages: langCount, - contributions, - }); - } catch (e) { - setStats(null); - } - setLoading(false); - }; - fetchStats(); - }, []); - - const topLanguages = stats ? Object.entries(stats.languages).sort((a, b) => b[1] - a[1]).slice(0, 5) : []; - - if (loading) { - return ( -
-
-
-
-
- {[1, 2, 3, 4].map((i) => ( -
- ))} -
-
-
-
- ); - } - - return ( -
-
-

- {t('github.title')} -

-

- {t('github.description')} -

-
- - {stats && ( -
-
-
- -

{stats.totalRepos}

-

{t('github.repositories')}

-
- -
- -

{stats.totalStars}

-

{t('github.stars')}

-
- -
- -

{stats.totalForks}

-

{t('github.forks')}

-
- -
- -

{stats.totalCommits !== -1 ? stats.totalCommits : "N/A"}

-

{t('github.commits')}

-
-
- -
-

- {t('github.languages')} -

-
- {topLanguages.map(([language, percentage], index) => ( -
-
- {language} - {percentage}% -
-
-
-
-
- ))} -
-
- -
-

- {t('github.activity')} -

- {stats.contributions && ( -
- {stats.contributions.map((day, i) => { - let color = 'bg-gray-200 dark:bg-gray-700'; - if (day.count > 10) color = 'bg-green-500'; - else if (day.count > 5) color = 'bg-green-400'; - else if (day.count > 2) color = 'bg-green-300'; - else if (day.count > 0) color = 'bg-green-200'; - return ( -
1 ? 's' : ''}`} - /> - ); - })} -
- )} -
- - {t('github.legend')}
- {t('github.totalCommits')} : {stats.totalCommits} -
-
-
-
- )} -
- ); -}; - -export default GitHubStatsSection; \ No newline at end of file diff --git a/src/components/Menu.tsx b/src/components/Menu.tsx index 3c0567d..df67e60 100644 --- a/src/components/Menu.tsx +++ b/src/components/Menu.tsx @@ -10,7 +10,6 @@ function Menu() {
  • Félix MARQUET
  • {t('nav.about')}
  • {t('nav.experience')}
  • -
  • {t('nav.github')}
  • {t('nav.projects')}
  • {t('nav.contact')}
  • {t('nav.cv')}