diff --git a/src/components/ContributionCalendar.jsx b/src/components/ContributionCalendar.jsx index 77180ce..604bb6e 100644 --- a/src/components/ContributionCalendar.jsx +++ b/src/components/ContributionCalendar.jsx @@ -1,13 +1,17 @@ import React from 'react'; -// Helper to get all days in the last 52 weeks +// Helper to get all days in the last 52 weeks, starting on Monday function getCalendarDays() { const days = []; const today = new Date(); today.setHours(0, 0, 0, 0); - // Go back 51 weeks (to get 52 weeks total) + // Find the most recent Monday const start = new Date(today); - start.setDate(start.getDate() - (7 * 51 + today.getDay())); + const dayOfWeek = start.getDay(); + // getDay(): 0=Sunday, 1=Monday, ..., 6=Saturday + // If today is not Monday, go back to the previous Monday + const offset = (dayOfWeek === 0 ? -6 : 1 - dayOfWeek); // If Sunday, go back 6 days; else, go back to Monday + start.setDate(start.getDate() - (7 * 51) + offset); for (let i = 0; i < 7 * 52; i++) { const d = new Date(start); d.setDate(start.getDate() + i); @@ -16,6 +20,24 @@ function getCalendarDays() { return days; } +// Get month labels for the top +function getMonthLabels(days) { + const labels = []; + let lastMonth = null; + for (let week = 0; week < 52; week++) { + const day = days[week * 7]; + const month = day.toLocaleString('default', { month: 'short' }); + if (month !== lastMonth) { + labels.push({ week, month }); + lastMonth = month; + } + } + return labels; +} + +// Day labels for rows (Monday to Sunday) +const DAY_LABELS = ['Mon', '', 'Wed', '', 'Fri', '', 'Sun']; + // Color scale (GitHub-like) const COLORS = [ '#ebedf0', // 0 @@ -32,38 +54,104 @@ function getColor(count) { export default function ContributionCalendar({ data }) { const days = getCalendarDays(); + const monthLabels = getMonthLabels(days); // Get max count for scaling (optional, for more dynamic color) // const max = Math.max(...Object.values(data)); return ( -
+ This page provides a transparent overview of the ongoing development activity for the 365DevNet project. The contribution calendar below visually represents code contributions (commits) made over the past year, with darker squares indicating more active days. Below the calendar, you'll find a list of the most recent commits, including details about each change. This helps users, contributors, and stakeholders track project progress and stay up to date with the latest updates. +
+ {/* Contribution Calendar */} +