From e6f47cd2d2ade86d63b9b662cde0057a14f52707 Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Wed, 16 Sep 2026 19:50:58 +0100 Subject: [PATCH] Redesign skills carousel: icon + name + slash marquee items, no pills; add live GitHub language proficiency panel --- src/components/LanguagePanel.jsx | 173 ++++++++++++++++++++++++++++++ src/components/SkillsCarousel.jsx | 31 ++++-- src/components/skill-icons.js | 25 +++++ src/index.css | 104 ++++++++++++++++-- 4 files changed, 321 insertions(+), 12 deletions(-) create mode 100644 src/components/LanguagePanel.jsx create mode 100644 src/components/skill-icons.js diff --git a/src/components/LanguagePanel.jsx b/src/components/LanguagePanel.jsx new file mode 100644 index 0000000..de60c6a --- /dev/null +++ b/src/components/LanguagePanel.jsx @@ -0,0 +1,173 @@ +import { useEffect, useState } from "react"; +import { profile } from "../content.js"; +import { skillIcons } from "./skill-icons.js"; + +const CACHE_KEY = "gh-lang-stats-v1"; +// 1h TTL: each refresh costs ~9 unauthenticated API calls (repo list + one /languages per repo), +// well inside the 60/hour limit. +const TTL_MS = 60 * 60 * 1000; + +// GitHub /languages names → glyph keys in skill-icons.js +const ICONS = { + JavaScript: "JavaScript", + TypeScript: "TypeScript", + HTML: "HTML", + CSS: "CSS", + SCSS: "CSS", + Python: "Python", + Kotlin: "Kotlin", + Java: "Java", + "C++": "C++", + C: "C", + Go: "Go", + Shell: "Bash", + Dockerfile: "Docker", + Vue: "Vue", +}; + +function LangGlyph({ name }) { + const icon = ICONS[name] && skillIcons[ICONS[name]]; + if (!icon) return null; + return ( + + ); +} + +function readCache() { + try { + const raw = localStorage.getItem(CACHE_KEY); + if (!raw) return null; + const parsed = JSON.parse(raw); + return parsed && Array.isArray(parsed.rows) ? parsed : null; + } catch { + return null; + } +} + +function writeCache(rows, repoCount) { + try { + localStorage.setItem(CACHE_KEY, JSON.stringify({ at: Date.now(), rows, repoCount })); + } catch { + // storage unavailable — panel still works uncached + } +} + +async function fetchRows(githubUser) { + const reposRes = await fetch( + `https://api.github.com/users/${githubUser}/repos?per_page=100`, + { headers: { Accept: "application/vnd.github+json" } } + ); + if (!reposRes.ok) throw new Error("repo list failed"); + const repos = await reposRes.json(); + + const langResults = await Promise.allSettled( + repos.map((r) => + fetch(`https://api.github.com/repos/${githubUser}/${r.name}/languages`).then( + (res) => (res.ok ? res.json() : null) + ) + ) + ); + + const totals = {}; + for (const result of langResults) { + if (result.status === "fulfilled" && result.value) { + for (const [lang, bytes] of Object.entries(result.value)) { + totals[lang] = (totals[lang] || 0) + bytes; + } + } + } + + const total = Object.values(totals).reduce((a, b) => a + b, 0); + if (!total) throw new Error("no language data"); + + const rows = Object.entries(totals) + .map(([name, bytes]) => ({ name, pct: (bytes / total) * 100 })) + .filter((r) => r.pct >= 1) + .sort((a, b) => b.pct - a.pct) + .slice(0, 8); + + return { rows, repoCount: repos.length }; +} + +export default function LanguagePanel() { + const [state, setState] = useState(() => { + const cached = readCache(); + if (cached) { + // Fresh or stale cache both render immediately; a refetch refreshes in the background. + return { status: "ready", rows: cached.rows, repoCount: cached.repoCount }; + } + return { status: "loading" }; + }); + const [armed, setArmed] = useState(false); + + useEffect(() => { + let cancelled = false; + fetchRows(profile.githubUser) + .then(({ rows, repoCount }) => { + if (cancelled) return; + writeCache(rows, repoCount); + setState({ status: "ready", rows, repoCount }); + }) + .catch(() => { + if (cancelled) return; + const cached = readCache(); + if (cached) setState({ status: "ready", rows: cached.rows, repoCount: cached.repoCount }); + else setState({ status: "error" }); + }); + return () => { + cancelled = true; + }; + }, []); + + useEffect(() => { + if (state.status !== "ready") return; + const frame = requestAnimationFrame(() => setArmed(true)); + return () => cancelAnimationFrame(frame); + }, [state.status]); + + return ( +
+
+

Language proficiency

+ + {state.repoCount + ? `Share of code across ${state.repoCount} public GitHub repos` + : "Live from your public GitHub repos"} + +
+ + {state.status === "loading" && ( +

Crunching your GitHub repos…

+ )} + + {state.status === "error" && ( +

+ Language stats are unavailable right now — they load live from GitHub. +

+ )} + + {state.status === "ready" && + state.rows.map((row) => ( +
+ + + {row.name} + +
+
+
+ {Math.round(row.pct)}% +
+ ))} +
+ ); +} diff --git a/src/components/SkillsCarousel.jsx b/src/components/SkillsCarousel.jsx index e08f25b..3b98d71 100644 --- a/src/components/SkillsCarousel.jsx +++ b/src/components/SkillsCarousel.jsx @@ -1,10 +1,24 @@ import { skills } from "../content.js"; +import { skillIcons } from "./skill-icons.js"; +import LanguagePanel from "./LanguagePanel.jsx"; -// Even copy count so the -50% translate lands on a copy boundary -// (seamless loop); 12 copies keep half the track (~5000px) far wider -// than any real viewport, so the right edge never gaps. +// Even copy count so the -50% translate lands exactly on a copy boundary. const COPIES = 12; +function SkillGlyph({ name }) { + const icon = skillIcons[name]; + if (!icon) return null; + return ( + + ); +} + function Marquee({ label, items }) { const row = Array.from({ length: COPIES }, () => items).flat(); return ( @@ -22,7 +36,11 @@ function Marquee({ label, items }) { className="marquee-item" aria-hidden={i >= items.length * (COPIES / 2)} > - {item} + + {item} + ))}
@@ -36,9 +54,10 @@ export default function SkillsCarousel() {

Skills & tools

+ + + - - ); } diff --git a/src/components/skill-icons.js b/src/components/skill-icons.js new file mode 100644 index 0000000..5624cc5 --- /dev/null +++ b/src/components/skill-icons.js @@ -0,0 +1,25 @@ +// Inline monochrome brand glyphs for the skills marquee + language panel. +// Sources: simple-icons (MIT), devicon (MIT); fills stripped, rendered via currentColor. + +export const skillIcons = { + "React Native": { vb: "0 0 24 24", inner: "" }, + "Kotlin": { vb: "0 0 24 24", inner: "" }, + "Java": { vb: "0 0 128 128", inner: " " }, + "C++": { vb: "0 0 24 24", inner: "" }, + "Go": { vb: "0 0 24 24", inner: "" }, + "HTML": { vb: "0 0 24 24", inner: "" }, + "CSS": { vb: "0 0 24 24", inner: "" }, + "JavaScript": { vb: "0 0 24 24", inner: "" }, + "Python": { vb: "0 0 24 24", inner: "" }, + "Bash": { vb: "0 0 24 24", inner: "" }, + "IntelliJ IDEA": { vb: "0 0 24 24", inner: "" }, + "WebStorm": { vb: "0 0 24 24", inner: "" }, + "PyCharm": { vb: "0 0 24 24", inner: "" }, + "Arduino IDE": { vb: "0 0 24 24", inner: "" }, + "Docker": { vb: "0 0 24 24", inner: "" }, + "Git": { vb: "0 0 24 24", inner: "" }, + "RESTful APIs": { vb: "0 0 24 24", inner: "" }, + "TypeScript": { vb: "0 0 24 24", inner: "" }, + "C": { vb: "0 0 24 24", inner: "" }, + "Vue": { vb: "0 0 24 24", inner: "" }, +}; diff --git a/src/index.css b/src/index.css index 599cdda..feedef9 100644 --- a/src/index.css +++ b/src/index.css @@ -672,7 +672,6 @@ a { .marquee-track { display: flex; - gap: 12px; width: max-content; animation: marquee-scroll var(--marquee-duration, 34s) linear infinite; } @@ -682,16 +681,29 @@ a { } .marquee-item { - font-size: 15px; + display: inline-flex; + align-items: center; + gap: 9px; + padding-right: 16px; + font-size: 15.5px; font-weight: 500; color: var(--ink); - background: var(--surface); - border: 1px solid var(--hairline); - border-radius: 999px; - padding: 11px 22px; white-space: nowrap; } +.marquee-icon { + width: 17px; + height: 17px; + flex: none; + color: var(--muted); +} + +.marquee-sep { + margin-left: 14px; + font-size: 14px; + color: var(--hairline-strong); +} + @keyframes marquee-scroll { from { transform: translateX(0); @@ -701,6 +713,86 @@ a { } } +/* ---------- language proficiency panel ---------- */ + +.lang-panel { + margin-top: 44px; + background: var(--surface); + border: 1px solid var(--hairline); + border-radius: var(--radius); + padding: 26px 28px 28px; +} + +.lang-panel-head { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 16px; + flex-wrap: wrap; + margin-bottom: 20px; +} + +.lang-panel-title { + font-size: 17px; + font-weight: 600; +} + +.lang-panel-sub { + font-size: 13px; + color: var(--muted); +} + +.lang-row { + display: grid; + grid-template-columns: minmax(120px, 190px) 1fr 46px; + align-items: center; + gap: 16px; + padding: 7.5px 0; +} + +.lang-name { + display: flex; + align-items: center; + gap: 10px; + font-size: 14.5px; + font-weight: 500; + min-width: 0; +} + +.lang-icon { + width: 16px; + height: 16px; + flex: none; + color: var(--muted); +} + +.lang-bar-track { + height: 7px; + background: var(--bg-alt); + border-radius: 999px; + overflow: hidden; +} + +.lang-bar-fill { + height: 100%; + background: var(--accent); + border-radius: 999px; + transition: width 900ms cubic-bezier(0.22, 1, 0.36, 1); +} + +.lang-pct { + font-size: 13px; + color: var(--muted); + text-align: right; + font-variant-numeric: tabular-nums; +} + +.lang-note { + margin-top: 14px; + font-size: 12.5px; + color: var(--muted); +} + /* ---------- interests ---------- */ .interest-grid {