From fa111af684f39f8114665c5f0c39f00c584db593 Mon Sep 17 00:00:00 2001 From: AKHIL Date: Thu, 23 Jul 2026 23:22:36 +0530 Subject: [PATCH] UI --- apps/web/src/components/github-stars.tsx | 82 ------------------------ apps/web/src/components/header.tsx | 3 - 2 files changed, 85 deletions(-) delete mode 100644 apps/web/src/components/github-stars.tsx diff --git a/apps/web/src/components/github-stars.tsx b/apps/web/src/components/github-stars.tsx deleted file mode 100644 index ef4a62bd..00000000 --- a/apps/web/src/components/github-stars.tsx +++ /dev/null @@ -1,82 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; -import { Github, Star } from "lucide-react"; -import { cn } from "@/lib/utils"; - -const REPO = "mydevtools-tech/mydevtools"; -const REPO_URL = `https://github.com/${REPO}`; -const CACHE_KEY = "mdt-gh-stars"; -const CACHE_TTL = 60 * 60 * 1000; // 1h — GitHub's unauth API is 60 req/hr/IP. - -function formatStars(n: number): string { - if (n >= 1000) return `${(n / 1000).toFixed(n >= 10000 ? 0 : 1)}k`; - return String(n); -} - -/** Header pill linking to the repo with a live stargazer count (client-fetched, localStorage-cached). */ -export function GithubStars({ className }: { className?: string }) { - const [stars, setStars] = useState(null); - - useEffect(() => { - try { - const cached = localStorage.getItem(CACHE_KEY); - if (cached) { - const { count, at } = JSON.parse(cached) as { count: number; at: number }; - setStars(count); - if (Date.now() - at < CACHE_TTL) return; // fresh — skip refetch - } - } catch { - /* ignore bad cache */ - } - - let cancelled = false; - fetch(`https://api.github.com/repos/${REPO}`, { - headers: { Accept: "application/vnd.github+json" }, - }) - .then((r) => (r.ok ? r.json() : Promise.reject(r.status))) - .then((d: { stargazers_count?: number }) => { - if (cancelled || typeof d.stargazers_count !== "number") return; - setStars(d.stargazers_count); - try { - localStorage.setItem( - CACHE_KEY, - JSON.stringify({ count: d.stargazers_count, at: Date.now() }) - ); - } catch { - /* ignore quota */ - } - }) - .catch(() => { - /* keep icon-only fallback */ - }); - return () => { - cancelled = true; - }; - }, []); - - return ( - - - Star - - - {stars != null ? formatStars(stars) : "—"} - - - ); -} diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index 01b70115..6ab3212e 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -6,7 +6,6 @@ import { Button } from "@/components/ui/button"; import { ModeToggle } from "./modeToggle"; import useAuth from "@/utils/useAuth"; import { Logo } from "./logo"; -import { GithubStars } from "./github-stars"; import { motion, AnimatePresence } from "framer-motion"; import { cn } from "@/lib/utils"; @@ -169,7 +168,6 @@ export function Header({ showThemeToggle = true }: HeaderProps) { {/* Desktop Actions */}
- {showThemeToggle ? : null} - setIsMenuOpen(false)}