Block 257 of 297
Heatmap Calendar
A year of daily activity as a week-by-day grid, with total, active days and busiest day worked out.
- Puck key
- HeatmapCalendarBlock
- Export
- heatmapCalendarBlock
- React component
- <HeatmapCalendar />
- Path
- components/puck/heatmap-calendar-block.tsx
- Dependencies
- None
- License
- MIT
About this block
When to use it, how to write for it, and what to change in the code.
What it's for
A year of daily activity as a week-by-day grid of shaded squares, with totals for the period, active days and the busiest day above it. Darker cells mean more activity, and each cell has a tooltip with its date and value. When the grid is wider than the card it scrolls sideways and opens on the most recent weeks.
- Volunteer hours or check-ins logged per day
- Daily library, park or facility visits across a year
- Daily website submissions or service requests
Writing the content
- Set First day as YYYY-MM-DD; without a valid date the grid loses its month and weekday labels and dates in tooltips.
- Enter Daily values comma-separated, oldest first, one per day. Up to 371 values (53 weeks) are used.
- Leave a day empty between commas for no data; it draws as an outlined white square, distinct from a zero.
- Write Unit as what each value counts, like volunteer hours; it appears in the summary, tooltips and screen reader text.
Accessibility
- The grid is an SVG with role="img" and a summary of the date range, total, active days and busiest day.
- Its scroll container is a focusable, labeled region, so keyboard users can scroll it (WCAG 2.1.1).
- Totals are a description list, and hidden text explains that darker cells mean more activity, since the Less to More key is visual only.
Customizing the code
- Shades are in LEVELS (cells) and KEYS (legend), from neutral-100 through indigo-800; keep the two arrays in step.
- Cell size and spacing are the CELL, STEP, GUTTER and TOP constants, in pixels.
Editor fields
What content editors see in the P1 sidebar when they select this block.
- Titletext
- Heading levelselect
- Subtitle or periodtext
- First daytext
- Daily valuestextarea
- Unittext
- Footnotetext