import React, { useEffect, useMemo, useState } from 'react'; import { GitBranch } from 'lucide-react'; import { getCachedGitActivity } from '../lib/git'; import { formatDate, isToday, getWeekdayLabel } from '../lib/utils-habit'; import AnimatedCounter from './AnimatedCounter'; const GitActivityGrid = () => { const [{ dailyCounts }, setData] = useState(() => getCachedGitActivity()); const weeks = useMemo(() => { const today = new Date(); const todayDay = today.getDay(); const daysSinceMonday = (todayDay + 6) % 7; const mondayThisWeek = new Date(today); mondayThisWeek.setDate(today.getDate() - daysSinceMonday); const weeksArray = []; const totalWeeks = 52; for (let week = totalWeeks - 1; week >= 0; week--) { const weekDays = []; const monday = new Date(mondayThisWeek); monday.setDate(mondayThisWeek.getDate() - week * 7); for (let day = 0; day < 7; day++) { const date = new Date(monday); date.setDate(monday.getDate() + day); weekDays.push(date); } weeksArray.push(weekDays); } return weeksArray; }, []); const getOpacity = (count) => { if (!count) return 0.15; if (count < 2) return 0.35; if (count < 5) return 0.6; if (count < 10) return 0.8; return 1; }; useEffect(() => { // Display current cache only; syncing is done from Settings setData(getCachedGitActivity()); }, []); return (