How it works
The GitHub-style contribution graph is a CSS Grid calendar in disguise: 53 columns by 7 rows of small squares, where each cell's color maps the day's count to one of four levels. Storing the level as a data-level attribute and styling through attribute selectors keeps the JS dumb and the CSS declarative. Grid beats absolutely-positioned cells because column widths and row heights self-align, and the uniform gap is one line of CSS. The data side is a single folding function: walk the date array, compute week-of-year and day-of-week, and drop each count into its cell.
The tap detail popover is where implementations usually break. Read the tapped cell's getBoundingClientRect, position the bubble above it absolutely, then flip below or clamp horizontally when near the viewport edges - without that flip, bubbles on the top row or screen edge get cut off. A 150-millisecond rise-and-fade entrance keeps the popover light rather than loud.
How to use this prompt
Great for check-ins, commits, spending logs - anything with a year of daily activity. Send your data shape (an array of date-plus-count) and the AI will generate the full-year mapping. On mobile, add the instruction that cells must stay square with constant gaps as they shrink; the AI will choose between fr-unit sizing and fixed pixels and handle the scaling math.
Tips for better results
Do not build the four levels from opacity steps of one color - use a single hue ramping light to dark (GitHub's #9be9a8 to #0e4429 style) for far better legibility. Outline today's cell so users stop hunting for it. On desktop, show a light tooltip on hover and reserve the full popover for click - two information layers that never fight. Past roughly 400 cells, stop binding listeners per cell and delegate from the container; it halves memory and simplifies the code.