Skip to content

Premium Analytics: move the remaining leaderboard widgets onto the shared row - #51602

Merged
chihsuan merged 6 commits into
trunkfrom
wooa7s-1989-migrate-remaining-labels
Aug 27, 2026
Merged

chihsuan merged 6 commits into
trunkfrom
wooa7s-1989-migrate-remaining-labels

Conversation

@chihsuan

@chihsuan chihsuan commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

  • Six more leaderboard widgets — Top platforms, Searched terms, Shares, File downloads, Tags & categories, and Top UTM — drop their hand-written labels and render through the shared row, so every leaderboard in the dashboard now uses one 36px box with padding-inline: md.
  • LeaderboardRowMedia gains an icon kind. Every kind that draws something took an image URL, and Tags & categories needs a @wordpress/icons glyph.
  • Tags & categories loses its local 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.
  • ~110 lines of per-widget label CSS go away.
  • video-detail-embeds is a plain list rather than a leaderboard, so it keeps its own markup; only its inset moves from sm to md to 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:

  • File downloads rows drop from 44px to 36px, and their link hover gains the brand colour alongside the existing underline.
  • In Tags & categories the anchor now wraps the glyph as well as the text, matching how Top referrers and Top locations have always treated their favicon and flag.
  • Shares, Searched terms and Top platforms lose a point of label type. Their hand-written labels were a default <Text> (body-md, --wpds-typography-font-size-md = 13px); the shared .label is --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.

Before After
before after

File downloads — the largest visual change: rows drop from 44px to 36px, so the list tightens up.

Before After
before after

The last three shift by the same 4px inset and drop from 13px to 12px labels; nothing else changes.

Top platforms

Before After
before after

Searched terms

Before After
before after

Shares

Before After
before after

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • Run Storybook: pnpm run storybook from projects/packages/premium-analytics.
  • Open Widgets / Tags → Default. Rows are 36px with a 12px inset, the tag and category glyphs still render, and linked rows show the outbound arrow.
  • Click a grouped row ("Desserts, chocolate"). The drilled-in members should be the same 36px rows at the same inset — before this change they were a separate 8px-inset list.
  • Open Widgets / FileDownloads → Default. Linked rows should turn blue and underline on hover; rows without a URL should not.
  • Open TopPlatforms, SearchTerms, and Shares → Default and confirm each row sits at the same inset as the widgets above.
  • Open UtmInsights → Default and drill into a UTM value. The value rows and the post rows below should stay the same height and inset.
  • On a dashboard, put several leaderboard widgets side by side and confirm the rows line up across all of them.

@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the wooa7s-1989-migrate-remaining-labels branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-1989-migrate-remaining-labels
bin/jetpack-downloader test jetpack-mu-wpcom-plugin wooa7s-1989-migrate-remaining-labels

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics Docs labels Aug 26, 2026
@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

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:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: September 7, 2026

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.

@chihsuan
chihsuan force-pushed the wooa7s-1989-migrate-custom-title-labels branch from 208b658 to 1345a5e Compare August 26, 2026 09:48
@chihsuan
chihsuan force-pushed the wooa7s-1989-migrate-remaining-labels branch from f332cc0 to 99c7577 Compare August 26, 2026 09:48
@jp-launch-control

jp-launch-control Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/widgets/utm-insights/render.tsx 32/37 (86.49%) 0.38% 0 💚
projects/packages/premium-analytics/packages/data/src/hooks/use-stats-tags.ts 1/1 (100.00%) 100.00% -1 💚
projects/packages/premium-analytics/widgets/tags/use-tag-views.ts 9/9 (100.00%) 100.00% -9 💚
projects/packages/premium-analytics/widgets/tags/render.tsx 18/19 (94.74%) 94.74% -20 💚

Full summary · PHP report · JS report

@chihsuan
chihsuan force-pushed the wooa7s-1989-migrate-remaining-labels branch 2 times, most recently from bc72c07 to 5c04f1d Compare August 26, 2026 10:18
Base automatically changed from wooa7s-1989-migrate-custom-title-labels to trunk August 27, 2026 02:42
…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.
@chihsuan
chihsuan force-pushed the wooa7s-1989-migrate-remaining-labels branch from 5c04f1d to cf20f0f Compare August 27, 2026 02:47
@chihsuan
chihsuan marked this pull request as ready for review August 27, 2026 02:53
@chihsuan
chihsuan requested a review from a team as a code owner August 27, 2026 02:53
@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Aug 27, 2026
kangzj
kangzj previously approved these changes Aug 27, 2026

@kangzj kangzj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. utm-insights says static on rows that are actually drill-down buttons. The label declares action={ { kind: 'static' } } (render.tsx#L142-L145) while the entry separately spreads a hand-rolled onClick + ariaLabel just below it (L159-L168). action is documented as "the mutually exclusive action applied to this chart row", so the declaration kinda contradicts what the row does. It works today only because LeaderboardRow renders drillDown and static the same way - the moment the shared row gives drill-down rows any affordance (chevron, cursor, hover), these rows silently miss it. Your tags widget 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.

  2. Four widgets pick up a second row-building pattern. search-terms (L60), shares (L45), top-platforms (L70) and utm-insights pass label: <LeaderboardRow … /> directly, where all ten existing chart-row call sites - and file-downloads and tags in 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-authors is the closest analogue if you want a reference.

  3. The label type actually shrank, and the description doesn't mention it. For Shares / Searched terms / Top platforms the old <Text> default was body-md = 13px; the shared .label is --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.

  4. The AGENTS.md exception overstates what video-detail-embeds does. The new wording (AGENTS.md#L763) says it "matches .row in chart-leaderboard/leaderboard-label.module.scss by hand". It doesn't really - it's display: block + padding-block: sm rather than flex/align-items: center, colour is brand instead of inherit, ellipsis sits on the row instead of on .label, and I measured its rows rendering at 16px font vs the shared row's 12px. Only min-block-size: 36px and (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.

  5. 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 catch rowGlyph handing back tag where category belongs - which is the one bit of logic the icon kind exists for. Also the test name says "without announcing it" but proves it via queryByRole( 'img' ); the real contract is aria-hidden="true", one getAttribute away. Minor, only if you're touching the file anyway. And widgets/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 🙌

@chihsuan

Copy link
Copy Markdown
Member Author

Thanks for the thorough pass — the token measurements especially.

All five are in. utm-insights now goes through buildLeaderboardRow + resolveLeaderboardRowAction, and the other three follow the same shape. AGENTS.md reworded, and the description now names the 13px → 12px.

On 5: rowGlyph lives in widgets/tags/, so the glyph test went there — it fails if the mapping flips.

@chihsuan
chihsuan merged commit 048ed9c into trunk Aug 27, 2026
77 checks passed
@chihsuan
chihsuan deleted the wooa7s-1989-migrate-remaining-labels branch August 27, 2026 04:22
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants