Repository navigation
Premium Analytics: move the remaining leaderboard widgets onto the shared row - #51602
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Premium Analytics plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
208b658 to
1345a5e
Compare
f332cc0 to
99c7577
Compare
Code Coverage SummaryCoverage changed in 4 files.
|
bc72c07 to
5c04f1d
Compare
…on media docs Also builds the File downloads rows through `buildLeaderboardRow`, like every other migrated widget.
…leaderboard row The last leaderboard widget drawing its own label. Its box already matched the shared row, so only the markup changes; `LeaderboardLabel` sets the same font size the dropped `variant="body-sm"` did.
5c04f1d to
cf20f0f
Compare
kangzj
left a comment
There was a problem hiding this comment.
Hi @chihsuan, this one tests well for me 👍 Every widget lands on the same 36px box with a 12px inset, and routing the tag rows through resolveLeaderboardRowAction also quietly kills a case where a grouped row carrying a link rendered an <a> inside a chart <button> - nice a11y win on top of the alignment. Approving, the notes below are all non-blocking.
Just a heads up on one thing that cost me a while: my first Storybook run showed no tag/category glyphs at all. That turned out to be a stale packages/widgets-toolkit/build-module/ in my checkout (Vite resolves module before main, so it was loading a pre-PR bundle while the widget source was fresh). A jp build packages/premium-analytics fixed it and the glyphs render exactly like your after-screenshot. Nothing wrong with the PR, just noting it in case someone else pulls this and sees the same thing.
A few suggestions
-
utm-insightssaysstaticon rows that are actually drill-down buttons. The label declaresaction={ { kind: 'static' } }(render.tsx#L142-L145) while the entry separately spreads a hand-rolledonClick+ariaLabeljust below it (L159-L168).actionis documented as "the mutually exclusive action applied to this chart row", so the declaration kinda contradicts what the row does. It works today only becauseLeaderboardRowrendersdrillDownandstaticthe same way - the moment the shared row gives drill-down rows any affordance (chevron, cursor, hover), these rows silently miss it. Yourtagswidget in this same PR already shows the shape I'd expect:buildLeaderboardRow+resolveLeaderboardRowAction( { hasChildren, drillDown } ), which also deletes the hand-rolled spread. This is the one I'd actually like to see changed. -
Four widgets pick up a second row-building pattern.
search-terms(L60),shares(L45),top-platforms(L70) andutm-insightspasslabel: <LeaderboardRow … />directly, where all ten existing chart-row call sites - andfile-downloadsandtagsin this very PR - spread...buildLeaderboardRow( { … } ). Functionally identical for a static action, so no bug, but a reader now has to know both forms, and it's what makes #1 possible in the first place.most-commented-authorsis the closest analogue if you want a reference. -
The label type actually shrank, and the description doesn't mention it. For Shares / Searched terms / Top platforms the old
<Text>default wasbody-md= 13px; the shared.labelis--wpds-typography-font-size-sm= 12px. I measured 12px on all three after the change. I'm fairly sure this is correct -referrers, untouched by this PR, already renders at 12px, so you're converging on the norm rather than breaking it. But the PR says those three "shift by the same 4px inset with nothing else visibly different", and the type did change too, so probably worth saying so explicitly so a designer signs off rather than finding it post-merge. -
The AGENTS.md exception overstates what
video-detail-embedsdoes. The new wording (AGENTS.md#L763) says it "matches.rowinchart-leaderboard/leaderboard-label.module.scssby hand". It doesn't really - it'sdisplay: block+padding-block: smrather thanflex/align-items: center, colour is brand instead ofinherit, ellipsis sits on the row instead of on.label, and I measured its rows rendering at 16px font vs the shared row's 12px. Onlymin-block-size: 36pxand (after this PR) the inset line up. Something like "matches the shared row's 36px height and inset" would be true and won't mislead the next person reading that file. -
The new test asserts a path exists, not that it's the right glyph (leaderboard-row.test.tsx#L71-L80).
expect( glyphPath ).toBeTruthy()passes for any SVG, so it wouldn't catchrowGlyphhanding backtagwherecategorybelongs - which is the one bit of logic the icon kind exists for. Also the test name says "without announcing it" but proves it viaqueryByRole( 'img' ); the real contract isaria-hidden="true", onegetAttributeaway. Minor, only if you're touching the file anyway. Andwidgets/tags/has no__tests__at all while taking the biggest behaviour change here, unlike its neighbours.
What I tested
Storybook from projects/packages/premium-analytics on the PR branch, after a full jp build packages/premium-analytics. Everything measured off getComputedStyle / getBoundingClientRect rather than eyeballed.
| Step | Result |
|---|---|
| Tags → Default: 36px rows, 12px inset, glyphs render | ✅ all 8 rows 36px / padding-inline: 12px, glyph present |
| Tags: glyph sits inside the anchor on linked rows | ✅ every <a> row contains the <svg>; grouped rows are <span> (no nested anchor) |
| Tags: drill into "Desserts, chocolate" | ✅ members render at 36px / 12px, same as the leaderboard rows |
| FileDownloads → Default: 44px → 36px | ✅ all 5 rows 36px / 12px |
| FileDownloads: linked row hover | ✅ brand blue + underline, arrow picks up the colour too |
| SearchTerms / Shares / TopPlatforms → Default | ✅ 10 / 4 / 10 rows, all 36px / 12px / 12px label |
| UtmInsights → Default + drill into a UTM value | ✅ value rows and post rows both 36px / 12px |
| VideoDetailEmbeds → Default: inset sm → md | ✅ 12px, 36px min-height kept |
| Tags in a dashboard frame (narrow column) | ✅ no overflow, rows still line up |
| Jest (whole package), tsc, ESLint, Stylelint | ✅ all clean |
| Widget-picker preview won't stretch the new glyph | ✅ every DataViews stretch selector targets img, not svg, so no [inert] twin needed |
| Removed CSS classes left dangling anywhere | ✅ no remaining styles.itemLabel / labelLink / itemIcon / childRow references |
Screenshots: your before/afters in the description match what I see locally, so I didn't add duplicates.
Thanks for pushing this series through - having every leaderboard on one row box is really nice to have 🙌
|
Thanks for the thorough pass — the token measurements especially. All five are in. On 5: |
Proposed changes
padding-inline: md.LeaderboardRowMediagains aniconkind. Every kind that draws something took an image URL, and Tags & categories needs a@wordpress/iconsglyph.TagLabel: the leaderboard rows and the drilled-in member list now build the same shared row, so the two views stay level with each other and with every other widget.video-detail-embedsis a plain list rather than a leaderboard, so it keeps its own markup; only its inset moves fromsmtomdto line up with the rest.Last of a few PRs aligning the leaderboard widgets with the design prototype. Stacked on #51599.
Three deliberate behaviour changes, all bringing these widgets in line with what the shared row already does elsewhere:
<Text>(body-md,--wpds-typography-font-size-md= 13px); the shared.labelis--wpds-typography-font-size-sm= 12px. That is the size every already-migrated leaderboard renders at, so this converges on the norm rather than changing it — but it is a type change, so worth a designer's eye.Screenshots
Captured from Storybook at a 760px widget width.
Tags & categories — the glyph moves inside the anchor, and the drilled-in member list is rebuilt out of the same rows.
File downloads — the largest visual change: rows drop from 44px to 36px, so the list tightens up.
The last three shift by the same 4px inset and drop from 13px to 12px labels; nothing else changes.
Top platforms
Searched terms
Shares
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
pnpm run storybookfromprojects/packages/premium-analytics.