Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions projects/packages/premium-analytics/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ area. Notes:
- `isFetching` draws nothing — it only marks the widget `aria-busy`. A revalidation of unchanged
params leaves the right numbers on screen, and blanking them reports a refresh nobody asked for
(WOOA7S-1934). Nothing unmounts, so children keep their own state and keyboard focus.
- Every other branch *does* unmount the children, and a drill-down reaches the skeleton by
- Every other branch _does_ unmount the children, and a drill-down reaches the skeleton by
definition (it changes the params). `<WidgetState>` catches the focus that would otherwise fall
to `<body>` and parks it on its own root, so the next Tab continues from the widget instead of
the top of the page. Widgets need do nothing for this, but drill-down rows must be real
Expand Down Expand Up @@ -759,10 +759,10 @@ wire a handler in `routeStatsReport()` inside `register-report-mocks.ts`. See
add a second in-widget `<Text variant="heading-md" render={ <h3 /> }>` title for framed Stats
widgets.
- View count format: `dataFormat={ { type: 'number', options: { useMultipliers: true, decimals: 0 } } }`
- Leaderboard row height: custom labels should produce a stable 36px row height. For the common
`<Text>` label case, `padding: var(--wpds-dimension-padding-sm)` is enough when the text
line-height plus vertical padding yields 36px. Use `min-height: 36px` when the label content
or typography does not naturally produce that height.
- 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.
- Loading / error / empty state: render through `<WidgetState>` (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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Leaderboards: Give shared rows one row height, bar radius, and link hover.
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,8 @@ It applies the shared precedence: drill-down for rows with children, external li
childless rows, and static content otherwise.

Use `LeaderboardLabel` directly for media plus truncating text outside chart rows, such as a
DataViews table cell. It deliberately does not add the chart row's 36px minimum block size.

### Row layout

`LeaderboardRow` takes two optional layout props. `LeaderboardPostLabel` accepts both and
forwards them.

| Prop | Default | Description |
| ----------- | ----------- | ----------------------------------------------------------------------------------------------------------- |
| `variant` | `'compact'` | `'compact'` is the standard 36px row. `'overlay'` drops that floor and takes its height from block padding. |
| `className` | - | Extra class on the row, for per-widget spacing. |

Pick `variant` to match the sibling rows in the same widget, not the chart's `withOverlayLabel`
prop. That prop only tints the bar fill; it sets no row height. Use `'overlay'` where the
neighbouring rows also take their height from block padding, and `'compact'` where they come
from `buildLeaderboardRow`.
DataViews table cell. It deliberately does not add the chart row's 36px minimum block size or its
inline padding.

## Props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ export type {
LeaderboardRowActionOptions,
LeaderboardRowChartProps,
LeaderboardRowProps,
LeaderboardRowVariant,
} from './leaderboard-row';
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
min-block-size: 36px;
min-inline-size: 0;
max-inline-size: 100%;
padding-inline: var(--wpds-dimension-padding-sm);
padding-inline: var(--wpds-dimension-padding-md);
overflow: hidden;
color: inherit;
text-decoration: none;
Expand All @@ -72,13 +72,11 @@
gap: var(--wpds-dimension-gap-xs);
}

/* Block padding sets the bar height when the label sits on top of the bar, so
the 36px floor is dropped. Doubled with the base class to beat it on
specificity rather than on stylesheet order. */
.overlay.row,
.overlay.rowLink {
min-block-size: 0;
padding-block: var(--wpds-dimension-padding-md);
/* The design system renders the external-link arrow as a sibling of the
label, so the colour has to go on the anchor to reach it. */
.rowLink:hover,
.rowLink:focus {
color: var(--wpds-color-foreground-interactive-brand);
}

.rowLink:hover .label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import { Link } from '@jetpack-premium-analytics/externals';
import clsx from 'clsx';
/**
* Internal dependencies
*/
Expand Down Expand Up @@ -34,13 +33,6 @@ export type LeaderboardRowAction =
}
| { kind: 'static' };

/**
* How tall the row sits. `compact` is the standard 36px row. `overlay` suits
* leaderboards that draw the label on top of the bar, where block padding sets
* the bar height because the row has no image to size it.
*/
export type LeaderboardRowVariant = 'compact' | 'overlay';

export type LeaderboardRowActionOptions = {
/** An external destination used only when the row has no children. */
href?: string;
Expand All @@ -57,10 +49,6 @@ export type LeaderboardRowProps = {
media: LeaderboardRowMedia;
/** The mutually exclusive action applied to this chart row. */
action: LeaderboardRowAction;
/** Row height. Defaults to `compact`. */
variant?: LeaderboardRowVariant;
/** Extra class for the row, for per-widget spacing. */
className?: string;
};

export type LeaderboardRowChartProps =
Expand Down Expand Up @@ -105,17 +93,7 @@ export function resolveLeaderboardRowAction(
*
* @return A single label element accepted by `LeaderboardEntry.label`.
*/
export function LeaderboardRow( {
label,
media,
action,
variant = 'compact',
className,
}: LeaderboardRowProps ): ReactElement {
const variantClass = variant === 'overlay' ? styles.overlay : undefined;
const rowClassName = clsx( styles.row, variantClass, className );
const linkClassName = clsx( styles.rowLink, variantClass, className );

export function LeaderboardRow( { label, media, action }: LeaderboardRowProps ): ReactElement {
// Post rows carry no media, so the row chrome goes on the anchor itself.
if ( action.kind === 'postLink' ) {
return (
Expand All @@ -126,9 +104,9 @@ export function LeaderboardRow( {
search={ action.search }
title={ label }
classNames={ {
internal: linkClassName,
external: linkClassName,
plain: rowClassName,
internal: styles.rowLink,
external: styles.rowLink,
plain: styles.row,
text: styles.label,
} }
/>
Expand All @@ -142,7 +120,7 @@ export function LeaderboardRow( {
if ( action.kind === 'link' ) {
return (
<Link
className={ linkClassName }
className={ styles.rowLink }
href={ action.href }
variant="unstyled"
openInNewTab
Expand All @@ -154,7 +132,7 @@ export function LeaderboardRow( {
}

return (
<span className={ rowClassName } title={ label }>
<span className={ styles.row } title={ label }>
{ content }
</span>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export {
type LeaderboardRowChartProps,
type LeaderboardRowMedia,
type LeaderboardRowProps,
type LeaderboardRowVariant,
} from './chart-leaderboard';
export {
BarChart,
Expand Down Expand Up @@ -86,11 +85,7 @@ export { WidgetFooter, type WidgetFooterProps } from './widget-footer';
export { ReportLink, type ReportLinkProps } from './report-link';
export { PostTitleLink, POST_URL_SEARCH_PARAM, type PostTitleLinkProps } from './post-title-link';
export { PostDetailLink, type PostDetailLinkProps } from './post-detail-link';
export {
LeaderboardPostLabel,
type LeaderboardPostLabelProps,
type LeaderboardPostLabelVariant,
} from './leaderboard-post-label';
export { LeaderboardPostLabel, type LeaderboardPostLabelProps } from './leaderboard-post-label';
export {
PostHighlightCard,
PostHighlightCardSkeleton,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export {
LeaderboardPostLabel,
type LeaderboardPostLabelProps,
type LeaderboardPostLabelVariant,
} from './leaderboard-post-label';
export { LeaderboardPostLabel, type LeaderboardPostLabelProps } from './leaderboard-post-label';
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
* Internal dependencies
*/
import { useWidgetNavigationSearch } from '../../hooks/use-widget-navigation-search';
import { LeaderboardRow, type LeaderboardRowVariant } from '../chart-leaderboard/leaderboard-row';
import { LeaderboardRow } from '../chart-leaderboard/leaderboard-row';
import type { ReactElement } from 'react';

/** How tall the row sits. */
export type LeaderboardPostLabelVariant = LeaderboardRowVariant;

export type LeaderboardPostLabelProps = {
/**
* Post or page ID. Rows carrying one link to the internal detail route.
Expand All @@ -22,14 +19,6 @@ export type LeaderboardPostLabelProps = {
* Optional detail-page tab to open, e.g. `email-opens`.
*/
section?: string;
/**
* Row height. Defaults to `compact`.
*/
variant?: LeaderboardPostLabelVariant;
/**
* Extra class for the row, for per-widget spacing.
*/
className?: string;
};

/**
Expand All @@ -42,8 +31,6 @@ export function LeaderboardPostLabel( {
label,
link,
section,
variant = 'compact',
className,
}: LeaderboardPostLabelProps ): ReactElement {
const search = useWidgetNavigationSearch( section );

Expand All @@ -52,8 +39,6 @@ export function LeaderboardPostLabel( {
label={ label }
media={ { kind: 'none' } }
action={ { kind: 'postLink', id, href: link, search } }
variant={ variant }
className={ className }
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function useChartTheme(): WooChartTheme {
rowGap: 4,
columnGap: 4,
labelSpacing: 'xs',
barBorderRadius: 'var(--wpds-border-radius-md)',
barBorderRadius: 'var(--wpds-border-radius-lg)',
deltaColors: [
'var(--wpds-color-stroke-surface-error-strong)',
'var(--wpds-color-foreground-content-neutral-weak)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export {
type LeaderboardRowChartProps,
type LeaderboardRowMedia,
type LeaderboardRowProps,
type LeaderboardRowVariant,
BarChart,
BarChartSkeleton,
type BarChartProps,
Expand Down Expand Up @@ -85,7 +84,6 @@ export {
type PostDetailLinkProps,
LeaderboardPostLabel,
type LeaderboardPostLabelProps,
type LeaderboardPostLabelVariant,
PostHighlightCard,
PostHighlightCardSkeleton,
type PostHighlightCardMetric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ function UtmInsightsInner( { utmDimension, showReportLink }: UtmInsightsInnerPro
id={ postRow.postId }
label={ postRow.label }
link={ postRow.href }
variant="overlay"
className={ styles.itemLabelInset }
/>
) : (
<span className={ styles.itemLabel }>
<Text className={ styles.itemLabelText }>{ item.label }</Text>
<Text className={ styles.itemLabelText } variant="body-sm">
{ item.label }
</Text>
</span>
),
currentValue: item.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,14 @@
margin-block-end: 0;
}

/* The UTM value rows. Post rows use `LeaderboardPostLabel` instead and take
only the inline-end inset below. */
/* 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-block: var(--wpds-dimension-padding-md);
padding-inline-start: var(--wpds-dimension-padding-sm);
padding-inline-end: var(--wpds-dimension-padding-lg);
}

/* Keeps post-row text short of the value column, like `.itemLabel`. Doubled to
outrank the shared row's own `padding-inline` on specificity, because the two
are single classes in different CSS modules and would tie on order. */
.itemLabelInset.itemLabelInset {
padding-inline-end: var(--wpds-dimension-padding-lg);
padding-inline: var(--wpds-dimension-padding-md);
}

.itemLabelText {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

Premium Analytics: Give shared leaderboard rows one row height, bar radius, and link hover.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Leaderboards: Give shared rows one row height, bar radius, and link hover.
Loading