Premium Analytics: adaptive sizing for the Posting activity heatmap - #50505
Merged
Conversation
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
louwie17
force-pushed
the
add/posting-activity-heatmap-adaptive-sizing
branch
from
July 15, 2026 09:03
fb756a2 to
5f62182
Compare
The Posting activity widget rendered its calendar heatmap in the chart's fixed-square compact mode at a fixed size, so it never adapted to the tile — tiny in tall tiles, and a full year overflowed into a horizontal scroll in narrow ones. It also only spanned the weeks that happened to contain posts. - Add `computeCalendarHeatmapLayout` and `fitCalendarHeatmapColumns`, dependency- free geometry that decides the expanded cell size, the column count, and how many fixed cells fit a width. Written without React/charts imports so it can be lifted into `@automattic/charts` later. - Measure the tile and pick the mode from its height: expanded renders scaled 61:40 cells (with numbers) sized to the computed rectangle via `HeatmapChartUnresponsive`; compact renders the chart's own fixed-size squares and is only trimmed to the columns that fit, so it never scrolls. - Trim to the most-recent weeks when the tile can't fit them all. - Floor the `stats/streak` fetch to a year ending on the picker's end date (`resolveStreakRange`), and densify the sparse response to that whole window (`buildStreakSeries`) so the heatmap always spans a full range of week columns rather than only the weeks that contain posts. - Expose `HeatmapChartUnresponsive` and `useElementSize` through the toolkit. Document the decisions in an ADR and the domain language in CONTEXT.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9yw5BSzzHjX78hmig3Kza
louwie17
force-pushed
the
add/posting-activity-heatmap-adaptive-sizing
branch
from
July 15, 2026 09:14
5f62182 to
805add7
Compare
Quality follow-up on the posting-activity adaptive heatmap:
- Use the canonical `getDatePart` helper in `buildStreakSeries` instead of an
inline `.split( 'T' )`, matching its sibling `resolveStreakRange`.
- Collapse the render memo to return `{ columns, sizingProps }` directly,
dropping the `expandedLayout: null` sentinel and impossible-null optional
chaining; drop the redundant `columns > 0` guard on the trim (`slice( -0 )`
already returns the whole array).
- Internalize the geometry tuning as module constants in `layout.ts`, slim the
input types, rename `fitCalendarHeatmapColumns` to
`fitCompactCalendarHeatmapColumns`, and raise the column minimum to 6.
- Rewrite `layout.test.ts` against the new API and constants.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V9yw5BSzzHjX78hmig3Kza
louwie17
marked this pull request as ready for review
July 15, 2026 10:10
Contributor
Author
|
Going to go ahead and merge this, given the changes are quite self contained. We can iterate :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
The Posting activity widget rendered its calendar heatmap in the chart's fixed-square
compactmode at a fixed size, so it never adapted to the tile — tiny in tall tiles, and a full year overflowed into a horizontal scroll in narrow ones. It also only spanned the weeks that happened to contain posts. This makes the heatmap adapt to its tile and always show a full range.Sizing (pure geometry + widget policy)
layout.ts:computeCalendarHeatmapLayout(expanded cell size, column count, exact rectangle) andfitCalendarHeatmapColumns(how many fixed cells fit a width). Dependency-free (no React/charts imports) so it can later be lifted into@automattic/charts.useElementSizeon the parent div) and picks the mode from its height:HeatmapChartUnresponsivewidth/height— so the chart'sminmax(0,1fr)tracks produce the exact cells (no wrapper div, no double measurement). I borrowed the 61/40 from Eders demo, but we can adjust this.compactprop) — the widget doesn't scale it, only trims the data to the columns that fit the width, so themax-contentgrid never scrolls.minColumnsis the knob to show more weeks there).Data
stats/streakfetch to at least a year ending on the picker's end date (resolveStreakRange) — a calendar heatmap needs a span of weeks, not a 7-day slice.{ 'yyyy-MM-dd': count }response (only days with posts) to the full window, missing days →null(buildStreakSeries). Without this,buildCalendarHeatmapDataderives its range from the returned data's min/max, so posts clustered in a narrow window would still collapse to a few columns even with the year-long fetch.Toolkit
HeatmapChartUnresponsiveanduseElementSizethrough the widgets-toolkit passthrough (widgets must not import@automattic/chartsdirectly). No charts-package change.No changes to
@automattic/chartsare needed — expanded sizing reuses the existingHeatmapChartUnresponsivewidth/height, and compact reuses the existingcompactprop.Closes: WOOA7S-1693
scalable-heatmap.mp4
Related product discussion/links
Does this pull request change what data or activity we track or use?
No — same
stats/streakendpoint; only the requested date window is widened.Testing instructions
jetpack build --deps packages/premium-analytics(orpnpm run build), then run Storybook forjs-packages/storybook.widgetWidth,widgetHeight,rowHeight,dashboardWidth):pnpm --filter automattic/jetpack-premium-analytics test -- widgets/posting-activity(31 tests across the layout geometry, column fit, the ≥365-day range floor, and the streak-series densification).🤖 Generated with Claude Code