diff --git a/projects/packages/premium-analytics/AGENTS.md b/projects/packages/premium-analytics/AGENTS.md
index 3e4d7f351c0f..5a8d7fc17c2f 100644
--- a/projects/packages/premium-analytics/AGENTS.md
+++ b/projects/packages/premium-analytics/AGENTS.md
@@ -759,10 +759,12 @@ wire a handler in `routeStatsReport()` inside `register-report-mocks.ts`. See
add a second in-widget ` }>` title for framed Stats
widgets.
- View count format: `dataFormat={ { type: 'number', options: { useMultipliers: true, decimals: 0 } } }`
-- Leaderboard rows: prefer `LeaderboardRow` / `buildLeaderboardRow` / `LeaderboardPostLabel` over
- a hand-written label — they carry the shared row box, and a copy drifts from it. A label that
- must be custom should match `.row` in `chart-leaderboard/leaderboard-label.module.scss`;
- several widgets predate that and have not been migrated yet.
+- Leaderboard rows: spread `buildLeaderboardRow()` into the chart entry — it carries the
+ drill-down `onClick`/`ariaLabel` that a bare `` label silently drops. Use
+ `` directly only outside a chart, as `widgets/tags` does for its drilled-in
+ member list. A hand-written copy drifts from the shared row box. `video-detail-embeds` is the
+ one exception, a plain list rather than a leaderboard, and matches the shared row's 36px height
+ and `padding-inline` by hand — not the rest of `.row`.
- Loading / error / empty state: render through `` (see "Loading / error / empty
state" above), not `LeaderboardChart`'s `emptyStateText` or a hand-rolled `data.length === 0`
branch. Empty uses a neutral glyph distinct from the error icon.
diff --git a/projects/packages/premium-analytics/changelog/wooa7s-1989-migrate-remaining-labels b/projects/packages/premium-analytics/changelog/wooa7s-1989-migrate-remaining-labels
new file mode 100644
index 000000000000..e78493d77075
--- /dev/null
+++ b/projects/packages/premium-analytics/changelog/wooa7s-1989-migrate-remaining-labels
@@ -0,0 +1,4 @@
+Significance: patch
+Type: changed
+
+Leaderboards: Match the remaining row labels to the other leaderboard widgets.
diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/README.md b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/README.md
index 49be6a854378..bdaa266a064c 100644
--- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/README.md
+++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/README.md
@@ -163,7 +163,7 @@ Pass `section` to `LeaderboardPostLabel` to open a named tab on the detail page,
There is no `LeaderboardVideoLabel`, so a widget building a `videoLink` action takes that same
window from `useWidgetNavigationSearch()` and passes it as `search`.
-`LeaderboardRowMedia` provides five semantic media variants. The variant owns its size,
+`LeaderboardRowMedia` provides six semantic media variants. The variant owns its size,
fallback, and default alt-text policy:
| Kind | Size | Missing or failed image behavior |
@@ -172,8 +172,11 @@ fallback, and default alt-text policy:
| `favicon` | 16 × 16px | Hidden; always decorative |
| `flag` | 28px wide | Placeholder; proportional height |
| `thumbnail` | 28 × 28px | Placeholder |
+| `icon` | 20 × 20px | No image; takes a glyph |
| `none` | No media | Renders text only |
+`icon` takes a `@wordpress/icons` glyph rather than a URL: `media: { kind: 'icon', icon: category }`.
+
Use `resolveLeaderboardRowAction` when raw data can contain both an external URL and children.
It applies the shared precedence: drill-down for rows with children, external links for
childless rows, and static content otherwise.
diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/__tests__/leaderboard-row.test.tsx b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/__tests__/leaderboard-row.test.tsx
index aa1dc4ac9ac5..a5cf1c5abf5f 100644
--- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/__tests__/leaderboard-row.test.tsx
+++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/__tests__/leaderboard-row.test.tsx
@@ -2,12 +2,13 @@
* External dependencies
*/
import { fireEvent, render, screen } from '@testing-library/react';
+import { category, tag } from '@wordpress/icons';
/**
* Internal dependencies
*/
import { LeaderboardLabel } from '../leaderboard-label';
import { buildLeaderboardRow, resolveLeaderboardRowAction } from '../leaderboard-row';
-import type { AnchorHTMLAttributes, ReactNode } from 'react';
+import type { AnchorHTMLAttributes, ReactElement, ReactNode } from 'react';
type MockRouteLinkProps = {
to: string;
@@ -45,6 +46,20 @@ jest.mock( '@wordpress/route', () => {
};
} );
+function glyphPath( root: Element | null | undefined ) {
+ return root?.querySelector( 'path' )?.getAttribute( 'd' );
+}
+
+// `@wordpress/icons` exports elements, so naming a glyph means rendering that
+// icon on its own and comparing the two paths.
+function iconPath( icon: ReactElement ) {
+ const { container, unmount } = render( icon );
+ const path = glyphPath( container );
+
+ unmount();
+ return path;
+}
+
describe( 'LeaderboardLabel', () => {
it( 'renders media and text without adding row actions', () => {
render(
@@ -66,6 +81,21 @@ describe( 'LeaderboardLabel', () => {
expect( screen.getByText( 'Desktop' ) ).toBeInTheDocument();
expect( screen.queryByRole( 'img' ) ).not.toBeInTheDocument();
} );
+
+ it( 'renders the glyph it was handed, hidden from assistive technology', () => {
+ const { container } = render(
+
+ );
+ // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access -- the glyph is aria-hidden by design, so the DOM is the only place to reach it.
+ const glyph = container.querySelector( 'svg' );
+
+ expect( screen.getByText( 'Recipes' ) ).toBeInTheDocument();
+ expect( glyph ).toHaveAttribute( 'aria-hidden', 'true' );
+ // Naming the glyph rather than just counting one: an icon kind exists so a
+ // widget can pick between glyphs, so the wrong one has to fail here.
+ expect( glyphPath( glyph ) ).toBe( iconPath( category ) );
+ expect( glyphPath( glyph ) ).not.toBe( iconPath( tag ) );
+ } );
} );
describe( 'resolveLeaderboardRowAction', () => {
diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.module.scss b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.module.scss
index f9fa7aa9fcb3..9b09de2c89ad 100644
--- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.module.scss
+++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.module.scss
@@ -93,3 +93,7 @@
height: var(--jpa-leaderboard-image-height);
object-fit: var(--jpa-leaderboard-image-fit);
}
+
+.icon {
+ flex: none;
+}
diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.tsx b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.tsx
index 83a6051b56f1..70c73d73b9c4 100644
--- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.tsx
+++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-label.tsx
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
-import { Stack } from '@jetpack-premium-analytics/externals';
+import { Icon, Stack } from '@jetpack-premium-analytics/externals';
import { __, sprintf } from '@wordpress/i18n';
import clsx from 'clsx';
import { useState } from 'react';
@@ -9,12 +9,14 @@ import { useState } from 'react';
* Internal dependencies
*/
import styles from './leaderboard-label.module.scss';
+import type { ComponentProps } from 'react';
export type LeaderboardRowMedia =
| { kind: 'avatar'; url?: string; name: string }
| { kind: 'favicon'; url?: string }
| { kind: 'flag'; url?: string; country: string }
| { kind: 'thumbnail'; url?: string; alt: string }
+ | { kind: 'icon'; icon: ComponentProps< typeof Icon >[ 'icon' ] }
| { kind: 'none' };
export type LeaderboardLabelProps = {
@@ -30,7 +32,9 @@ export type LeaderboardLabelProps = {
const DEFAULT_IMAGE_URL =
'data:image/svg+xml;utf8,';
-function getMediaDetails( media: Exclude< LeaderboardRowMedia, { kind: 'none' } > ) {
+function getMediaDetails(
+ media: Exclude< LeaderboardRowMedia, { kind: 'none' } | { kind: 'icon' } >
+) {
switch ( media.kind ) {
case 'avatar':
return {
@@ -82,7 +86,8 @@ export function LeaderboardLabel( {
decorativeMedia = false,
}: LeaderboardLabelProps ) {
const [ failedImageUrl, setFailedImageUrl ] = useState< string >();
- const mediaDetails = media.kind === 'none' ? null : getMediaDetails( media );
+ const mediaDetails =
+ media.kind === 'none' || media.kind === 'icon' ? null : getMediaDetails( media );
const shouldRenderImage =
mediaDetails &&
( mediaDetails.fallback === 'placeholder' || Boolean( mediaDetails.url ) ) &&
@@ -95,6 +100,9 @@ export function LeaderboardLabel( {
align="center"
className={ clsx( styles.container, mediaDetails?.className ) }
>
+ { media.kind === 'icon' && (
+
+ ) }
{ shouldRenderImage && (
- { row.label }
-
- ) : (
-
- { row.label }
-
- ),
+ ...buildLeaderboardRow( {
+ label: row.label,
+ media: { kind: 'none' },
+ action: resolveLeaderboardRowAction( { href: row.href, hasChildren: false } ),
+ } ),
currentValue: row.value,
currentShare: sharePercentage( row.value, maxValue ),
previousValue,
diff --git a/projects/packages/premium-analytics/widgets/file-downloads/style.module.css b/projects/packages/premium-analytics/widgets/file-downloads/style.module.css
index 79af92d7a772..5a943c435006 100644
--- a/projects/packages/premium-analytics/widgets/file-downloads/style.module.css
+++ b/projects/packages/premium-analytics/widgets/file-downloads/style.module.css
@@ -1,29 +1,3 @@
-.labelLink {
- display: block;
-
- padding-block: var(--wpds-dimension-padding-md);
- padding-inline-start: var(--wpds-dimension-padding-sm);
- overflow: hidden;
- color: inherit;
- text-decoration: none;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.labelLink:hover,
-.labelLink:focus {
- text-decoration: underline;
-}
-
-.labelText {
- display: block;
- padding-block: var(--wpds-dimension-padding-md);
- padding-inline-start: var(--wpds-dimension-padding-sm);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
.root {
container-type: inline-size;
display: flex;
diff --git a/projects/packages/premium-analytics/widgets/search-terms/render.tsx b/projects/packages/premium-analytics/widgets/search-terms/render.tsx
index 8848ce263ed6..0457f8f16495 100644
--- a/projects/packages/premium-analytics/widgets/search-terms/render.tsx
+++ b/projects/packages/premium-analytics/widgets/search-terms/render.tsx
@@ -12,6 +12,7 @@ import {
WidgetFooter,
WidgetRoot,
WidgetState,
+ buildLeaderboardRow,
sharePercentage,
useWidgetRootContext,
type LeaderboardChartData,
@@ -20,7 +21,7 @@ import {
import { search } from '@jetpack-premium-analytics/icons';
import { useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
-import { Stack, Text } from '@jetpack-premium-analytics/externals';
+import { Stack } from '@jetpack-premium-analytics/externals';
/**
* Internal dependencies
*/
@@ -55,11 +56,11 @@ function SearchTermsInner() {
return {
id: `${ index }-${ term.label }`,
- label: (
-
- { term.label }
-
- ),
+ ...buildLeaderboardRow( {
+ label: term.label,
+ media: { kind: 'none' },
+ action: { kind: 'static' },
+ } ),
currentValue: term.views,
previousValue: previousViews,
currentShare: sharePercentage( term.views, maxValue ),
diff --git a/projects/packages/premium-analytics/widgets/search-terms/style.module.css b/projects/packages/premium-analytics/widgets/search-terms/style.module.css
index 29ddc2e78e23..5a943c435006 100644
--- a/projects/packages/premium-analytics/widgets/search-terms/style.module.css
+++ b/projects/packages/premium-analytics/widgets/search-terms/style.module.css
@@ -13,15 +13,3 @@
flex: 1 1 0;
min-height: 0;
}
-
-.itemLabel {
- padding: var(--wpds-dimension-padding-sm);
- min-width: 0;
- overflow: hidden;
-}
-
-.itemLabelText {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
-}
diff --git a/projects/packages/premium-analytics/widgets/shares/render.tsx b/projects/packages/premium-analytics/widgets/shares/render.tsx
index bb08b0e170c3..a71ca043477c 100644
--- a/projects/packages/premium-analytics/widgets/shares/render.tsx
+++ b/projects/packages/premium-analytics/widgets/shares/render.tsx
@@ -7,6 +7,7 @@ import {
WIDGET_ROW_LIMIT,
WidgetRoot,
WidgetState,
+ buildLeaderboardRow,
sharePercentage,
type LeaderboardChartData,
type ReportParamsFieldAttributes,
@@ -14,7 +15,7 @@ import {
import { megaphone } from '@jetpack-premium-analytics/icons';
import { useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
-import { Stack, Text } from '@jetpack-premium-analytics/externals';
+import { Stack } from '@jetpack-premium-analytics/externals';
/**
* Internal dependencies
*/
@@ -40,11 +41,11 @@ function SharesInner() {
return data.map( ( service, index ) => ( {
id: `${ index }-${ service.service }`,
- label: (
-
- { service.label }
-
- ),
+ ...buildLeaderboardRow( {
+ label: service.label,
+ media: { kind: 'none' },
+ action: { kind: 'static' },
+ } ),
currentValue: service.value,
currentShare: sharePercentage( service.value, maxValue ),
} ) );
diff --git a/projects/packages/premium-analytics/widgets/shares/style.module.css b/projects/packages/premium-analytics/widgets/shares/style.module.css
index 29ddc2e78e23..5a943c435006 100644
--- a/projects/packages/premium-analytics/widgets/shares/style.module.css
+++ b/projects/packages/premium-analytics/widgets/shares/style.module.css
@@ -13,15 +13,3 @@
flex: 1 1 0;
min-height: 0;
}
-
-.itemLabel {
- padding: var(--wpds-dimension-padding-sm);
- min-width: 0;
- overflow: hidden;
-}
-
-.itemLabelText {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
-}
diff --git a/projects/packages/premium-analytics/widgets/tags/__tests__/tags.test.tsx b/projects/packages/premium-analytics/widgets/tags/__tests__/tags.test.tsx
new file mode 100644
index 000000000000..8cbf7a308ea0
--- /dev/null
+++ b/projects/packages/premium-analytics/widgets/tags/__tests__/tags.test.tsx
@@ -0,0 +1,128 @@
+/**
+ * External dependencies
+ */
+import { getDefaultQueryParams, queryClient } from '@jetpack-premium-analytics/data';
+import { fireEvent, render, screen } from '@testing-library/react';
+import apiFetch from '@wordpress/api-fetch';
+import { category, tag } from '@wordpress/icons';
+/**
+ * Internal dependencies
+ */
+import TagsWidget from '../render';
+import type { ReactElement } from 'react';
+
+jest.mock( '@wordpress/api-fetch', () => jest.fn() );
+
+jest.mock( '@wordpress/route', () => jest.requireActual( '../../test-utils' ).mockWordPressRoute );
+
+const mockApiFetch = apiFetch as unknown as jest.Mock;
+
+// `type: 'category'` is the only value the sanitizer turns into the `folder`
+// glyph key, so the fixture pairs one of each against a grouped row.
+const TAGS_RESPONSE = {
+ date: '2026-06-22',
+ period: 'month',
+ tags: [
+ {
+ tags: [
+ { type: 'category', name: 'Recipes', link: 'https://example.com/category/recipes/' },
+ ],
+ views: 1240,
+ },
+ {
+ tags: [ { type: 'tag', name: 'vegan', link: 'https://example.com/tag/vegan/' } ],
+ views: 980,
+ },
+ {
+ tags: [
+ { type: 'category', name: 'Desserts', link: 'https://example.com/category/desserts/' },
+ { type: 'tag', name: 'chocolate', link: 'https://example.com/tag/chocolate/' },
+ ],
+ views: 760,
+ },
+ ],
+};
+
+function glyphPath( root: Element | null | undefined ) {
+ return root?.querySelector( 'svg path' )?.getAttribute( 'd' );
+}
+
+// `@wordpress/icons` exports elements, so the only way to name the glyph a row
+// drew is to compare it against that icon rendered on its own.
+function iconPath( icon: ReactElement ) {
+ const { container, unmount } = render( icon );
+ const path = glyphPath( container );
+
+ unmount();
+ return path;
+}
+
+// The label text sits next to the glyph inside the row's media wrapper.
+function rowGlyphPath( label: string ) {
+ return glyphPath( screen.getByText( label ).parentElement );
+}
+
+// Queried through the label rather than the accessible name, which the design
+// system extends with its own "opens in a new tab" copy.
+function rowLink( label: string ) {
+ return screen.getByText( label ).closest( 'a' );
+}
+
+describe( 'TagsWidget', () => {
+ beforeEach( () => {
+ queryClient.clear();
+ mockApiFetch.mockReset();
+ mockApiFetch.mockResolvedValue( TAGS_RESPONSE );
+ } );
+
+ it( 'draws the category glyph on a category row and the tag glyph on a tag row', async () => {
+ render( );
+
+ await expect( screen.findByText( 'Recipes' ) ).resolves.toBeInTheDocument();
+
+ const categoryPath = iconPath( category );
+ const tagPath = iconPath( tag );
+
+ expect( categoryPath ).not.toBe( tagPath );
+ expect( rowGlyphPath( 'Recipes' ) ).toBe( categoryPath );
+ expect( rowGlyphPath( 'vegan' ) ).toBe( tagPath );
+ } );
+
+ it( 'links a single tag row and wraps its glyph in the anchor', async () => {
+ render( );
+
+ await expect( screen.findByText( 'vegan' ) ).resolves.toBeInTheDocument();
+
+ const link = rowLink( 'vegan' );
+
+ expect( link ).toHaveAttribute( 'href', 'https://example.com/tag/vegan/' );
+ expect( glyphPath( link ) ).toBe( iconPath( tag ) );
+ } );
+
+ it( 'drills a grouped row into its members and back', async () => {
+ render( );
+
+ const groupButton = await screen.findByRole( 'button', {
+ name: /view the tags and categories in desserts, chocolate/i,
+ } );
+
+ // A grouped row has no combined archive URL, so it must not be a link.
+ expect( rowLink( 'Desserts, chocolate' ) ).toBeNull();
+
+ fireEvent.click( groupButton ); // eslint-disable-line testing-library/prefer-user-event -- @testing-library/user-event is not a direct dep of this package.
+
+ // Members carry their own glyph and archive URL, unlike the group row.
+ await expect( screen.findByText( 'Desserts' ) ).resolves.toBeInTheDocument();
+ expect( rowLink( 'Desserts' ) ).toHaveAttribute(
+ 'href',
+ 'https://example.com/category/desserts/'
+ );
+ expect( rowGlyphPath( 'Desserts' ) ).toBe( iconPath( category ) );
+ expect( rowGlyphPath( 'chocolate' ) ).toBe( iconPath( tag ) );
+
+ fireEvent.click( screen.getByRole( 'button', { name: /all tags & categories/i } ) ); // eslint-disable-line testing-library/prefer-user-event -- @testing-library/user-event is not a direct dep of this package.
+
+ await expect( screen.findByText( 'Recipes' ) ).resolves.toBeInTheDocument();
+ expect( screen.queryByText( 'chocolate' ) ).not.toBeInTheDocument();
+ } );
+} );
diff --git a/projects/packages/premium-analytics/widgets/tags/render.tsx b/projects/packages/premium-analytics/widgets/tags/render.tsx
index 365cc71000c6..1cce2011c84f 100644
--- a/projects/packages/premium-analytics/widgets/tags/render.tsx
+++ b/projects/packages/premium-analytics/widgets/tags/render.tsx
@@ -3,6 +3,7 @@
*/
import {
LeaderboardChart,
+ LeaderboardRow,
LeaderboardSkeleton,
ReportLink,
WIDGET_ROW_LIMIT,
@@ -10,6 +11,8 @@ import {
WidgetFooter,
WidgetRoot,
WidgetState,
+ buildLeaderboardRow,
+ resolveLeaderboardRowAction,
safeHttpUrl,
sharePercentage,
useWidgetDrillDown,
@@ -21,7 +24,7 @@ import { tag as tagIllustration } from '@jetpack-premium-analytics/icons';
import { useEffect, useMemo } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { category, tag as tagGlyph } from '@wordpress/icons';
-import { Icon, Link, Stack } from '@jetpack-premium-analytics/externals';
+import { Stack } from '@jetpack-premium-analytics/externals';
/**
* Internal dependencies
*/
@@ -37,10 +40,6 @@ type TagsWidgetProps = WidgetRenderProps< TagsRenderAttributes >;
// row is a tag.
const rowGlyph = ( labelIcon: string ) => ( labelIcon === 'folder' ? category : tagGlyph );
-// Icon + label fields shared by the leaderboard rows and the drilled-in members;
-// documented on TagChildView.
-type TagLabelProps = Pick< TagChildView, 'labelIcon' | 'label' | 'link' >;
-
interface TagGroupMembersProps {
/**
* The selected group's individual tags/categories.
@@ -48,36 +47,6 @@ interface TagGroupMembersProps {
members: TagChildView[];
}
-/**
- * Icon + label for a single tag/category, shared by the leaderboard rows and the
- * drilled-in group members. A member with an archive URL renders an external
- * link; one without renders plain text.
- */
-function TagLabel( { labelIcon, label, link }: TagLabelProps ) {
- const href = safeHttpUrl( link );
-
- return (
- <>
-
- { href ? (
-
- { label }
-
- ) : (
-
- { label }
-
- ) }
- >
- );
-}
-
/**
* Drilled-in view for a grouped row: the individual tags and categories that
* share the selected group. The Stats endpoint reports only the group's
@@ -87,9 +56,15 @@ function TagGroupMembers( { members }: TagGroupMembersProps ) {
return (
{ members.map( member => (
-
-
-
+
) ) }
);
@@ -130,22 +105,25 @@ function TagsInner() {
return {
id: row.id,
- label: (
-
-
-
- ),
currentValue: row.value,
currentShare: sharePercentage( row.value, maxValue ),
// Grouped rows have no single archive URL, so a click drills into
// their members instead. Single tag/category rows link out directly.
- ...( isGroup && {
- onClick: () => selectGroup( row.label ),
- ariaLabel: sprintf(
- /* translators: %s is the grouped tags and categories label */
- __( 'View the tags and categories in %s', 'jetpack-premium-analytics-pkg' ),
- row.label
- ),
+ ...buildLeaderboardRow( {
+ label: row.label,
+ media: { kind: 'icon', icon: rowGlyph( row.labelIcon ) },
+ action: resolveLeaderboardRowAction( {
+ href: safeHttpUrl( row.link ) ?? undefined,
+ hasChildren: isGroup,
+ drillDown: {
+ onClick: () => selectGroup( row.label ),
+ ariaLabel: sprintf(
+ /* translators: %s is the grouped tags and categories label */
+ __( 'View the tags and categories in %s', 'jetpack-premium-analytics-pkg' ),
+ row.label
+ ),
+ },
+ } ),
} ),
};
} );
diff --git a/projects/packages/premium-analytics/widgets/tags/style.module.css b/projects/packages/premium-analytics/widgets/tags/style.module.css
index c5eef7758cbb..9b90cf0d95bd 100644
--- a/projects/packages/premium-analytics/widgets/tags/style.module.css
+++ b/projects/packages/premium-analytics/widgets/tags/style.module.css
@@ -14,32 +14,6 @@
min-height: 0;
}
-/* Icon + label row for the leaderboard. min-height keeps a stable 36px row for
- both single tag/category rows and grouped (drill-down) rows. */
-.itemLabel {
- gap: var(--wpds-dimension-padding-sm);
- min-height: 36px;
- min-width: 0;
- padding-inline: var(--wpds-dimension-padding-sm);
- overflow: hidden;
-}
-
-/* Keep the category/tag glyph from shrinking when the label is long. */
-.itemIcon {
- flex-shrink: 0;
-}
-
-.itemLabelText {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
-}
-
-a.itemLabelText:hover,
-a.itemLabelText:focus {
- text-decoration: underline;
-}
-
/* Drilled-in group members: a scrollable list of the individual
tags/categories. The Stats endpoint reports no per-member views, so these
rows are links only, without leaderboard bars. */
@@ -48,12 +22,3 @@ a.itemLabelText:focus {
min-height: 0;
overflow-y: auto;
}
-
-.childRow {
- display: flex;
- align-items: center;
- gap: var(--wpds-dimension-padding-sm);
- min-height: 36px;
- padding-inline: var(--wpds-dimension-padding-sm);
- overflow: hidden;
-}
diff --git a/projects/packages/premium-analytics/widgets/top-platforms/render.tsx b/projects/packages/premium-analytics/widgets/top-platforms/render.tsx
index ba68cfb1ca49..4c511f770efc 100644
--- a/projects/packages/premium-analytics/widgets/top-platforms/render.tsx
+++ b/projects/packages/premium-analytics/widgets/top-platforms/render.tsx
@@ -6,7 +6,6 @@ import { device } from '@jetpack-premium-analytics/icons';
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
-import { Stack, Text } from '@jetpack-premium-analytics/externals';
import {
WIDGET_ROW_LIMIT,
calculateDelta,
@@ -14,6 +13,7 @@ import {
getCombinedPeriodMax,
LeaderboardChart,
LeaderboardSkeleton,
+ buildLeaderboardRow,
sharePercentage,
WidgetRoot,
WidgetState,
@@ -66,11 +66,11 @@ function TopPlatformsInner( { platformDimension }: TopPlatformsInnerProps ) {
return {
id: `${ index }-${ item.key }`,
- label: (
-
- { item.label }
-
- ),
+ ...buildLeaderboardRow( {
+ label: item.label,
+ media: { kind: 'none' },
+ action: { kind: 'static' },
+ } ),
currentValue: item.views,
currentShare: sharePercentage( item.views, maxViews ),
previousValue,
diff --git a/projects/packages/premium-analytics/widgets/top-platforms/style.module.css b/projects/packages/premium-analytics/widgets/top-platforms/style.module.css
index cd8e2c0a4822..5a943c435006 100644
--- a/projects/packages/premium-analytics/widgets/top-platforms/style.module.css
+++ b/projects/packages/premium-analytics/widgets/top-platforms/style.module.css
@@ -13,7 +13,3 @@
flex: 1 1 0;
min-height: 0;
}
-
-.itemLabel {
- padding: var(--wpds-dimension-padding-sm);
-}
diff --git a/projects/packages/premium-analytics/widgets/utm-insights/render.tsx b/projects/packages/premium-analytics/widgets/utm-insights/render.tsx
index 35fc257e10fd..858a54bea5a2 100644
--- a/projects/packages/premium-analytics/widgets/utm-insights/render.tsx
+++ b/projects/packages/premium-analytics/widgets/utm-insights/render.tsx
@@ -3,7 +3,6 @@
*/
import { useEffect, useMemo } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
-import { Text } from '@jetpack-premium-analytics/externals';
import {
WIDGET_ROW_LIMIT,
calculateDelta,
@@ -17,6 +16,8 @@ import {
WidgetFooter,
WidgetRoot,
WidgetState,
+ buildLeaderboardRow,
+ resolveLeaderboardRowAction,
sharePercentage,
useWidgetDrillDown,
useWidgetRootContext,
@@ -129,22 +130,35 @@ function UtmInsightsInner( { utmDimension, showReportLink }: UtmInsightsInnerPro
return activeData.map( ( item, index ) => {
const previousValue = item.previousValue;
const postRow = 'postId' in item ? item : null;
+ const hasChildren = ! isDrillDown && 'children' in item && Boolean( item.children?.length );
return {
id: `${ index }-${ item.label }`,
- label: postRow ? (
-
- ) : (
-
-
- { item.label }
-
-
- ),
+ ...( postRow
+ ? {
+ label: (
+
+ ),
+ }
+ : buildLeaderboardRow( {
+ label: item.label,
+ media: { kind: 'none' },
+ action: resolveLeaderboardRowAction( {
+ hasChildren,
+ drillDown: {
+ onClick: () => selectUtmLabel( item.label ),
+ ariaLabel: sprintf(
+ /* translators: %s is the UTM value label. */
+ __( 'View posts for %s', 'jetpack-premium-analytics-pkg' ),
+ item.label
+ ),
+ },
+ } ),
+ } ) ),
currentValue: item.value,
currentShare: sharePercentage( item.value, maxValue ),
previousValue,
@@ -156,16 +170,6 @@ function UtmInsightsInner( { utmDimension, showReportLink }: UtmInsightsInnerPro
withComparison && previousValue !== undefined
? calculateDelta( item.value, previousValue )
: undefined,
- ...( ! isDrillDown &&
- 'children' in item &&
- item.children?.length && {
- onClick: () => selectUtmLabel( item.label ),
- ariaLabel: sprintf(
- /* translators: %s is the UTM value label. */
- __( 'View posts for %s', 'jetpack-premium-analytics-pkg' ),
- item.label
- ),
- } ),
};
} );
}, [ activeData, isDrillDown, selectUtmLabel, withComparison ] );
diff --git a/projects/packages/premium-analytics/widgets/utm-insights/style.module.css b/projects/packages/premium-analytics/widgets/utm-insights/style.module.css
index 61d3a7f3cf76..d38deb672ae8 100644
--- a/projects/packages/premium-analytics/widgets/utm-insights/style.module.css
+++ b/projects/packages/premium-analytics/widgets/utm-insights/style.module.css
@@ -19,19 +19,3 @@
min-inline-size: 0;
margin-block-end: 0;
}
-
-/* Matches the shared leaderboard row so these sit level with the post rows,
- which render through `LeaderboardPostLabel`. */
-.itemLabel {
- display: flex;
- align-items: center;
- min-block-size: 36px;
- min-inline-size: 0;
- padding-inline: var(--wpds-dimension-padding-md);
-}
-
-.itemLabelText {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
-}
diff --git a/projects/packages/premium-analytics/widgets/video-detail-embeds/style.module.css b/projects/packages/premium-analytics/widgets/video-detail-embeds/style.module.css
index 1046179fc116..1b5f03ec5b7b 100644
--- a/projects/packages/premium-analytics/widgets/video-detail-embeds/style.module.css
+++ b/projects/packages/premium-analytics/widgets/video-detail-embeds/style.module.css
@@ -42,7 +42,7 @@
display: block;
min-block-size: 36px;
padding-block: var(--wpds-dimension-padding-sm);
- padding-inline: var(--wpds-dimension-padding-sm);
+ padding-inline: var(--wpds-dimension-padding-md);
overflow: hidden;
color: var(--wpds-color-foreground-interactive-brand);
text-overflow: ellipsis;
diff --git a/projects/plugins/jetpack/changelog/wooa7s-1989-migrate-remaining-labels b/projects/plugins/jetpack/changelog/wooa7s-1989-migrate-remaining-labels
new file mode 100644
index 000000000000..c70ef09eda71
--- /dev/null
+++ b/projects/plugins/jetpack/changelog/wooa7s-1989-migrate-remaining-labels
@@ -0,0 +1,4 @@
+Significance: patch
+Type: enhancement
+
+Premium Analytics: Match the remaining leaderboard row labels to the other widgets.
diff --git a/projects/plugins/premium-analytics/changelog/wooa7s-1989-migrate-remaining-labels b/projects/plugins/premium-analytics/changelog/wooa7s-1989-migrate-remaining-labels
new file mode 100644
index 000000000000..e78493d77075
--- /dev/null
+++ b/projects/plugins/premium-analytics/changelog/wooa7s-1989-migrate-remaining-labels
@@ -0,0 +1,4 @@
+Significance: patch
+Type: changed
+
+Leaderboards: Match the remaining row labels to the other leaderboard widgets.