From 16b43705d9eab7c3d91af0bf72c84d7f405bc45f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Tue, 3 Nov 2026 13:03:56 +0000 Subject: [PATCH 1/9] add CardTabs primitive to premium-analytics ui Base UI tabs on WPDS tokens, mirroring the Tabs API of @wordpress/ui --- pnpm-lock.yaml | 3 + .../premium-analytics/eslint.config.mjs | 14 ++ .../packages/premium-analytics/package.json | 1 + .../card-tabs/__tests__/card-tabs.test.tsx | 90 +++++++++++++ .../ui/src/card-tabs/card-tabs.module.scss | 88 +++++++++++++ .../packages/ui/src/card-tabs/card-tabs.tsx | 72 ++++++++++ .../packages/ui/src/card-tabs/index.ts | 7 + .../card-tabs/stories/card-tabs.stories.tsx | 123 ++++++++++++++++++ .../packages/ui/src/card-tabs/types.ts | 21 +++ .../packages/ui/src/index.ts | 1 + 10 files changed, 420 insertions(+) create mode 100644 projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx create mode 100644 projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss create mode 100644 projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx create mode 100644 projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts create mode 100644 projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx create mode 100644 projects/packages/premium-analytics/packages/ui/src/card-tabs/types.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 76a1dce81e84..059bf43c7505 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4182,6 +4182,9 @@ importers: '@automattic/number-formatters': specifier: workspace:* version: link:../../js-packages/number-formatters + '@base-ui/react': + specifier: 1.9.0 + version: 1.9.0(@date-fns/tz@1.5.0)(@types/react@19.3.0)(date-fns@4.4.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) '@date-fns/tz': specifier: 1.5.0 version: 1.5.0 diff --git a/projects/packages/premium-analytics/eslint.config.mjs b/projects/packages/premium-analytics/eslint.config.mjs index d4c551c4ffa8..fdf45f96cc2f 100644 --- a/projects/packages/premium-analytics/eslint.config.mjs +++ b/projects/packages/premium-analytics/eslint.config.mjs @@ -169,6 +169,14 @@ export default defineConfig( message: 'Import these from @jetpack-premium-analytics/externals instead: it compiles them once into a shared script module rather than into every module that imports them. Missing an export? Add it to packages/externals/src/index.ts.', }, + { + // Base UI is what `@wordpress/ui` builds on. It is + // compiled into `packages/ui` for `CardTabs` and nowhere + // else, so a second copy is never bundled by accident. + regex: '^@base-ui/react(/.*)?$', + message: + 'Build on @wordpress/ui from @jetpack-premium-analytics/externals, or on CardTabs from @jetpack-premium-analytics/ui. Base UI itself is compiled into packages/ui only.', + }, ], }, ], @@ -209,6 +217,12 @@ export default defineConfig( message: 'Import these from @jetpack-premium-analytics/externals instead: it compiles them once into a shared script module rather than into every bundle that imports them. Missing an export? Add it to packages/externals/src/index.ts.', }, + { + // Same as the packages rule above. + regex: '^@base-ui/react(/.*)?$', + message: + 'Build on @wordpress/ui from @jetpack-premium-analytics/externals, or on CardTabs from @jetpack-premium-analytics/ui. Base UI itself is compiled into packages/ui only.', + }, ], }, ], diff --git a/projects/packages/premium-analytics/package.json b/projects/packages/premium-analytics/package.json index 2d26f037e69e..afb12f11074e 100644 --- a/projects/packages/premium-analytics/package.json +++ b/projects/packages/premium-analytics/package.json @@ -47,6 +47,7 @@ "@automattic/jetpack-connection": "workspace:*", "@automattic/jetpack-script-data": "workspace:*", "@automattic/number-formatters": "workspace:*", + "@base-ui/react": "1.9.0", "@date-fns/tz": "1.5.0", "@jetpack-premium-analytics/data": "link:packages/data", "@jetpack-premium-analytics/datetime": "link:packages/datetime", diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx new file mode 100644 index 000000000000..4a2f84a9bb58 --- /dev/null +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx @@ -0,0 +1,90 @@ +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { isRTL } from '@wordpress/i18n'; +import { act } from 'react'; +import * as CardTabs from '../card-tabs'; + +jest.mock( '@wordpress/i18n', () => ( { + ...jest.requireActual( '@wordpress/i18n' ), + isRTL: jest.fn( () => false ), +} ) ); + +const METRICS = [ + { key: 'orders', label: 'Orders' }, + { key: 'visitors', label: 'Visitors' }, + { key: 'revenue', label: 'Revenue' }, +]; + +function renderCardTabs( { disabledKey }: { disabledKey?: string } = {} ) { + const onValueChange = jest.fn(); + + render( + + + { METRICS.map( metric => ( + + { metric.label } + + ) ) } + + { METRICS.map( metric => ( + + { metric.label } chart + + ) ) } + + ); + + return { onValueChange }; +} + +describe( 'CardTabs', () => { + beforeEach( () => { + jest.mocked( isRTL ).mockReturnValue( false ); + } ); + + it( 'shows the selected card’s panel, labelled by the card, and reports a click on another', async () => { + const user = userEvent.setup(); + const { onValueChange } = renderCardTabs(); + + const selected = screen.getByRole( 'tab', { name: 'Visitors' } ); + expect( selected ).toHaveAttribute( 'aria-selected', 'true' ); + expect( screen.getByRole( 'tabpanel' ) ).toHaveAttribute( 'aria-labelledby', selected.id ); + expect( screen.getByRole( 'tabpanel' ) ).toHaveTextContent( 'Visitors chart' ); + expect( screen.queryByText( 'Orders chart' ) ).not.toBeInTheDocument(); + + await user.click( screen.getByRole( 'tab', { name: 'Orders' } ) ); + + expect( onValueChange ).toHaveBeenCalledWith( 'orders', expect.anything() ); + } ); + + it( 'moves between cards with the arrow keys and selects only on Enter', async () => { + const user = userEvent.setup(); + const { onValueChange } = renderCardTabs( { disabledKey: 'revenue' } ); + + act( () => screen.getByRole( 'tab', { name: 'Visitors' } ).focus() ); + await user.keyboard( '{ArrowLeft}' ); + + expect( screen.getByRole( 'tab', { name: 'Orders' } ) ).toHaveFocus(); + expect( onValueChange ).not.toHaveBeenCalled(); + + await user.keyboard( '{Enter}' ); + + expect( onValueChange ).toHaveBeenCalledWith( 'orders', expect.anything() ); + } ); + + it( 'follows the text direction, so the left arrow moves forward in RTL', async () => { + jest.mocked( isRTL ).mockReturnValue( true ); + const user = userEvent.setup(); + renderCardTabs(); + + act( () => screen.getByRole( 'tab', { name: 'Orders' } ).focus() ); + await user.keyboard( '{ArrowLeft}' ); + + expect( screen.getByRole( 'tab', { name: 'Visitors' } ) ).toHaveFocus(); + } ); +} ); diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss new file mode 100644 index 000000000000..996b53dcd363 --- /dev/null +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss @@ -0,0 +1,88 @@ +/* A card's narrowest inline size before the row wraps. No WPDS dimension + * token reaches this far; a consumer tunes it through + * `--jpa-card-tabs-min-inline-size`, as it tunes the gap and the padding. */ +$card-tabs-min-inline-size: 10rem; + +/* As many cards to a row as fit at their minimum size, every row sharing the + * width evenly. A consumer that balances its rows sets + * `--jpa-card-tabs-columns` instead. */ +.list { + display: grid; + grid-template-columns: repeat(var(--jpa-card-tabs-columns, auto-fit), minmax(min(100%, var(--jpa-card-tabs-min-inline-size, #{$card-tabs-min-inline-size})), 1fr)); + gap: var(--jpa-card-tabs-gap, var(--wpds-dimension-gap-sm)); + min-inline-size: 0; +} + +/* A card draws its own box, so there is no indicator to hide. The selected + * card's fill marks the selection; the other states take the interactive + * tokens Button and Tabs share. */ +.tab { + display: flex; + align-items: flex-start; + inline-size: 100%; + min-inline-size: 0; + margin: 0; + padding: var(--jpa-card-tabs-padding, var(--wpds-dimension-padding-md)); + overflow: hidden; + border: 0; + border-radius: var(--wpds-border-radius-lg); + background-color: var(--wpds-color-background-interactive-neutral-weak); + color: var(--wpds-color-foreground-interactive-neutral); + font: inherit; + text-align: start; + cursor: var(--wpds-cursor-control); + appearance: none; + + /* Drawn inside the card, so the widget chrome's `overflow` cannot clip it. + * Transparent until focused; forced colors paint it regardless. */ + outline: var(--wpds-border-width-focus) solid transparent; + outline-offset: calc(-1 * var(--wpds-border-width-focus)); + + @media not (prefers-reduced-motion) { + transition: background-color 0.1s linear; + } +} + +.tab:focus-visible { + outline-color: var(--wpds-color-stroke-focus); +} + +.tab:not([data-disabled]):not([aria-selected="true"]):is(:hover, :active) { + background-color: var(--wpds-color-background-interactive-neutral-weak-active); + color: var(--wpds-color-foreground-interactive-neutral-active); +} + +.tab[aria-selected="true"] { + background-color: var(--wpds-color-background-interactive-brand-weak-active); + cursor: default; +} + +.tab[data-disabled] { + color: var(--wpds-color-foreground-interactive-neutral-disabled); + cursor: default; +} + +/* Fills do not survive forced colors, so the selected card doubles its edge. */ +@media (forced-colors: active) { + + .tab[aria-selected="true"] { + outline-width: var(--wpds-border-width-md); + outline-style: double; + } + + .tab[data-disabled] { + color: GrayText; + } +} + +.panel { + min-inline-size: 0; + min-block-size: 0; +} + +/* The panel is a tab stop of its own, so it takes the outset ring `Tabs` + * gives its panel. */ +.panel:focus-visible { + outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus); + outline-offset: var(--wpds-border-width-focus); +} diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx new file mode 100644 index 000000000000..45c1c101f0bb --- /dev/null +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx @@ -0,0 +1,72 @@ +/** + * External dependencies + */ +// eslint-disable-next-line no-restricted-imports -- The one module that compiles Base UI in; see the ESLint rule. +import { DirectionProvider } from '@base-ui/react/direction-provider'; +// eslint-disable-next-line no-restricted-imports -- The one module that compiles Base UI in; see the ESLint rule. +import { Tabs } from '@base-ui/react/tabs'; +import { isRTL } from '@wordpress/i18n'; +import clsx from 'clsx'; +import { forwardRef } from 'react'; +/** + * Internal dependencies + */ +import styles from './card-tabs.module.scss'; +import type { + CardTabsListProps, + CardTabsPanelProps, + CardTabsRootProps, + CardTabsTabProps, +} from './types'; + +/** + * Groups the cards and their panels: the `Tabs` of `@wordpress/ui` with each + * tab drawn as a card, whose fill marks the selection. + */ +export const Root = forwardRef< HTMLDivElement, CardTabsRootProps >( + function CardTabsRoot( props, forwardedRef ) { + return ( + + + + ); + } +); + +/** The row of cards, wrapping as the room runs out. */ +export const List = forwardRef< HTMLDivElement, CardTabsListProps >( function CardTabsList( + { className, ...otherProps }, + forwardedRef +) { + return ( + + ); +} ); + +/** A card: a button that shows its panel when activated. */ +export const Tab = forwardRef< HTMLButtonElement, CardTabsTabProps >( function CardTabsTab( + { className, ...otherProps }, + forwardedRef +) { + return ( + + ); +} ); + +/** The panel shown while its card is selected. */ +export const Panel = forwardRef< HTMLDivElement, CardTabsPanelProps >( function CardTabsPanel( + { className, ...otherProps }, + forwardedRef +) { + return ( + + ); +} ); diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts b/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts new file mode 100644 index 000000000000..1af90660d965 --- /dev/null +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts @@ -0,0 +1,7 @@ +export { List, Panel, Root, Tab } from './card-tabs'; +export type { + CardTabsListProps, + CardTabsPanelProps, + CardTabsRootProps, + CardTabsTabProps, +} from './types'; diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx new file mode 100644 index 000000000000..7f57ca2663b6 --- /dev/null +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx @@ -0,0 +1,123 @@ +/** + * External dependencies + */ +import { useState } from 'react'; +/** + * Internal dependencies + */ +import * as CardTabs from '../card-tabs'; +import type { Meta, StoryObj } from '@storybook/react'; +import type { ComponentProps } from 'react'; + +/** The Store performance cards, as the widget lays them out. */ +const METRICS = [ + { key: 'orders', label: 'Orders', value: '143' }, + { key: 'visitors', label: 'Store visitors', value: '27' }, + { key: 'conversion', label: 'Conversion rate', value: '3.2%' }, + { key: 'revenue', label: 'Revenue', value: '$1,284' }, +]; + +interface CardTabsStoryControls { + containerWidth: number; + activateOnFocus: boolean; + disableLast: boolean; +} + +/** + * Four metric cards over a panel, inside a horizontally resizable container + * that stands in for a widget of that width. + */ +function CardTabsStory( { containerWidth, activateOnFocus, disableLast }: CardTabsStoryControls ) { + const [ value, setValue ] = useState( METRICS[ 0 ].key ); + + return ( +
+ + + { METRICS.map( ( metric, index ) => ( + + + { metric.label } + + { metric.value } + + + + ) ) } + + { METRICS.map( metric => ( + + { metric.label } chart + + ) ) } + +
+ ); +} + +const meta = { + title: 'Packages/Premium Analytics/UI/CardTabs', + component: CardTabs.Root, + tags: [ 'autodocs' ], + argTypes: { + containerWidth: { + control: { type: 'range', min: 240, max: 960, step: 8 }, + description: 'Width of the container, standing in for the widget.', + }, + activateOnFocus: { + control: 'boolean', + description: 'Select a card as the arrow keys reach it, instead of on Enter or Space.', + }, + disableLast: { + control: 'boolean', + description: 'Disable the last card.', + }, + }, + parameters: { + layout: 'padded', + docs: { + description: { + component: + 'The `Tabs` of `@wordpress/ui` with each tab drawn as a card: Base UI tabs underneath, the selected card marked by its fill rather than an indicator, and the design system’s interactive tokens for every state. The row wraps on its own once the cards would fall under their minimum width; the gap, padding and that width are tuned through the `--jpa-card-tabs-*` custom properties.', + }, + }, + }, +} satisfies Meta< ComponentProps< typeof CardTabs.Root > & CardTabsStoryControls >; + +export default meta; + +type Story = StoryObj< CardTabsStoryControls >; + +/** Room for every card on one row. */ +export const Default: Story = { + render: args => , + args: { containerWidth: 720, activateOnFocus: false, disableLast: false }, +}; + +/** A container too narrow for one row: the cards wrap into two. */ +export const Wrapping: Story = { + render: args => , + args: { containerWidth: 360, activateOnFocus: false, disableLast: false }, +}; diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/types.ts b/projects/packages/premium-analytics/packages/ui/src/card-tabs/types.ts new file mode 100644 index 000000000000..a7379f9540aa --- /dev/null +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/types.ts @@ -0,0 +1,21 @@ +/** + * External dependencies + */ +// eslint-disable-next-line no-restricted-imports -- Type-only; the parts come from the one module that compiles Base UI in. +import type { Tabs } from '@base-ui/react/tabs'; +import type { ComponentPropsWithoutRef, CSSProperties, ElementType, ReactNode } from 'react'; + +/** Base UI's props with `className` and `style` narrowed to plain values, as `@wordpress/ui` narrows its own. */ +type PartProps< Part extends ElementType > = Omit< + ComponentPropsWithoutRef< Part >, + 'className' | 'style' | 'children' +> & { + className?: string; + style?: CSSProperties; + children?: ReactNode; +}; + +export type CardTabsRootProps = PartProps< typeof Tabs.Root >; +export type CardTabsListProps = PartProps< typeof Tabs.List >; +export type CardTabsTabProps = PartProps< typeof Tabs.Tab >; +export type CardTabsPanelProps = PartProps< typeof Tabs.Panel >; diff --git a/projects/packages/premium-analytics/packages/ui/src/index.ts b/projects/packages/premium-analytics/packages/ui/src/index.ts index e6877b4a9bdd..dc44800f7ac9 100644 --- a/projects/packages/premium-analytics/packages/ui/src/index.ts +++ b/projects/packages/premium-analytics/packages/ui/src/index.ts @@ -1,3 +1,4 @@ +export * as CardTabs from './card-tabs'; export { DataViewsDrilldownNative, type DataViewsDrilldownNativeProps, From 8ecd0d6e7e5ba35358e22567a4a062a7f96350ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Tue, 3 Nov 2026 13:04:02 +0000 Subject: [PATCH 2/9] add render passthrough to metric comparison lets a card render the value and delta as spans inside a button --- .../src/components/metric-delta/metric-delta.tsx | 11 ++++++++++- .../metric-with-comparison.tsx | 14 +++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-delta/metric-delta.tsx b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-delta/metric-delta.tsx index 5cb8e14670ee..5c73cb8978fe 100644 --- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-delta/metric-delta.tsx +++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-delta/metric-delta.tsx @@ -35,6 +35,9 @@ export type MetricDeltaProps = { className?: string; + /** The element the delta renders as, for a spot that allows phrasing content only, such as a button. */ + render?: ComponentProps< typeof Stack >[ 'render' ]; + /** * Text alignment * @default 'center' @@ -80,6 +83,7 @@ export function MetricDelta( { hideZero = false, invertColors = false, className, + render, justify = 'center', showAbsolute = false, absoluteFormat = 'number', @@ -90,7 +94,11 @@ export function MetricDelta( { if ( percentageChange === null ) { return ( - + { fallback } ); @@ -117,6 +125,7 @@ export function MetricDelta( { return ( [ 'render' ]; + /** * What to display for delta when calculation is not possible */ @@ -86,6 +89,7 @@ export function MetricWithComparison( { invertDeltaColors = false, hideDeltaOnZero = false, className, + render, deltaFallback, showAbsoluteDelta = false, }: MetricWithComparisonProps ) { @@ -94,11 +98,19 @@ export function MetricWithComparison( { const absoluteFormat = dataFormat.type === 'currency' ? 'currency' : 'number'; return ( - + { showDelta && ( Date: Tue, 3 Nov 2026 13:04:05 +0000 Subject: [PATCH 3/9] draw metric tabs chart cards on CardTabs drops every override of the Tabs internals from the stylesheet --- .../changelog/update-card-tabs-primitive | 4 ++ .../__tests__/metric-tabs-chart.test.tsx | 2 +- .../metric-tabs-chart.module.scss | 65 +++---------------- .../metric-tabs-chart/metric-tabs-chart.tsx | 34 +++++----- .../changelog/update-card-tabs-primitive | 4 ++ .../changelog/update-card-tabs-primitive | 4 ++ 6 files changed, 41 insertions(+), 72 deletions(-) create mode 100644 projects/packages/premium-analytics/changelog/update-card-tabs-primitive create mode 100644 projects/plugins/jetpack/changelog/update-card-tabs-primitive create mode 100644 projects/plugins/premium-analytics/changelog/update-card-tabs-primitive diff --git a/projects/packages/premium-analytics/changelog/update-card-tabs-primitive b/projects/packages/premium-analytics/changelog/update-card-tabs-primitive new file mode 100644 index 000000000000..db9aee56fcea --- /dev/null +++ b/projects/packages/premium-analytics/changelog/update-card-tabs-primitive @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Metric cards: Draw the cards on their own tabs primitive, taking the design system’s hover, selected and focus states. diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx index dc84fc63d744..010754e75efb 100644 --- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx +++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx @@ -222,7 +222,7 @@ describe( 'MetricTabsChart', () => { render( ); expect( - screen.getByRole( 'tablist' ).style.getPropertyValue( '--jpa-metric-tabs-columns' ) + screen.getByRole( 'tablist' ).style.getPropertyValue( '--jpa-card-tabs-columns' ) ).toBe( columns ); } ); diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.module.scss b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.module.scss index 1a7c0318f667..bb5b35338e02 100644 --- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.module.scss +++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.module.scss @@ -15,10 +15,7 @@ min-height: 0; } -/* Keeps the tabs' `z-index` inside the header, so the chart's tooltip, which - comes later in the source, paints above them. */ .header { - isolation: isolate; display: flex; flex-direction: row; flex-wrap: wrap; @@ -28,16 +25,12 @@ gap: var(--wpds-dimension-gap-md); } -/* Equal-width cards fill the room left by the controls. The component sets the - * column count that balances the rows; until it measures, or beside controls, - * as many cards as fit share a row. The minimum matches `MIN_CARD_WIDTH`. */ +/* The cards fill the room left by the controls. Until the component measures, + * or beside controls, as many cards as fit share a row; measured, it sets the + * column count that balances the rows. */ .tabs { - display: grid; flex: 1 1 auto; - grid-template-columns: repeat(var(--jpa-metric-tabs-columns, auto-fit), minmax(min(100%, 160px), 1fr)); - gap: var(--wpds-dimension-gap-sm); min-width: 0; - overflow: visible; } /* Dropdown mode (narrow tiles): the selected-metric card is the trigger. */ @@ -60,9 +53,8 @@ padding-block: var(--wpds-dimension-padding-md); } -/* Draw the focus ring inside the card; the default outset ring gets clipped +/* Draw the focus ring inside the trigger; the default outset ring gets clipped * by the widget chrome's `overflow: auto`. */ -.tab, .metricSelect [class*="trigger-wrapper"] { outline-offset: calc(-1 * var(--wpds-border-width-focus)); } @@ -72,57 +64,19 @@ text-align: start; } +/* The card is the container the value's `cqi` clamp below measures against. */ .tab { container-type: inline-size; - height: auto; - min-width: 0; - overflow: hidden; - padding: var(--wpds-dimension-padding-md); - border-radius: var(--wpds-border-radius-lg); -} - -/* Hide the selection underline; the card fill shows selection instead. Older - * `@wordpress/ui` rendered the indicator as a per-tab ``; newer versions - * render it as a tablist-level presentation span. Hide whichever is present. */ -.tab > svg { - display: none; -} - -.root [role="tablist"] [role="presentation"] { - display: none; -} - -.tab:hover, -.tab[aria-selected="true"] { - background-color: var(--wpds-color-background-surface-brand); -} - -/* The Tab paints its hover fill and focus ring on `::after`, sized for a 48px - * tab. Stretch it to the card so the ring follows the card edge, and drop its - * fill, which the card fill above replaces. */ -.tab::after { - inset: 0; - border-radius: inherit; - outline-offset: calc(-1 * var(--wpds-border-width-focus)); - background-color: transparent; - box-shadow: none; } /* A lone metric has nothing to switch to: it reads as the widget's headline - * figure rather than a control, so it drops the card fill and the pointer. */ + * figure rather than a control, so it keeps the card's inset and no fill. */ .singleMetric .tab { - cursor: default; -} - -/* A static headline has no selected or hover state. */ -.singleMetric .tab:hover { - background-color: transparent; + padding: var(--wpds-dimension-padding-md); } -/* Each tab's content: label stacked over the value + delta, start-aligned. - * Growing to fill is what keeps it against the card's leading edge — the - * tablist centres a tab's children, which shows as soon as a card is wider - * than its text. */ +/* Each card's content: label stacked over the value + delta, start-aligned + * and growing to fill the card. */ .tabContent { display: flex; flex: 1 1 auto; @@ -138,6 +92,7 @@ max-width: 100%; overflow: hidden; text-overflow: ellipsis; + white-space: nowrap; } /* Prefer moving the delta below the value over painting into the next card. */ diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.tsx b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.tsx index 483fef63bef4..e4b715557348 100644 --- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.tsx +++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.tsx @@ -3,7 +3,6 @@ */ import { SelectControl, - Tabs, Text, VisuallyHidden, mixHexColors, @@ -11,6 +10,7 @@ import { useGlobalChartsContext, type TickResolution, } from '@jetpack-premium-analytics/externals'; +import { CardTabs } from '@jetpack-premium-analytics/ui'; import { useResizeObserver } from '@wordpress/compose'; import { __ } from '@wordpress/i18n'; import clsx from 'clsx'; @@ -43,7 +43,7 @@ import type { ComponentProps, CSSProperties, ReactNode } from 'react'; */ const MIN_TAB_WIDTH = 120; -/** Narrowest card (px) before the cards wrap; keep in step with `.tabs` in the stylesheet. */ +/** Narrowest card (px) before the cards wrap, handed to the list as `--jpa-card-tabs-min-inline-size`. */ const MIN_CARD_WIDTH = 160; /** The gap (px) between cards, `--wpds-dimension-gap-sm`. */ @@ -572,7 +572,7 @@ function MetricTabContent( { return ( { hideLabelFromVision ? ( - { metric.label } + }>{ metric.label } ) : ( { metric.label } ) } @@ -594,6 +594,7 @@ function MetricTabContent( { ) : ( } className={ styles.metricComparison } value={ metric.value } previousValue={ metric.previousValue } @@ -603,7 +604,7 @@ function MetricTabContent( { align="flex-end" /> ) } - { note && { note } } + { note && }>{ note } } ); } @@ -830,38 +831,39 @@ export function MetricTabsChart( { } return ( -
- { metrics.map( metric => ( - - + ) ) } - + { controls }
- { /* One panel per tab (WAI-ARIA + @wordpress/ui parity). Only the active - metric's panel renders its chart; the rest stay empty. */ } + { /* One panel per tab, as WAI-ARIA asks; Base UI mounts only the selected one. */ } { metrics.map( metric => ( - - + ) ) } -
+ ); } diff --git a/projects/plugins/jetpack/changelog/update-card-tabs-primitive b/projects/plugins/jetpack/changelog/update-card-tabs-primitive new file mode 100644 index 000000000000..a4dcdbb752b9 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-card-tabs-primitive @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Premium Analytics: Give the metric cards the design system’s hover, selected and focus states. diff --git a/projects/plugins/premium-analytics/changelog/update-card-tabs-primitive b/projects/plugins/premium-analytics/changelog/update-card-tabs-primitive new file mode 100644 index 000000000000..e5574021af38 --- /dev/null +++ b/projects/plugins/premium-analytics/changelog/update-card-tabs-primitive @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Metric cards: Give the cards the design system’s hover, selected and focus states. From 0ffebd679607cb9dfea8026bf6ee55669f1b1ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Tue, 3 Nov 2026 15:23:01 +0000 Subject: [PATCH 4/9] export only the CardTabs parts drops the unused prop types and the gap custom property --- .../packages/ui/src/card-tabs/card-tabs.module.scss | 4 ++-- .../premium-analytics/packages/ui/src/card-tabs/index.ts | 6 ------ .../packages/ui/src/card-tabs/stories/card-tabs.stories.tsx | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss index 996b53dcd363..e0915fbf4372 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.module.scss @@ -1,6 +1,6 @@ /* A card's narrowest inline size before the row wraps. No WPDS dimension * token reaches this far; a consumer tunes it through - * `--jpa-card-tabs-min-inline-size`, as it tunes the gap and the padding. */ + * `--jpa-card-tabs-min-inline-size`, as it tunes the padding. */ $card-tabs-min-inline-size: 10rem; /* As many cards to a row as fit at their minimum size, every row sharing the @@ -9,7 +9,7 @@ $card-tabs-min-inline-size: 10rem; .list { display: grid; grid-template-columns: repeat(var(--jpa-card-tabs-columns, auto-fit), minmax(min(100%, var(--jpa-card-tabs-min-inline-size, #{$card-tabs-min-inline-size})), 1fr)); - gap: var(--jpa-card-tabs-gap, var(--wpds-dimension-gap-sm)); + gap: var(--wpds-dimension-gap-sm); min-inline-size: 0; } diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts b/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts index 1af90660d965..22e394c6ddae 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts @@ -1,7 +1 @@ export { List, Panel, Root, Tab } from './card-tabs'; -export type { - CardTabsListProps, - CardTabsPanelProps, - CardTabsRootProps, - CardTabsTabProps, -} from './types'; diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx index 7f57ca2663b6..aceeac9b5d2e 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx @@ -5,7 +5,7 @@ import { useState } from 'react'; /** * Internal dependencies */ -import * as CardTabs from '../card-tabs'; +import { CardTabs } from '../index'; import type { Meta, StoryObj } from '@storybook/react'; import type { ComponentProps } from 'react'; @@ -100,7 +100,7 @@ const meta = { docs: { description: { component: - 'The `Tabs` of `@wordpress/ui` with each tab drawn as a card: Base UI tabs underneath, the selected card marked by its fill rather than an indicator, and the design system’s interactive tokens for every state. The row wraps on its own once the cards would fall under their minimum width; the gap, padding and that width are tuned through the `--jpa-card-tabs-*` custom properties.', + 'The `Tabs` of `@wordpress/ui` with each tab drawn as a card: Base UI tabs underneath, the selected card marked by its fill rather than an indicator, and the design system’s interactive tokens for every state. The row wraps on its own once the cards would fall under their minimum width; the padding, that width and the column count are set through `--jpa-card-tabs-padding`, `--jpa-card-tabs-min-inline-size` and `--jpa-card-tabs-columns`.', }, }, }, From 90793c865025e8a96eb7687eae82390fbdcab87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Tue, 3 Nov 2026 15:26:14 +0000 Subject: [PATCH 5/9] name CardTabs in its folder barrel the ui barrel re-exports it by name, as the other folders --- .../packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx | 2 +- .../premium-analytics/packages/ui/src/card-tabs/index.ts | 2 +- projects/packages/premium-analytics/packages/ui/src/index.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx index 4a2f84a9bb58..3cb7626f7e64 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/__tests__/card-tabs.test.tsx @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { isRTL } from '@wordpress/i18n'; import { act } from 'react'; -import * as CardTabs from '../card-tabs'; +import { CardTabs } from '../index'; jest.mock( '@wordpress/i18n', () => ( { ...jest.requireActual( '@wordpress/i18n' ), diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts b/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts index 22e394c6ddae..ad45b48979a8 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/index.ts @@ -1 +1 @@ -export { List, Panel, Root, Tab } from './card-tabs'; +export * as CardTabs from './card-tabs'; diff --git a/projects/packages/premium-analytics/packages/ui/src/index.ts b/projects/packages/premium-analytics/packages/ui/src/index.ts index dc44800f7ac9..efdb979128d6 100644 --- a/projects/packages/premium-analytics/packages/ui/src/index.ts +++ b/projects/packages/premium-analytics/packages/ui/src/index.ts @@ -1,4 +1,4 @@ -export * as CardTabs from './card-tabs'; +export { CardTabs } from './card-tabs'; export { DataViewsDrilldownNative, type DataViewsDrilldownNativeProps, From 3fa06289215b91ccd2f1ecf95d84f0b8a5629996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 5 Nov 2026 12:39:31 +0000 Subject: [PATCH 6/9] take CardTabs Base UI parts from externals reuses the copy @wordpress/ui compiles in, instead of a second one in ui --- .../premium-analytics/eslint.config.mjs | 10 ++++----- .../packages/externals/src/index.ts | 9 ++++++++ .../packages/ui/src/card-tabs/card-tabs.tsx | 21 ++++++++++--------- .../packages/ui/src/card-tabs/types.ts | 11 +++++----- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/projects/packages/premium-analytics/eslint.config.mjs b/projects/packages/premium-analytics/eslint.config.mjs index fdf45f96cc2f..e1a9bd9bb634 100644 --- a/projects/packages/premium-analytics/eslint.config.mjs +++ b/projects/packages/premium-analytics/eslint.config.mjs @@ -170,12 +170,12 @@ export default defineConfig( 'Import these from @jetpack-premium-analytics/externals instead: it compiles them once into a shared script module rather than into every module that imports them. Missing an export? Add it to packages/externals/src/index.ts.', }, { - // Base UI is what `@wordpress/ui` builds on. It is - // compiled into `packages/ui` for `CardTabs` and nowhere - // else, so a second copy is never bundled by accident. + // Base UI is what `@wordpress/ui` builds on, so `externals` + // already compiles it in: importing it anywhere else + // compiles a second copy. regex: '^@base-ui/react(/.*)?$', message: - 'Build on @wordpress/ui from @jetpack-premium-analytics/externals, or on CardTabs from @jetpack-premium-analytics/ui. Base UI itself is compiled into packages/ui only.', + 'Build on @wordpress/ui from @jetpack-premium-analytics/externals, or on CardTabs from @jetpack-premium-analytics/ui. A primitive that needs Base UI itself takes it from externals, which already compiles it in behind @wordpress/ui.', }, ], }, @@ -221,7 +221,7 @@ export default defineConfig( // Same as the packages rule above. regex: '^@base-ui/react(/.*)?$', message: - 'Build on @wordpress/ui from @jetpack-premium-analytics/externals, or on CardTabs from @jetpack-premium-analytics/ui. Base UI itself is compiled into packages/ui only.', + 'Build on @wordpress/ui from @jetpack-premium-analytics/externals, or on CardTabs from @jetpack-premium-analytics/ui. A primitive that needs Base UI itself takes it from externals, which already compiles it in behind @wordpress/ui.', }, ], }, diff --git a/projects/packages/premium-analytics/packages/externals/src/index.ts b/projects/packages/premium-analytics/packages/externals/src/index.ts index a1b0abd7e83a..08715fd6f56e 100644 --- a/projects/packages/premium-analytics/packages/externals/src/index.ts +++ b/projects/packages/premium-analytics/packages/externals/src/index.ts @@ -103,6 +103,15 @@ export { VisuallyHidden, } from '@wordpress/ui'; +/** + * Base UI + * + * The unstyled parts `@wordpress/ui` is built on, so they are already compiled + * in here. Prefixed because `Tabs` above is the design system's styled one. + */ +export { DirectionProvider as BaseDirectionProvider } from '@base-ui/react/direction-provider'; +export { Tabs as BaseTabs } from '@base-ui/react/tabs'; + /** * DataViews */ diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx index 45c1c101f0bb..9c830ca3de62 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx @@ -1,10 +1,7 @@ /** * External dependencies */ -// eslint-disable-next-line no-restricted-imports -- The one module that compiles Base UI in; see the ESLint rule. -import { DirectionProvider } from '@base-ui/react/direction-provider'; -// eslint-disable-next-line no-restricted-imports -- The one module that compiles Base UI in; see the ESLint rule. -import { Tabs } from '@base-ui/react/tabs'; +import { BaseDirectionProvider, BaseTabs } from '@jetpack-premium-analytics/externals'; import { isRTL } from '@wordpress/i18n'; import clsx from 'clsx'; import { forwardRef } from 'react'; @@ -26,9 +23,9 @@ import type { export const Root = forwardRef< HTMLDivElement, CardTabsRootProps >( function CardTabsRoot( props, forwardedRef ) { return ( - - - + + + ); } ); @@ -39,7 +36,7 @@ export const List = forwardRef< HTMLDivElement, CardTabsListProps >( function Ca forwardedRef ) { return ( - ( function C forwardedRef ) { return ( - + ); } ); @@ -63,7 +64,7 @@ export const Panel = forwardRef< HTMLDivElement, CardTabsPanelProps >( function forwardedRef ) { return ( - = Omit< children?: ReactNode; }; -export type CardTabsRootProps = PartProps< typeof Tabs.Root >; -export type CardTabsListProps = PartProps< typeof Tabs.List >; -export type CardTabsTabProps = PartProps< typeof Tabs.Tab >; -export type CardTabsPanelProps = PartProps< typeof Tabs.Panel >; +export type CardTabsRootProps = PartProps< typeof BaseTabs.Root >; +export type CardTabsListProps = PartProps< typeof BaseTabs.List >; +export type CardTabsTabProps = PartProps< typeof BaseTabs.Tab >; +export type CardTabsPanelProps = PartProps< typeof BaseTabs.Panel >; From 726f8266e32a4509521c71cae68f59213e6ff73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 5 Nov 2026 12:39:35 +0000 Subject: [PATCH 7/9] add a single-copy guard for Base UI fails when its version drifts from the one @wordpress/ui resolves --- .../tests/js/base-ui-single-copy.test.ts | 30 +++++++++++++++++++ .../tests/single-copy-modules.cjs | 4 +-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 projects/packages/premium-analytics/tests/js/base-ui-single-copy.test.ts diff --git a/projects/packages/premium-analytics/tests/js/base-ui-single-copy.test.ts b/projects/packages/premium-analytics/tests/js/base-ui-single-copy.test.ts new file mode 100644 index 000000000000..25112f024765 --- /dev/null +++ b/projects/packages/premium-analytics/tests/js/base-ui-single-copy.test.ts @@ -0,0 +1,30 @@ +/** + * External dependencies + */ +import fs from 'fs'; +import path from 'path'; + +const PACKAGE_ROOT = path.join( __dirname, '..', '..' ); + +/** + * Gets the directory a package is installed in, as resolved from another directory. + * + * @param {string} name - Package name. + * @param {string} from - Directory the resolution starts from. + * @return {string} The package's real directory. + */ +function installedDir( name: string, from: string ): string { + return fs.realpathSync( + path.dirname( require.resolve( `${ name }/package.json`, { paths: [ from ] } ) ) + ); +} + +// `externals` re-exports Base UI parts beside `@wordpress/ui`, which is built on Base UI. Bumping +// one without the other installs two copies, and the module compiles both in. +it( 'resolves the Base UI copy @wordpress/ui is built on', () => { + const designSystemDir = installedDir( '@wordpress/ui', PACKAGE_ROOT ); + + expect( installedDir( '@base-ui/react', PACKAGE_ROOT ) ).toBe( + installedDir( '@base-ui/react', designSystemDir ) + ); +} ); diff --git a/projects/packages/premium-analytics/tests/single-copy-modules.cjs b/projects/packages/premium-analytics/tests/single-copy-modules.cjs index 575d519bb9ba..a14785290272 100644 --- a/projects/packages/premium-analytics/tests/single-copy-modules.cjs +++ b/projects/packages/premium-analytics/tests/single-copy-modules.cjs @@ -37,8 +37,8 @@ const escapeRegExp = value => value.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ); * @return {Object} Mapper entries, keyed by an anchored pattern for the bare import. */ function singleCopyModuleMapper( rootDir ) { - // Anything the package does not depend on directly, such as `@base-ui/react`, is reached through - // the library that does. + // Anything the package does not depend on directly, such as `@wordpress/rich-text`, is reached + // through the library that does. const searchDirs = [ rootDir ]; for ( const name of [ '@wordpress/ui', '@wordpress/dataviews', '@wordpress/components' ] ) { try { From a7b4a75b3f2912a50ab54d77025d1d94f9a71035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 5 Nov 2026 13:22:47 +0000 Subject: [PATCH 8/9] test that metric cards hold no block elements catches a card face part falling back to a div inside the tab button --- .../__tests__/metric-tabs-chart.test.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx index 010754e75efb..137b4bec1f9c 100644 --- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx +++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/__tests__/metric-tabs-chart.test.tsx @@ -515,6 +515,24 @@ describe( 'MetricTabsChart', () => { } } ); + it( 'draws each card without block elements, which a button cannot hold', () => { + const unavailable = { + ...METRIC, + key: 'likes', + label: 'Likes', + unavailable: "Hourly data isn't available for this metric.", + }; + + render( ); + + const tabs = screen.getAllByRole( 'tab' ); + expect( tabs ).toHaveLength( 2 ); + for ( const tab of tabs ) { + // eslint-disable-next-line testing-library/no-node-access -- A block element has no role to query by. + expect( tab.querySelector( 'div' ) ).toBeNull(); + } + } ); + it( 'emits a single series when the metric has no previous period', () => { const withoutPrevious = { ...METRIC, previous: undefined }; From 35cb6900bb3760cd2d5622a17a3a4698beed7f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 5 Nov 2026 13:22:51 +0000 Subject: [PATCH 9/9] say CardTabs mirrors the ui Tabs API it builds on Base UI; it does not wrap the Tabs of @wordpress/ui --- .../premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx | 4 ++-- .../packages/ui/src/card-tabs/stories/card-tabs.stories.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx index 9c830ca3de62..cb52636f251c 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/card-tabs.tsx @@ -17,8 +17,8 @@ import type { } from './types'; /** - * Groups the cards and their panels: the `Tabs` of `@wordpress/ui` with each - * tab drawn as a card, whose fill marks the selection. + * Groups the cards and their panels. Mirrors the `Tabs` API of `@wordpress/ui`, + * with each tab drawn as a card whose fill marks the selection. */ export const Root = forwardRef< HTMLDivElement, CardTabsRootProps >( function CardTabsRoot( props, forwardedRef ) { diff --git a/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx b/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx index aceeac9b5d2e..3e4282a5f106 100644 --- a/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx +++ b/projects/packages/premium-analytics/packages/ui/src/card-tabs/stories/card-tabs.stories.tsx @@ -100,7 +100,7 @@ const meta = { docs: { description: { component: - 'The `Tabs` of `@wordpress/ui` with each tab drawn as a card: Base UI tabs underneath, the selected card marked by its fill rather than an indicator, and the design system’s interactive tokens for every state. The row wraps on its own once the cards would fall under their minimum width; the padding, that width and the column count are set through `--jpa-card-tabs-padding`, `--jpa-card-tabs-min-inline-size` and `--jpa-card-tabs-columns`.', + 'Mirrors the `Tabs` API of `@wordpress/ui`, with each tab drawn as a card: Base UI tabs underneath, the selected card marked by its fill rather than an indicator, and the design system’s interactive tokens for every state. The row wraps on its own once the cards would fall under their minimum width; the padding, that width and the column count are set through `--jpa-card-tabs-padding`, `--jpa-card-tabs-min-inline-size` and `--jpa-card-tabs-columns`.', }, }, },