From d577b9de6c7bca13745403427af6c99aec575ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 11:23:00 +0900 Subject: [PATCH 01/17] add widget footer for high-relevance actions footer strip under the body; the More menu keeps low-relevance ones --- packages/widget-dashboard/CHANGELOG.md | 8 ++ .../widget-actions/widget-actions.tsx | 19 ++-- .../src/components/widget-footer/index.ts | 1 + .../widget-footer/widget-footer.module.css | 31 ++++++ .../widget-footer/widget-footer.tsx | 105 ++++++++++++++++++ .../components/widget-frame/widget-frame.tsx | 19 +++- .../src/components/widgets/widgets.tsx | 14 ++- .../src/stories/index.story.tsx | 19 +++- widgets/events/render.tsx | 24 +--- widgets/events/style.module.css | 6 - widgets/events/widget.json | 16 +++ widgets/quick-draft/widget.json | 8 ++ 12 files changed, 224 insertions(+), 46 deletions(-) create mode 100644 packages/widget-dashboard/src/components/widget-footer/index.ts create mode 100644 packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css create mode 100644 packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx diff --git a/packages/widget-dashboard/CHANGELOG.md b/packages/widget-dashboard/CHANGELOG.md index ab01a629961270..0729f7e74be724 100644 --- a/packages/widget-dashboard/CHANGELOG.md +++ b/packages/widget-dashboard/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +### New Features + +- Widget chrome footer: `relevance: 'high'` actions materialize as a + persistent strip under the widget body. Actions without an icon mount as + leading text links, actions with one as trailing icon-only links; the + "More" menu keeps the remaining actions, and full-bleed widgets keep every + action in the menu ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). + ## 0.5.0 (2026-08-12) ### New Features diff --git a/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx b/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx index c240daf159e897..ee844f337d4eeb 100644 --- a/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx +++ b/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx @@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n'; import { moreVertical } from '@wordpress/icons'; // eslint-disable-next-line @wordpress/use-recommended-components import { Icon, IconButton, Link } from '@wordpress/ui'; -import type { WidgetType } from '@wordpress/widget-primitives'; +import type { WidgetAction } from '@wordpress/widget-primitives'; import { useReserveHeaderSpace } from '../widget-header/widget-header-fit'; import styles from './widget-actions.module.css'; import { unlock } from '../../lock-unlock'; @@ -12,16 +12,18 @@ const { Menu } = unlock( componentsPrivateApis ); type WidgetActionsProps = { /** - * The widget type whose declared actions render here. + * The actions this menu materializes. The host routes them by relevance: + * the footer takes `'high'`, this menu the rest, and every action for + * full-bleed widgets, which have no footer. */ - widgetType: WidgetType; + actions: WidgetAction[]; }; /** - * Materializes a widget type's declared `actions` as a "more" menu in the - * chrome: a three-dots trigger surfacing each action. This host mounts a real - * anchor for the link fulfillment, so middle-click and copy address survive; - * the menu exposes it as a menu item rather than as a link. + * Materializes widget actions as a "more" menu in the chrome: a three-dots + * trigger surfacing each given action. This host mounts a real anchor for the + * link fulfillment, so middle-click and copy address survive; the menu exposes + * it as a menu item rather than as a link. * * As a trailing header section it reserves its own footprint, so the * collapsible controls beside it never plan for space it occupies. @@ -29,9 +31,8 @@ type WidgetActionsProps = { * @param {WidgetActionsProps} props Component props. */ export function WidgetActions( { - widgetType, + actions, }: WidgetActionsProps ): React.ReactNode { - const actions = widgetType.actions ?? []; const reserveRef = useReserveHeaderSpace< HTMLSpanElement >( 'actions' ); if ( actions.length === 0 ) { diff --git a/packages/widget-dashboard/src/components/widget-footer/index.ts b/packages/widget-dashboard/src/components/widget-footer/index.ts new file mode 100644 index 00000000000000..ea6bd3cfef8ab7 --- /dev/null +++ b/packages/widget-dashboard/src/components/widget-footer/index.ts @@ -0,0 +1 @@ +export { WidgetFooter } from './widget-footer'; diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css new file mode 100644 index 00000000000000..1c00bfe465a255 --- /dev/null +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css @@ -0,0 +1,31 @@ +/* + * The divider spans the full card width in every presentation; the content + * aligns to the card padding via `--wp-ui-card-padding`, which already + * resolves the host-tunable tile padding. The body above is a middle card + * section with no bottom padding, so scrolled content runs flush to the + * divider. + */ +.widget-footer { + padding-block: var(--wpds-dimension-padding-md); + padding-inline: var(--wp-ui-card-padding); + border-block-start-style: solid; + border-block-start-width: var(--wpds-border-width-xs); + border-block-start-color: var(--wpds-color-stroke-surface-neutral-weak); +} + +.icon-actions { + margin-inline-start: auto; +} + +/* + * Square the icon-only link to the icon-button geometry, via the override + * hooks the Button styles declare for icon buttons. Breathing room around + * the glyph comes from the size scale (compact height around the 24px + * icon), not from padding: inline padding past ~3px widens the box out of + * square, and below that it does not move anything. + */ +.icon-action { + --wp-ui-button-aspect-ratio: 1; + --wp-ui-button-padding-inline: 0px; + --wp-ui-button-min-width: unset; +} diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx new file mode 100644 index 00000000000000..51ca0ac5997b5a --- /dev/null +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx @@ -0,0 +1,105 @@ +// eslint-disable-next-line @wordpress/use-recommended-components +import { Link, LinkButton, Stack, Tooltip } from '@wordpress/ui'; +import type { WidgetAction, WidgetIcon } from '@wordpress/widget-primitives'; +import styles from './widget-footer.module.css'; + +type WidgetFooterProps = { + /** + * The actions this footer materializes; the host routes the + * `relevance: 'high'` ones here. + */ + actions: WidgetAction[]; + + /** + * Inert the footer while customizing, so it does not capture interaction. + */ + editMode?: boolean; +}; + +/** + * Persistent strip of chrome under the widget body, the prominent surface for + * the widget's `relevance: 'high'` actions: always visible, unlike the More + * menu the remaining actions collapse into. + * + * Materialization is by declared shape: an action without an icon mounts as a + * text link on the leading edge; an action with one mounts as an icon-only + * link on the trailing edge, its label serving as accessible name and tooltip. + * Both mount real anchors, so middle-click, copy address, and download + * semantics survive. + * + * @param {WidgetFooterProps} props Component props. + */ +export function WidgetFooter( { + actions, + editMode = false, +}: WidgetFooterProps ): React.ReactNode { + if ( actions.length === 0 ) { + return null; + } + + const linkActions = actions.filter( ( action ) => ! action.icon ); + const iconActions = actions.filter( + ( action ): action is WidgetAction & { icon: WidgetIcon } => + !! action.icon + ); + + return ( + + { linkActions.length > 0 && ( + + { linkActions.map( ( action ) => ( + + { action.label } + + ) ) } + + ) } + + { iconActions.length > 0 && ( + + + { iconActions.map( ( action ) => ( + + + } + > + + + { action.label } + + ) ) } + + + ) } + + ); +} diff --git a/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx b/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx index 34b6e69849ed53..fa7f4e3af96e39 100644 --- a/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx +++ b/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx @@ -6,6 +6,7 @@ import { __ } from '@wordpress/i18n'; // eslint-disable-next-line @wordpress/use-recommended-components import { Card, Notice, Stack, VisuallyHidden } from '@wordpress/ui'; import type { WidgetType } from '@wordpress/widget-primitives'; +import { WidgetFooter } from '../widget-footer'; import { WidgetHeader } from '../widget-header'; import { WidgetRender } from '../widget-render'; import styles from './widget-frame.module.css'; @@ -69,8 +70,9 @@ export interface WidgetFrameProps { } /** - * Shared framing: `presentation` into header + content, with the error/loading - * boundaries. Hosts supply the `Card.Root` and their own concerns. + * Shared framing: `presentation` into header, content, and the actions footer, + * with the error/loading boundaries. Hosts supply the `Card.Root` and their + * own concerns. * * @param {WidgetFrameProps} props Component props. */ @@ -87,6 +89,15 @@ export function WidgetFrame( { const isBodyBleeding = presentation === 'full-bleed' || presentation === 'content-bleed'; + // The footer is the prominent surface for high-relevance actions. + // full-bleed leaves no chrome to host one, so its actions all stay in + // the More menu. + const footerActions = isHeaderHidden + ? [] + : ( widgetType.actions ?? [] ).filter( + ( action ) => action.relevance === 'high' + ); + const body = ( }> @@ -122,6 +133,10 @@ export function WidgetFrame( { ) } { body } + + { footerActions.length > 0 && ( + + ) } ); } diff --git a/packages/widget-dashboard/src/components/widgets/widgets.tsx b/packages/widget-dashboard/src/components/widgets/widgets.tsx index 5e65684a006479..1a0b3364718917 100644 --- a/packages/widget-dashboard/src/components/widgets/widgets.tsx +++ b/packages/widget-dashboard/src/components/widgets/widgets.tsx @@ -124,14 +124,22 @@ export const Widgets = forwardRef< HTMLDivElement, WidgetsProps >( ( type ) => type.name === widget.type ); const hasSettings = !! widgetType?.attributes?.length; - const hasActions = !! widgetType?.actions?.length; const isFullBleed = widgetType?.presentation === 'full-bleed'; + // The chrome footer is the prominent surface for high-relevance + // actions, so the menu takes the rest. full-bleed widgets have no + // footer and keep every action in the menu. + const actions = widgetType?.actions ?? []; + const menuActions = isFullBleed + ? actions + : actions.filter( ( action ) => action.relevance !== 'high' ); + const hasActions = menuActions.length > 0; + // The active mode's controls: layout while customizing, the // attribute controls (high-relevance fields on the prominent // surface, plus a settings entry point when needed) and the - // declared actions otherwise. + // menu actions otherwise. let controls: React.ReactNode; if ( editMode ) { controls = ; @@ -146,7 +154,7 @@ export const Widgets = forwardRef< HTMLDivElement, WidgetsProps >( ) } { hasActions && ( - + ) } ); diff --git a/packages/widget-dashboard/src/stories/index.story.tsx b/packages/widget-dashboard/src/stories/index.story.tsx index 0522b3082e4011..7967fa915fd691 100644 --- a/packages/widget-dashboard/src/stories/index.story.tsx +++ b/packages/widget-dashboard/src/stories/index.story.tsx @@ -6,7 +6,7 @@ import '@wordpress/components/build-style/style.css'; // eslint-disable-next-line @wordpress/no-non-module-stylesheet-imports import '@wordpress/dataviews/build-style/style.css'; import { useState } from '@wordpress/element'; -import { chartBar, trendingUp } from '@wordpress/icons'; +import { chartBar, download, trendingUp } from '@wordpress/icons'; import type { ResolveWidgetModule, WidgetAction, @@ -243,20 +243,31 @@ const GOAL_FIELDS: WidgetAttributeField< GoalAttributes >[] = [ }, ]; -// Two declarative actions: an external link and a client-side download. +// Three declarative actions: two at high relevance for the chrome footer (a +// text link and an icon-carrying download), one at the default relevance for +// the More menu. const GOAL_ACTIONS: WidgetAction[] = [ { id: 'view-goal', label: 'View goal details', + relevance: 'high', href: 'https://wordpress.org/', openInNewTab: true, }, { id: 'export-progress', label: 'Export progress', + relevance: 'high', + icon: download, href: new URL( './goal-progress.csv', import.meta.url ).href, download: 'goal-progress.csv', }, + { + id: 'about-goals', + label: 'About goals', + href: 'https://wordpress.org/documentation/', + openInNewTab: true, + }, ]; const goalProgressWidgetType: WidgetType = { @@ -266,7 +277,7 @@ const goalProgressWidgetType: WidgetType = { description: 'Sample goal widget whose attributes are all promoted.', help: { content: - 'One attribute, Goal metric, at high relevance: a single field in the header and no settings button. Two actions in the More menu: a link and a download.', + 'One attribute, Goal metric, at high relevance: a single field in the header and no settings button. Two promoted actions in the footer (a link and a download), plus one in the More menu.', }, icon: trendingUp, renderModule: 'demo/widgets/goal-progress/render', @@ -428,7 +439,7 @@ Their tiles compare the header presentations: The widget only declares relevance; the fit is measured by the chrome, so the same declaration adapts to any tile width. Resize the canvas to watch the headers switch presentations. -Beyond attributes, \`demo/goal-progress\` declares two \`actions\`: a "View goal details" link and an "Export progress" download. The host surfaces them in a "More" menu in the toolbar, so the widget declares each action as data and the host owns where it appears. +Beyond attributes, \`demo/goal-progress\` declares three \`actions\`, and the same relevance policy routes them: the two at \`relevance: 'high'\` materialize in a persistent chrome footer (the "View goal details" text link on the leading edge; the icon-carrying "Export progress" download as an icon-only link on the trailing edge), while "About goals" stays at the default relevance and lands in the "More" menu. The widget declares each action as data plus its importance; the host owns the surfaces. Each type also carries a \`help\` note, opened from the info icon in the header, that describes its attributes and what they do. `, diff --git a/widgets/events/render.tsx b/widgets/events/render.tsx index 5a8b603ee62702..b1ce49d9991058 100644 --- a/widgets/events/render.tsx +++ b/widgets/events/render.tsx @@ -4,7 +4,7 @@ import { store as coreStore } from '@wordpress/core-data'; import { Spinner } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { mapMarker } from '@wordpress/icons'; -import { Icon, Link, Stack, EmptyState } from '@wordpress/ui'; +import { Icon, Stack, EmptyState } from '@wordpress/ui'; import { EventsList, type WPEvent } from './components'; import type { EventsWidgetAttributes } from './types'; import styles from './style.module.css'; @@ -117,11 +117,7 @@ export default function WordPressEvents( { }, [ activeLocation, hasSelectedLocation, userLocale ] ); return ( - + { ! hasSelectedLocation && ( ) } -
- - - { __( 'Meetups' ) } - - - { __( 'WordCamps' ) } - - -
); } diff --git a/widgets/events/style.module.css b/widgets/events/style.module.css index c82736ee23df1d..42a0879bb5a122 100644 --- a/widgets/events/style.module.css +++ b/widgets/events/style.module.css @@ -8,12 +8,6 @@ padding: var(--wpds-dimension-padding-2xl); } -.footer { - border-block-start: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak); - padding-block: var(--wpds-dimension-padding-lg); - padding-inline: var(--wpds-dimension-padding-2xl); -} - .statusText { padding-inline: var(--wpds-dimension-padding-2xl); color: var(--wpds-color-foreground-content-neutral-weak); diff --git a/widgets/events/widget.json b/widgets/events/widget.json index c7fbd176484850..2a1a850460669d 100644 --- a/widgets/events/widget.json +++ b/widgets/events/widget.json @@ -5,5 +5,21 @@ "icon": "core/calendar", "category": "dashboard", "presentation": "content-bleed", + "actions": [ + { + "id": "meetups", + "label": "Meetups", + "relevance": "high", + "href": "https://make.wordpress.org/community/meetups-landing-page", + "openInNewTab": true + }, + { + "id": "wordcamps", + "label": "WordCamps", + "relevance": "high", + "href": "https://central.wordcamp.org/schedule/", + "openInNewTab": true + } + ], "textdomain": "default" } diff --git a/widgets/quick-draft/widget.json b/widgets/quick-draft/widget.json index 4b112453f9a753..eec88af4b719d8 100644 --- a/widgets/quick-draft/widget.json +++ b/widgets/quick-draft/widget.json @@ -8,5 +8,13 @@ "icon": "dashboard-widgets/drafts", "category": "dashboard", "presentation": "content-bleed", + "actions": [ + { + "id": "view-drafts", + "label": "View all drafts", + "relevance": "high", + "href": "edit.php?post_status=draft" + } + ], "textdomain": "default" } From 3a9b7426ec822903c703352a8cf029fafe0db587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 15:34:51 +0900 Subject: [PATCH 02/17] hold action icon slot while references resolve actions keep their icon shape from first paint; unresolvable refs clear --- packages/widget-primitives/CHANGELOG.md | 7 ++ .../src/hooks/test/use-widget-types.test.tsx | 8 ++- .../src/hooks/use-widget-types.ts | 64 ++++++++++++++----- 3 files changed, 59 insertions(+), 20 deletions(-) diff --git a/packages/widget-primitives/CHANGELOG.md b/packages/widget-primitives/CHANGELOG.md index 6e773b13351484..8430ea99a8c74a 100644 --- a/packages/widget-primitives/CHANGELOG.md +++ b/packages/widget-primitives/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +### Enhancements + +- `useWidgetTypes` holds the icon slot with the transparent stand-in while + an action's icon reference resolves, so hosts routing actions by icon + keep a stable shape from first paint; an unresolvable reference clears + the stand-in ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). + ## 0.5.0 (2026-08-12) ### New Features diff --git a/packages/widget-primitives/src/hooks/test/use-widget-types.test.tsx b/packages/widget-primitives/src/hooks/test/use-widget-types.test.tsx index bf2170bb50701a..bb974484965897 100644 --- a/packages/widget-primitives/src/hooks/test/use-widget-types.test.tsx +++ b/packages/widget-primitives/src/hooks/test/use-widget-types.test.tsx @@ -228,7 +228,7 @@ describe( 'useWidgetTypes', () => { ); } ); - it( 'leaves an action without an icon when the reference does not resolve', async () => { + it( 'clears the action stand-in when the reference does not resolve', async () => { const { result } = renderHook( () => useWidgetTypes( actionIconRecords ) ); @@ -241,7 +241,7 @@ describe( 'useWidgetTypes', () => { ); } ); - it( 'emits record actions without their icon while the reference resolves', async () => { + it( 'holds the action icon slot with a stand-in while the reference resolves', async () => { registerIconResolver( () => new Promise< WidgetIcon | null >( () => {} ) ); @@ -256,7 +256,9 @@ describe( 'useWidgetTypes', () => { id: 'report', relevance: 'high', } ); - expect( result.current[ 0 ][ 0 ].actions?.[ 0 ].icon ).toBeUndefined(); + expect( + isValidElement( result.current[ 0 ][ 0 ].actions?.[ 0 ].icon ) + ).toBe( true ); } ); it( "keeps a module action's element icon", async () => { diff --git a/packages/widget-primitives/src/hooks/use-widget-types.ts b/packages/widget-primitives/src/hooks/use-widget-types.ts index 3c33d7a5284305..4b3ae6d8216b79 100644 --- a/packages/widget-primitives/src/hooks/use-widget-types.ts +++ b/packages/widget-primitives/src/hooks/use-widget-types.ts @@ -17,25 +17,38 @@ import type { /* * Transparent stand-in for an icon reference that has not resolved yet: - * it holds the icon slot so titles do not shift when the icon lands. + * it holds the icon slot so titles do not shift and actions keep their + * icon shape while the icon lands. */ const pendingIcon: WidgetIcon = createElement( 'svg', { viewBox: '0 0 24 24', } ); /** - * Emitted actions carry only renderable icons: a wire reference resolves - * after the gate and patches in; anything else non-renderable drops. + * Emitted actions carry only renderable icons. A record action's wire + * reference holds the slot with the stand-in until it resolves after the + * gate; module-declared actions have no resolution pass, so anything + * non-renderable drops. * - * @param actions Declared actions, from the record or the module. + * @param actions Declared actions, from the record or the module. + * @param holdPending Substitute the stand-in for wire references that + * resolve after the gate. */ function withRenderableIcons( - actions: ( WidgetAction | WidgetActionRecord )[] + actions: ( WidgetAction | WidgetActionRecord )[], + holdPending: boolean ): WidgetAction[] { - return actions.map( ( { icon, ...action } ) => ( { - ...action, - ...( isValidElement( icon ) ? { icon: icon as WidgetIcon } : {} ), - } ) ); + return actions.map( ( { icon, ...action } ) => { + if ( isValidElement( icon ) ) { + return { ...action, icon: icon as WidgetIcon }; + } + + if ( holdPending && typeof icon === 'string' ) { + return { ...action, icon: pendingIcon }; + } + + return action; + } ); } /* `true` while records or their metadata imports are still resolving; hosts @@ -141,7 +154,12 @@ export function useWidgetTypes( ? { keywords: record.keywords } : {} ), ...( actions - ? { actions: withRenderableIcons( actions ) } + ? { + actions: withRenderableIcons( + actions, + actions === record.actions + ), + } : {} ), } as WidgetType; } catch { @@ -194,7 +212,8 @@ export function useWidgetTypes( /* * Each record action's icon reference resolves off the gate * and patches into the emitted action; an unresolvable - * reference leaves the action without an icon. + * reference clears the stand-in, leaving the action without + * an icon. */ for ( const record of records ) { for ( const action of record.actions ?? [] ) { @@ -203,7 +222,7 @@ export function useWidgetTypes( } void resolveIcon( action.icon ).then( ( resolved ) => { - if ( cancelled || ! resolved ) { + if ( cancelled ) { return; } @@ -215,11 +234,22 @@ export function useWidgetTypes( return { ...type, - actions: type.actions?.map( ( entry ) => - entry.id === action.id - ? { ...entry, icon: resolved } - : entry - ), + actions: type.actions?.map( ( entry ) => { + if ( entry.id !== action.id ) { + return entry; + } + + if ( resolved ) { + return { + ...entry, + icon: resolved, + }; + } + + return entry.icon === pendingIcon + ? { ...entry, icon: undefined } + : entry; + } ), }; } ) ); From f35ec5c1a97bc36fc180c5fb9119540da09bff7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 15:35:03 +0900 Subject: [PATCH 03/17] fix new-tab hint on icon-only footer actions target on the anchor, hint in the accessible name; no second glyph --- .../widget-footer/widget-footer.tsx | 78 ++++++++++++++----- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx index 51ca0ac5997b5a..d47241f1b1eec2 100644 --- a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx @@ -1,8 +1,64 @@ +import { __, sprintf } from '@wordpress/i18n'; // eslint-disable-next-line @wordpress/use-recommended-components import { Link, LinkButton, Stack, Tooltip } from '@wordpress/ui'; import type { WidgetAction, WidgetIcon } from '@wordpress/widget-primitives'; import styles from './widget-footer.module.css'; +type IconActionProps = { + /** + * An icon-carrying action, materialized as an icon-only link. + */ + action: WidgetAction & { icon: WidgetIcon }; +}; + +/** + * Icon-only link for an icon-carrying action. `openInNewTab` mounts the + * target on the anchor directly instead of through `Link`, which would add + * its external glyph beside the action icon; the new-tab hint joins the + * accessible name instead, which the `aria-label` would otherwise mute. + * + * @param {IconActionProps} props Component props. + */ +function IconAction( { action }: IconActionProps ): React.ReactNode { + const label = action.openInNewTab + ? sprintf( + /* translators: %s: action label. */ + __( '%s (opens in a new tab)' ), + action.label + ) + : action.label; + + return ( + + + ) : undefined + } + /> + } + > + + + { action.label } + + ); +} + type WidgetFooterProps = { /** * The actions this footer materializes; the host routes the @@ -75,27 +131,7 @@ export function WidgetFooter( { > { iconActions.map( ( action ) => ( - - - } - > - - - { action.label } - + ) ) }
From aaa5af537aa9331f14f79e07e2cf390a527febfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 15:35:08 +0900 Subject: [PATCH 04/17] share the footer/menu action split in one helper --- .../components/widget-frame/widget-frame.tsx | 12 +++------ .../src/components/widgets/widgets.tsx | 11 +++----- .../src/utils/split-widget-actions.ts | 25 +++++++++++++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 packages/widget-dashboard/src/utils/split-widget-actions.ts diff --git a/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx b/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx index fa7f4e3af96e39..eedcf328148d5c 100644 --- a/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx +++ b/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx @@ -6,6 +6,7 @@ import { __ } from '@wordpress/i18n'; // eslint-disable-next-line @wordpress/use-recommended-components import { Card, Notice, Stack, VisuallyHidden } from '@wordpress/ui'; import type { WidgetType } from '@wordpress/widget-primitives'; +import { splitWidgetActions } from '../../utils/split-widget-actions'; import { WidgetFooter } from '../widget-footer'; import { WidgetHeader } from '../widget-header'; import { WidgetRender } from '../widget-render'; @@ -89,14 +90,9 @@ export function WidgetFrame( { const isBodyBleeding = presentation === 'full-bleed' || presentation === 'content-bleed'; - // The footer is the prominent surface for high-relevance actions. - // full-bleed leaves no chrome to host one, so its actions all stay in - // the More menu. - const footerActions = isHeaderHidden - ? [] - : ( widgetType.actions ?? [] ).filter( - ( action ) => action.relevance === 'high' - ); + // The footer is the prominent surface for high-relevance actions; + // `splitWidgetActions` owns the routing rule shared with the menu. + const { footer: footerActions } = splitWidgetActions( widgetType ); const body = ( diff --git a/packages/widget-dashboard/src/components/widgets/widgets.tsx b/packages/widget-dashboard/src/components/widgets/widgets.tsx index 1a0b3364718917..5576a843a980bf 100644 --- a/packages/widget-dashboard/src/components/widgets/widgets.tsx +++ b/packages/widget-dashboard/src/components/widgets/widgets.tsx @@ -10,6 +10,7 @@ import type { import type { WidgetName } from '@wordpress/widget-primitives'; import { useDashboardInternalContext } from '../../context/dashboard-context'; import { useDashboardContainerColumnCount } from '../../hooks/use-dashboard-container-column-count'; +import { splitWidgetActions } from '../../utils/split-widget-actions'; import { WidgetActions } from '../widget-actions'; import { WidgetAttributes } from '../widget-attributes'; import { WidgetChrome } from '../widget-chrome'; @@ -127,13 +128,9 @@ export const Widgets = forwardRef< HTMLDivElement, WidgetsProps >( const isFullBleed = widgetType?.presentation === 'full-bleed'; - // The chrome footer is the prominent surface for high-relevance - // actions, so the menu takes the rest. full-bleed widgets have no - // footer and keep every action in the menu. - const actions = widgetType?.actions ?? []; - const menuActions = isFullBleed - ? actions - : actions.filter( ( action ) => action.relevance !== 'high' ); + // `splitWidgetActions` owns the footer/menu routing rule; the + // frame reads the footer half of the same split. + const { menu: menuActions } = splitWidgetActions( widgetType ); const hasActions = menuActions.length > 0; // The active mode's controls: layout while customizing, the diff --git a/packages/widget-dashboard/src/utils/split-widget-actions.ts b/packages/widget-dashboard/src/utils/split-widget-actions.ts new file mode 100644 index 00000000000000..76c35d6623d2cc --- /dev/null +++ b/packages/widget-dashboard/src/utils/split-widget-actions.ts @@ -0,0 +1,25 @@ +import type { WidgetAction, WidgetType } from '@wordpress/widget-primitives'; + +/** + * Splits a widget type's declared actions across the chrome's two surfaces: + * the footer takes `relevance: 'high'`, the More menu takes the rest. + * Full-bleed widgets have no chrome to host a footer, so every action stays + * in the menu. Both surfaces read this one rule so they cannot drift. + * + * @param widgetType The widget type whose actions are routed. + */ +export function splitWidgetActions( widgetType?: WidgetType ): { + footer: WidgetAction[]; + menu: WidgetAction[]; +} { + const actions = widgetType?.actions ?? []; + + if ( widgetType?.presentation === 'full-bleed' ) { + return { footer: [], menu: actions }; + } + + return { + footer: actions.filter( ( action ) => action.relevance === 'high' ), + menu: actions.filter( ( action ) => action.relevance !== 'high' ), + }; +} From 4724e96d20e0900d42a8cdb1a25633a9a695342a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 15:35:12 +0900 Subject: [PATCH 05/17] document the footer surface mapping --- packages/widget-dashboard/README.md | 11 ++++++++++- packages/widget-primitives/src/stories/actions.md | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/widget-dashboard/README.md b/packages/widget-dashboard/README.md index 20f07f5a581a3f..01b46ac07a2ec8 100644 --- a/packages/widget-dashboard/README.md +++ b/packages/widget-dashboard/README.md @@ -205,7 +205,7 @@ The tile chrome is a `Card` at the Card's default density. Hosts can tighten or ```css :root { - --wp-widget-dashboard-tile-padding: var(--wpds-dimension-padding-lg); + --wp-widget-dashboard-tile-padding: var( --wpds-dimension-padding-lg ); } ``` @@ -232,6 +232,15 @@ The prominent surface holds only while it fits. The header measures the space it Edits on any surface stage through the engine's internal layer and reach `onLayoutChange` on commit. Prominent-surface and dropdown edits publish on a shared auto-save debounce; the settings surface publishes on Save. +### Actions + +Actions carry the same `relevance` vocabulary, mapped to two surfaces: + +- **Footer**: `relevance: 'high'` actions render in a persistent strip under the widget body. Actions without an icon mount as leading text links; actions with one mount as trailing icon-only links, the label serving as accessible name and tooltip. +- **More menu**: the remaining actions collapse into the three-dots menu in the tile header. + +Every affordance is a real anchor, so middle-click, copy address, and download semantics survive. Full-bleed widgets render no chrome to host a footer, so all of their actions stay in the menu. + ## Authoring widgets Widget render modules receive only what they need to render and edit: diff --git a/packages/widget-primitives/src/stories/actions.md b/packages/widget-primitives/src/stories/actions.md index 463da463e6b389..d2c49a34de1b04 100644 --- a/packages/widget-primitives/src/stories/actions.md +++ b/packages/widget-primitives/src/stories/actions.md @@ -61,3 +61,5 @@ Where no link primitive fits, as in a command palette, the host mounts what the The widget lists its actions; it never specifies where they go. The host maps them to its surfaces: a dashboard might gather them in a "More" menu, a footer, or a command palette. `relevance` carries the widget's side of that decision: `'high'` marks an action worth a prominent surface, `'low'` (the default) the rest. Attributes already use the same vocabulary: the widget declares intent, and the host owns the surface. + +The dashboard host maps the hint this way: high-relevance actions mount in a persistent footer under the widget body, and the rest collapse into the "More" menu. Full-bleed widgets render no chrome, so all of their actions stay in the menu. From 43c325aa3c22e4c872d35d33f65f63a748f3ea6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 16:12:33 +0900 Subject: [PATCH 06/17] add medium tier to widget relevance scale footer maps high to leading links, medium to trailing compact affordances; icon declarations no longer decide placement --- ...lass-wp-rest-widget-modules-controller.php | 2 +- .../dashboard-widgets/widget-types.php | 2 +- packages/widget-dashboard/CHANGELOG.md | 11 ++-- packages/widget-dashboard/README.md | 5 +- .../widget-footer/widget-footer.module.css | 2 +- .../widget-footer/widget-footer.tsx | 61 ++++++++++++------- .../src/stories/index.story.tsx | 8 +-- .../src/utils/split-widget-actions.ts | 14 +++-- packages/widget-primitives/CHANGELOG.md | 7 +++ .../widget-primitives/src/stories/actions.md | 4 +- packages/widget-primitives/src/types.ts | 15 ++--- ...wp-rest-widget-modules-controller-test.php | 2 +- phpunit/experimental/widget-types-test.php | 12 ++++ 13 files changed, 95 insertions(+), 50 deletions(-) diff --git a/lib/experimental/dashboard-widgets/class-wp-rest-widget-modules-controller.php b/lib/experimental/dashboard-widgets/class-wp-rest-widget-modules-controller.php index 41c727b6dd14a5..35609948151e8f 100644 --- a/lib/experimental/dashboard-widgets/class-wp-rest-widget-modules-controller.php +++ b/lib/experimental/dashboard-widgets/class-wp-rest-widget-modules-controller.php @@ -337,7 +337,7 @@ public function get_item_schema() { 'icon' => array( 'type' => 'string' ), 'relevance' => array( 'type' => 'string', - 'enum' => array( 'high', 'low' ), + 'enum' => array( 'high', 'medium', 'low' ), ), 'href' => array( 'type' => 'string' ), 'download' => array( 'type' => array( 'string', 'boolean' ) ), diff --git a/lib/experimental/dashboard-widgets/widget-types.php b/lib/experimental/dashboard-widgets/widget-types.php index 503f20cdd597e9..ee3a509570cd7c 100644 --- a/lib/experimental/dashboard-widgets/widget-types.php +++ b/lib/experimental/dashboard-widgets/widget-types.php @@ -242,7 +242,7 @@ function gutenberg_sanitize_widget_actions( $actions, $dir_name = '' ) { } } - if ( isset( $action['relevance'] ) && in_array( $action['relevance'], array( 'high', 'low' ), true ) ) { + if ( isset( $action['relevance'] ) && in_array( $action['relevance'], array( 'high', 'medium', 'low' ), true ) ) { $entry['relevance'] = $action['relevance']; } diff --git a/packages/widget-dashboard/CHANGELOG.md b/packages/widget-dashboard/CHANGELOG.md index 0729f7e74be724..e8b73499a5563e 100644 --- a/packages/widget-dashboard/CHANGELOG.md +++ b/packages/widget-dashboard/CHANGELOG.md @@ -4,11 +4,12 @@ ### New Features -- Widget chrome footer: `relevance: 'high'` actions materialize as a - persistent strip under the widget body. Actions without an icon mount as - leading text links, actions with one as trailing icon-only links; the - "More" menu keeps the remaining actions, and full-bleed widgets keep every - action in the menu ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). +- Widget chrome footer: promoted actions materialize as a persistent strip + under the widget body. `relevance: 'high'` actions mount as leading text + links, `'medium'` actions as trailing compact affordances (icon-only when + the action declares an icon); the "More" menu keeps the remaining actions, + and full-bleed widgets keep every action in the menu + ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). ## 0.5.0 (2026-08-12) diff --git a/packages/widget-dashboard/README.md b/packages/widget-dashboard/README.md index 01b46ac07a2ec8..113558f97ce07f 100644 --- a/packages/widget-dashboard/README.md +++ b/packages/widget-dashboard/README.md @@ -234,9 +234,10 @@ Edits on any surface stage through the engine's internal layer and reach `onLayo ### Actions -Actions carry the same `relevance` vocabulary, mapped to two surfaces: +Actions carry the same `relevance` scale, mapped to surfaces of decreasing prominence: -- **Footer**: `relevance: 'high'` actions render in a persistent strip under the widget body. Actions without an icon mount as leading text links; actions with one mount as trailing icon-only links, the label serving as accessible name and tooltip. +- **Footer, leading**: `relevance: 'high'` actions render as text links in a persistent strip under the widget body, labels always visible. +- **Footer, trailing**: `relevance: 'medium'` actions render beside them as compact affordances: an icon-only link when the action declares an icon (the label as accessible name and tooltip), a text link otherwise. - **More menu**: the remaining actions collapse into the three-dots menu in the tile header. Every affordance is a real anchor, so middle-click, copy address, and download semantics survive. Full-bleed widgets render no chrome to host a footer, so all of their actions stay in the menu. diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css index 1c00bfe465a255..731e40d17eaa7b 100644 --- a/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css @@ -13,7 +13,7 @@ border-block-start-color: var(--wpds-color-stroke-surface-neutral-weak); } -.icon-actions { +.compact-actions { margin-inline-start: auto; } diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx index d47241f1b1eec2..ebba6d88083a09 100644 --- a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx @@ -61,8 +61,8 @@ function IconAction( { action }: IconActionProps ): React.ReactNode { type WidgetFooterProps = { /** - * The actions this footer materializes; the host routes the - * `relevance: 'high'` ones here. + * The actions this footer materializes; the host routes the promoted + * tiers (`relevance: 'high'` and `'medium'`) here. */ actions: WidgetAction[]; @@ -73,15 +73,16 @@ type WidgetFooterProps = { }; /** - * Persistent strip of chrome under the widget body, the prominent surface for - * the widget's `relevance: 'high'` actions: always visible, unlike the More - * menu the remaining actions collapse into. + * Persistent strip of chrome under the widget body, the prominent surface + * for the widget's promoted actions: always visible, unlike the More menu + * the remaining actions collapse into. * - * Materialization is by declared shape: an action without an icon mounts as a - * text link on the leading edge; an action with one mounts as an icon-only - * link on the trailing edge, its label serving as accessible name and tooltip. - * Both mount real anchors, so middle-click, copy address, and download - * semantics survive. + * Materialization follows the relevance tier: `'high'` actions mount as + * text links on the leading edge, labels always visible; `'medium'` actions + * mount on the trailing edge as compact affordances, icon-only when the + * action declares an icon and text links otherwise. Every affordance is a + * real anchor, so middle-click, copy address, and download semantics + * survive. * * @param {WidgetFooterProps} props Component props. */ @@ -93,10 +94,11 @@ export function WidgetFooter( { return null; } - const linkActions = actions.filter( ( action ) => ! action.icon ); - const iconActions = actions.filter( - ( action ): action is WidgetAction & { icon: WidgetIcon } => - !! action.icon + const highActions = actions.filter( + ( action ) => action.relevance === 'high' + ); + const mediumActions = actions.filter( + ( action ) => action.relevance === 'medium' ); return ( @@ -107,9 +109,9 @@ export function WidgetFooter( { className={ styles[ 'widget-footer' ] } { ...( editMode ? { inert: 'true' } : {} ) } > - { linkActions.length > 0 && ( + { highActions.length > 0 && ( - { linkActions.map( ( action ) => ( + { highActions.map( ( action ) => ( ) } - { iconActions.length > 0 && ( + { mediumActions.length > 0 && ( - { iconActions.map( ( action ) => ( - - ) ) } + { mediumActions.map( ( action ) => + action.icon ? ( + + ) : ( + + { action.label } + + ) + ) } ) } diff --git a/packages/widget-dashboard/src/stories/index.story.tsx b/packages/widget-dashboard/src/stories/index.story.tsx index 7967fa915fd691..2b638d930a7085 100644 --- a/packages/widget-dashboard/src/stories/index.story.tsx +++ b/packages/widget-dashboard/src/stories/index.story.tsx @@ -243,8 +243,8 @@ const GOAL_FIELDS: WidgetAttributeField< GoalAttributes >[] = [ }, ]; -// Three declarative actions: two at high relevance for the chrome footer (a -// text link and an icon-carrying download), one at the default relevance for +// Three declarative actions spanning the relevance scale: a high link and a +// medium download for the chrome footer, one at the default relevance for // the More menu. const GOAL_ACTIONS: WidgetAction[] = [ { @@ -257,7 +257,7 @@ const GOAL_ACTIONS: WidgetAction[] = [ { id: 'export-progress', label: 'Export progress', - relevance: 'high', + relevance: 'medium', icon: download, href: new URL( './goal-progress.csv', import.meta.url ).href, download: 'goal-progress.csv', @@ -439,7 +439,7 @@ Their tiles compare the header presentations: The widget only declares relevance; the fit is measured by the chrome, so the same declaration adapts to any tile width. Resize the canvas to watch the headers switch presentations. -Beyond attributes, \`demo/goal-progress\` declares three \`actions\`, and the same relevance policy routes them: the two at \`relevance: 'high'\` materialize in a persistent chrome footer (the "View goal details" text link on the leading edge; the icon-carrying "Export progress" download as an icon-only link on the trailing edge), while "About goals" stays at the default relevance and lands in the "More" menu. The widget declares each action as data plus its importance; the host owns the surfaces. +Beyond attributes, \`demo/goal-progress\` declares three \`actions\` spanning the relevance scale, and that scale routes them: "View goal details" at \`'high'\` mounts as a leading text link in a persistent chrome footer, "Export progress" at \`'medium'\` beside it as a trailing icon-only link, and "About goals" at the default \`'low'\` lands in the "More" menu. The widget declares each action as data plus its importance; the host owns the surfaces. Each type also carries a \`help\` note, opened from the info icon in the header, that describes its attributes and what they do. `, diff --git a/packages/widget-dashboard/src/utils/split-widget-actions.ts b/packages/widget-dashboard/src/utils/split-widget-actions.ts index 76c35d6623d2cc..0f3ee93d1803b7 100644 --- a/packages/widget-dashboard/src/utils/split-widget-actions.ts +++ b/packages/widget-dashboard/src/utils/split-widget-actions.ts @@ -2,9 +2,10 @@ import type { WidgetAction, WidgetType } from '@wordpress/widget-primitives'; /** * Splits a widget type's declared actions across the chrome's two surfaces: - * the footer takes `relevance: 'high'`, the More menu takes the rest. - * Full-bleed widgets have no chrome to host a footer, so every action stays - * in the menu. Both surfaces read this one rule so they cannot drift. + * the footer takes the promoted tiers (`relevance: 'high'` and `'medium'`), + * the More menu takes the rest. Full-bleed widgets have no chrome to host a + * footer, so every action stays in the menu. Both surfaces read this one + * rule so they cannot drift. * * @param widgetType The widget type whose actions are routed. */ @@ -18,8 +19,11 @@ export function splitWidgetActions( widgetType?: WidgetType ): { return { footer: [], menu: actions }; } + const isPromoted = ( action: WidgetAction ) => + action.relevance === 'high' || action.relevance === 'medium'; + return { - footer: actions.filter( ( action ) => action.relevance === 'high' ), - menu: actions.filter( ( action ) => action.relevance !== 'high' ), + footer: actions.filter( isPromoted ), + menu: actions.filter( ( action ) => ! isPromoted( action ) ), }; } diff --git a/packages/widget-primitives/CHANGELOG.md b/packages/widget-primitives/CHANGELOG.md index 8430ea99a8c74a..5050e74e96db1b 100644 --- a/packages/widget-primitives/CHANGELOG.md +++ b/packages/widget-primitives/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +### New Features + +- `WidgetRelevance` gains a `'medium'` tier between `'high'` and `'low'`: + a declaration worth persistent but compact visibility. Hosts map the + scale to surfaces of decreasing prominence + ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). + ### Enhancements - `useWidgetTypes` holds the icon slot with the transparent stand-in while diff --git a/packages/widget-primitives/src/stories/actions.md b/packages/widget-primitives/src/stories/actions.md index d2c49a34de1b04..96acad8732d69c 100644 --- a/packages/widget-primitives/src/stories/actions.md +++ b/packages/widget-primitives/src/stories/actions.md @@ -60,6 +60,6 @@ Where no link primitive fits, as in a command palette, the host mounts what the The widget lists its actions; it never specifies where they go. The host maps them to its surfaces: a dashboard might gather them in a "More" menu, a footer, or a command palette. -`relevance` carries the widget's side of that decision: `'high'` marks an action worth a prominent surface, `'low'` (the default) the rest. Attributes already use the same vocabulary: the widget declares intent, and the host owns the surface. +`relevance` carries the widget's side of that decision as a decreasing scale: `'high'` marks an action worth the most prominent surface, `'medium'` one worth persistent but compact visibility, and `'low'` (the default) the rest. Attributes already use the same vocabulary: the widget declares intent, and the host owns the surface. -The dashboard host maps the hint this way: high-relevance actions mount in a persistent footer under the widget body, and the rest collapse into the "More" menu. Full-bleed widgets render no chrome, so all of their actions stay in the menu. +The dashboard host maps the scale this way: `'high'` actions mount as text links in a persistent footer under the widget body, `'medium'` actions beside them as compact icon affordances, and the rest collapse into the "More" menu. Full-bleed widgets render no chrome, so all of their actions stay in the menu. diff --git a/packages/widget-primitives/src/types.ts b/packages/widget-primitives/src/types.ts index 733042e9925dc1..91af12b2a13de3 100644 --- a/packages/widget-primitives/src/types.ts +++ b/packages/widget-primitives/src/types.ts @@ -62,11 +62,11 @@ export interface WidgetHelp { } /** - * How relevant a declaration is. Hosts may promote `'high'` to a prominent - * surface; `'low'` (the default) is not. The widget declares importance, - * not a surface. + * How relevant a declaration is, as a decreasing scale. The widget declares + * importance, not a surface; hosts map the tiers to surfaces of decreasing + * prominence. `'low'` is the default. */ -export type WidgetRelevance = 'high' | 'low'; +export type WidgetRelevance = 'high' | 'medium' | 'low'; /** * A user-triggerable verb a widget type declares. The declaration is @@ -99,9 +99,10 @@ export interface WidgetAction { icon?: WidgetIcon; /** - * How relevant the action is among the widget's actions. Hosts may - * surface `'high'` prominently; `'low'` (the default) belongs in a - * secondary surface such as a menu. + * How relevant the action is among the widget's actions. Hosts map the + * scale to surfaces of decreasing prominence: `'high'` deserves the + * most prominent one, `'medium'` a persistent but compact one, and + * `'low'` (the default) a collapsed surface such as a menu. */ relevance?: WidgetRelevance; diff --git a/phpunit/experimental/class-wp-rest-widget-modules-controller-test.php b/phpunit/experimental/class-wp-rest-widget-modules-controller-test.php index 26e9ff72c3bbb2..76ff35129a918d 100644 --- a/phpunit/experimental/class-wp-rest-widget-modules-controller-test.php +++ b/phpunit/experimental/class-wp-rest-widget-modules-controller-test.php @@ -243,7 +243,7 @@ public function test_schema_exposes_expected_properties() { $this->assertArrayHasKey( 'icon', $action_properties ); $this->assertArrayHasKey( 'relevance', $action_properties ); $this->assertSame( - array( 'high', 'low' ), + array( 'high', 'medium', 'low' ), $action_properties['relevance']['enum'] ); } diff --git a/phpunit/experimental/widget-types-test.php b/phpunit/experimental/widget-types-test.php index 1e6954f117a456..24e0b1c951416e 100644 --- a/phpunit/experimental/widget-types-test.php +++ b/phpunit/experimental/widget-types-test.php @@ -354,6 +354,12 @@ public function test_sanitize_widget_actions_envelope_extras() { 'icon' => 'core/chart-bar', 'relevance' => 'high', ), + array( + 'id' => 'export', + 'label' => 'Export', + 'href' => 'https://example.com/export', + 'relevance' => 'medium', + ), array( 'id' => 'about', 'label' => 'About', @@ -373,6 +379,12 @@ public function test_sanitize_widget_actions_envelope_extras() { 'icon' => 'core/chart-bar', 'relevance' => 'high', ), + array( + 'id' => 'export', + 'label' => 'Export', + 'href' => 'https://example.com/export', + 'relevance' => 'medium', + ), array( 'id' => 'about', 'label' => 'About', From bee0fda8ed40e0dd4e09e616005580e63359e445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 16:20:34 +0900 Subject: [PATCH 07/17] tighten comments and docs --- packages/widget-dashboard/CHANGELOG.md | 9 +++--- packages/widget-dashboard/README.md | 8 ++--- .../widget-footer/widget-footer.module.css | 14 +++------ .../widget-footer/widget-footer.tsx | 31 ++++++------------- .../components/widget-frame/widget-frame.tsx | 2 -- .../src/components/widgets/widgets.tsx | 2 -- .../src/utils/split-widget-actions.ts | 8 ++--- packages/widget-primitives/CHANGELOG.md | 12 +++---- .../src/hooks/use-widget-types.ts | 16 ++++------ .../widget-primitives/src/stories/actions.md | 4 +-- packages/widget-primitives/src/types.ts | 11 +++---- 11 files changed, 42 insertions(+), 75 deletions(-) diff --git a/packages/widget-dashboard/CHANGELOG.md b/packages/widget-dashboard/CHANGELOG.md index e8b73499a5563e..e207823f7413d5 100644 --- a/packages/widget-dashboard/CHANGELOG.md +++ b/packages/widget-dashboard/CHANGELOG.md @@ -4,11 +4,10 @@ ### New Features -- Widget chrome footer: promoted actions materialize as a persistent strip - under the widget body. `relevance: 'high'` actions mount as leading text - links, `'medium'` actions as trailing compact affordances (icon-only when - the action declares an icon); the "More" menu keeps the remaining actions, - and full-bleed widgets keep every action in the menu +- Widget chrome footer: `relevance: 'high'` actions mount as leading text + links in a persistent strip under the widget body, `'medium'` as trailing + compact affordances (icon-only with a declared icon); the "More" menu + keeps the rest, and full-bleed widgets keep every action in the menu ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). ## 0.5.0 (2026-08-12) diff --git a/packages/widget-dashboard/README.md b/packages/widget-dashboard/README.md index 113558f97ce07f..35881bff0785ef 100644 --- a/packages/widget-dashboard/README.md +++ b/packages/widget-dashboard/README.md @@ -236,11 +236,11 @@ Edits on any surface stage through the engine's internal layer and reach `onLayo Actions carry the same `relevance` scale, mapped to surfaces of decreasing prominence: -- **Footer, leading**: `relevance: 'high'` actions render as text links in a persistent strip under the widget body, labels always visible. -- **Footer, trailing**: `relevance: 'medium'` actions render beside them as compact affordances: an icon-only link when the action declares an icon (the label as accessible name and tooltip), a text link otherwise. -- **More menu**: the remaining actions collapse into the three-dots menu in the tile header. +- **Footer, leading**: `relevance: 'high'` actions render as text links in a persistent strip under the widget body. +- **Footer, trailing**: `relevance: 'medium'` actions render as compact affordances: icon-only links when the action declares an icon, text links otherwise. +- **More menu**: the rest collapse into the three-dots menu in the tile header. -Every affordance is a real anchor, so middle-click, copy address, and download semantics survive. Full-bleed widgets render no chrome to host a footer, so all of their actions stay in the menu. +Every affordance is a real anchor. Full-bleed widgets have no footer, so all of their actions stay in the menu. ## Authoring widgets diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css index 731e40d17eaa7b..6e134a1a6dca8e 100644 --- a/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css @@ -1,9 +1,6 @@ /* - * The divider spans the full card width in every presentation; the content - * aligns to the card padding via `--wp-ui-card-padding`, which already - * resolves the host-tunable tile padding. The body above is a middle card - * section with no bottom padding, so scrolled content runs flush to the - * divider. + * Full-width divider; content aligns to the card padding. The body above + * has no bottom padding, so scrolled content runs flush to the divider. */ .widget-footer { padding-block: var(--wpds-dimension-padding-md); @@ -18,11 +15,8 @@ } /* - * Square the icon-only link to the icon-button geometry, via the override - * hooks the Button styles declare for icon buttons. Breathing room around - * the glyph comes from the size scale (compact height around the 24px - * icon), not from padding: inline padding past ~3px widens the box out of - * square, and below that it does not move anything. + * Square the icon-only link via the Button override hooks for icon + * buttons; breathing room comes from the size, not from padding. */ .icon-action { --wp-ui-button-aspect-ratio: 1; diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx index ebba6d88083a09..cc5741382cae2d 100644 --- a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx @@ -6,16 +6,15 @@ import styles from './widget-footer.module.css'; type IconActionProps = { /** - * An icon-carrying action, materialized as an icon-only link. + * The action to materialize. */ action: WidgetAction & { icon: WidgetIcon }; }; /** - * Icon-only link for an icon-carrying action. `openInNewTab` mounts the - * target on the anchor directly instead of through `Link`, which would add - * its external glyph beside the action icon; the new-tab hint joins the - * accessible name instead, which the `aria-label` would otherwise mute. + * Icon-only link. `openInNewTab` mounts the target on the anchor rather + * than through `Link`, whose external glyph would double the icon; the + * new-tab hint joins the accessible name. * * @param {IconActionProps} props Component props. */ @@ -42,9 +41,7 @@ function IconAction( { action }: IconActionProps ): React.ReactNode { download={ action.download } render={ action.openInNewTab ? ( - /* The href and the icon content merge in - through the render-prop chain at runtime, - invisible to the static analyzer. */ + /* href and content merge in at runtime. */ // eslint-disable-next-line jsx-a11y/anchor-has-content, jsx-a11y/anchor-is-valid ) : undefined @@ -61,28 +58,20 @@ function IconAction( { action }: IconActionProps ): React.ReactNode { type WidgetFooterProps = { /** - * The actions this footer materializes; the host routes the promoted - * tiers (`relevance: 'high'` and `'medium'`) here. + * The promoted actions (`relevance: 'high'` and `'medium'`). */ actions: WidgetAction[]; /** - * Inert the footer while customizing, so it does not capture interaction. + * Inert the footer while customizing. */ editMode?: boolean; }; /** - * Persistent strip of chrome under the widget body, the prominent surface - * for the widget's promoted actions: always visible, unlike the More menu - * the remaining actions collapse into. - * - * Materialization follows the relevance tier: `'high'` actions mount as - * text links on the leading edge, labels always visible; `'medium'` actions - * mount on the trailing edge as compact affordances, icon-only when the - * action declares an icon and text links otherwise. Every affordance is a - * real anchor, so middle-click, copy address, and download semantics - * survive. + * Persistent strip under the widget body. `'high'` actions mount as leading + * text links; `'medium'` actions as trailing compact affordances, icon-only + * when they declare an icon. Every affordance is a real anchor. * * @param {WidgetFooterProps} props Component props. */ diff --git a/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx b/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx index eedcf328148d5c..5c80be37250f07 100644 --- a/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx +++ b/packages/widget-dashboard/src/components/widget-frame/widget-frame.tsx @@ -90,8 +90,6 @@ export function WidgetFrame( { const isBodyBleeding = presentation === 'full-bleed' || presentation === 'content-bleed'; - // The footer is the prominent surface for high-relevance actions; - // `splitWidgetActions` owns the routing rule shared with the menu. const { footer: footerActions } = splitWidgetActions( widgetType ); const body = ( diff --git a/packages/widget-dashboard/src/components/widgets/widgets.tsx b/packages/widget-dashboard/src/components/widgets/widgets.tsx index 5576a843a980bf..1735a336e4310f 100644 --- a/packages/widget-dashboard/src/components/widgets/widgets.tsx +++ b/packages/widget-dashboard/src/components/widgets/widgets.tsx @@ -128,8 +128,6 @@ export const Widgets = forwardRef< HTMLDivElement, WidgetsProps >( const isFullBleed = widgetType?.presentation === 'full-bleed'; - // `splitWidgetActions` owns the footer/menu routing rule; the - // frame reads the footer half of the same split. const { menu: menuActions } = splitWidgetActions( widgetType ); const hasActions = menuActions.length > 0; diff --git a/packages/widget-dashboard/src/utils/split-widget-actions.ts b/packages/widget-dashboard/src/utils/split-widget-actions.ts index 0f3ee93d1803b7..b2c08229fd64a7 100644 --- a/packages/widget-dashboard/src/utils/split-widget-actions.ts +++ b/packages/widget-dashboard/src/utils/split-widget-actions.ts @@ -1,11 +1,9 @@ import type { WidgetAction, WidgetType } from '@wordpress/widget-primitives'; /** - * Splits a widget type's declared actions across the chrome's two surfaces: - * the footer takes the promoted tiers (`relevance: 'high'` and `'medium'`), - * the More menu takes the rest. Full-bleed widgets have no chrome to host a - * footer, so every action stays in the menu. Both surfaces read this one - * rule so they cannot drift. + * Splits a widget type's actions across the chrome surfaces: the footer + * takes `relevance: 'high'` and `'medium'`, the More menu the rest. + * Full-bleed widgets have no footer, so every action stays in the menu. * * @param widgetType The widget type whose actions are routed. */ diff --git a/packages/widget-primitives/CHANGELOG.md b/packages/widget-primitives/CHANGELOG.md index 5050e74e96db1b..175a0d417bc3ee 100644 --- a/packages/widget-primitives/CHANGELOG.md +++ b/packages/widget-primitives/CHANGELOG.md @@ -4,17 +4,15 @@ ### New Features -- `WidgetRelevance` gains a `'medium'` tier between `'high'` and `'low'`: - a declaration worth persistent but compact visibility. Hosts map the - scale to surfaces of decreasing prominence +- `WidgetRelevance` gains a `'medium'` tier between `'high'` and `'low'`, + for persistent but compact visibility ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). ### Enhancements -- `useWidgetTypes` holds the icon slot with the transparent stand-in while - an action's icon reference resolves, so hosts routing actions by icon - keep a stable shape from first paint; an unresolvable reference clears - the stand-in ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). +- `useWidgetTypes` holds the icon slot with the stand-in while an action's + icon reference resolves; an unresolvable reference clears it + ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). ## 0.5.0 (2026-08-12) diff --git a/packages/widget-primitives/src/hooks/use-widget-types.ts b/packages/widget-primitives/src/hooks/use-widget-types.ts index 4b3ae6d8216b79..3f8bb5052ba334 100644 --- a/packages/widget-primitives/src/hooks/use-widget-types.ts +++ b/packages/widget-primitives/src/hooks/use-widget-types.ts @@ -25,14 +25,12 @@ const pendingIcon: WidgetIcon = createElement( 'svg', { } ); /** - * Emitted actions carry only renderable icons. A record action's wire - * reference holds the slot with the stand-in until it resolves after the - * gate; module-declared actions have no resolution pass, so anything - * non-renderable drops. + * Emitted actions carry only renderable icons: a wire reference holds the + * slot with the stand-in while it resolves; anything else non-renderable + * drops. * * @param actions Declared actions, from the record or the module. - * @param holdPending Substitute the stand-in for wire references that - * resolve after the gate. + * @param holdPending Whether wire references resolve later (record actions). */ function withRenderableIcons( actions: ( WidgetAction | WidgetActionRecord )[], @@ -210,10 +208,8 @@ export function useWidgetTypes( } /* - * Each record action's icon reference resolves off the gate - * and patches into the emitted action; an unresolvable - * reference clears the stand-in, leaving the action without - * an icon. + * Record action icon references resolve off the gate and + * patch in; an unresolvable reference clears the stand-in. */ for ( const record of records ) { for ( const action of record.actions ?? [] ) { diff --git a/packages/widget-primitives/src/stories/actions.md b/packages/widget-primitives/src/stories/actions.md index 96acad8732d69c..39bc91d28ccafe 100644 --- a/packages/widget-primitives/src/stories/actions.md +++ b/packages/widget-primitives/src/stories/actions.md @@ -60,6 +60,6 @@ Where no link primitive fits, as in a command palette, the host mounts what the The widget lists its actions; it never specifies where they go. The host maps them to its surfaces: a dashboard might gather them in a "More" menu, a footer, or a command palette. -`relevance` carries the widget's side of that decision as a decreasing scale: `'high'` marks an action worth the most prominent surface, `'medium'` one worth persistent but compact visibility, and `'low'` (the default) the rest. Attributes already use the same vocabulary: the widget declares intent, and the host owns the surface. +`relevance` carries the widget's side of that decision: `'high'` marks an action worth the most prominent surface, `'medium'` one worth persistent but compact visibility, and `'low'` (the default) the rest. Attributes use the same vocabulary: the widget declares intent, and the host owns the surface. -The dashboard host maps the scale this way: `'high'` actions mount as text links in a persistent footer under the widget body, `'medium'` actions beside them as compact icon affordances, and the rest collapse into the "More" menu. Full-bleed widgets render no chrome, so all of their actions stay in the menu. +The dashboard maps it as: `'high'` as text links in a persistent footer, `'medium'` beside them as compact icon affordances, the rest in the "More" menu. Full-bleed widgets keep every action in the menu. diff --git a/packages/widget-primitives/src/types.ts b/packages/widget-primitives/src/types.ts index 91af12b2a13de3..b76dcb8037aac6 100644 --- a/packages/widget-primitives/src/types.ts +++ b/packages/widget-primitives/src/types.ts @@ -62,9 +62,9 @@ export interface WidgetHelp { } /** - * How relevant a declaration is, as a decreasing scale. The widget declares - * importance, not a surface; hosts map the tiers to surfaces of decreasing - * prominence. `'low'` is the default. + * How relevant a declaration is. The widget declares importance, not a + * surface; hosts map the scale to surfaces of decreasing prominence. + * `'low'` is the default. */ export type WidgetRelevance = 'high' | 'medium' | 'low'; @@ -99,10 +99,7 @@ export interface WidgetAction { icon?: WidgetIcon; /** - * How relevant the action is among the widget's actions. Hosts map the - * scale to surfaces of decreasing prominence: `'high'` deserves the - * most prominent one, `'medium'` a persistent but compact one, and - * `'low'` (the default) a collapsed surface such as a menu. + * How relevant the action is among the widget's actions. */ relevance?: WidgetRelevance; From afc9e74a3205f182f6eb74fd5555af03a849bb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 16:40:11 +0900 Subject: [PATCH 08/17] update stale relevance docs to the three-tier scale --- .../architecture/dashboard-widgets.md | 2 +- packages/widget-dashboard/README.md | 2 +- .../widget-actions/widget-actions.tsx | 6 +- packages/widget-primitives/README.md | 4 +- .../widget-render/stories/index.story.tsx | 2 +- .../widget-primitives/src/stories/anatomy.md | 3 +- .../src/stories/introduction.md | 10 +- packages/wp-build/CHANGELOG.md | 5 + packages/wp-build/README.md | 154 +++++++++--------- 9 files changed, 98 insertions(+), 90 deletions(-) diff --git a/docs/explanations/architecture/dashboard-widgets.md b/docs/explanations/architecture/dashboard-widgets.md index 8abacb3ad47a6a..27d5ca5399d77c 100644 --- a/docs/explanations/architecture/dashboard-widgets.md +++ b/docs/explanations/architecture/dashboard-widgets.md @@ -33,7 +33,7 @@ The split between `widget.json` and `widget.ts` is deliberate. `widget.json` is Unlike the other translatable strings, `help` is an object: `content` plus optional `links`, meant for compact surfaces such as tooltips. -`actions`: declarative verbs (`id`, `label`, optional `icon` and `relevance`, plus exactly one fulfillment key). Today the only key is `href`, a link target, with optional `download` / `openInNewTab`. Hosts mount the primitive and place it; the dashboard uses a "More" menu. A relative `href` that exists under `widgets/{name}/` becomes a plugin URL at registration; missing relative non-admin files are dropped. `data:` and `javascript:` hrefs are rejected. Prefer absolute URLs for assets that must work in the plugin zip (which does not ship `widgets/`). +`actions`: declarative verbs (`id`, `label`, optional `icon` and `relevance`, plus exactly one fulfillment key). Today the only key is `href`, a link target, with optional `download` / `openInNewTab`. Hosts mount the primitive and place it; the dashboard routes by `relevance`: `'high'` and `'medium'` to a persistent footer, the rest to a "More" menu. A relative `href` that exists under `widgets/{name}/` becomes a plugin URL at registration; missing relative non-admin files are dropped. `data:` and `javascript:` hrefs are rejected. Prefer absolute URLs for assets that must work in the plugin zip (which does not ship `widgets/`). `icon`: a registered icon name (`collection/icon-name`), resolved client-side through the site's Icons API. Malformed names are dropped at registration. diff --git a/packages/widget-dashboard/README.md b/packages/widget-dashboard/README.md index 35881bff0785ef..39c1e74142fca8 100644 --- a/packages/widget-dashboard/README.md +++ b/packages/widget-dashboard/README.md @@ -223,7 +223,7 @@ When a widget type declares `help`, the tile chrome surfaces its `content` and o ### Attribute editing -A widget declares importance per attribute through `relevance` (`'high' | 'low'`, absent means `'low'`). The declaration states importance, not placement; this host maps it to two surfaces: +A widget declares importance per attribute through `relevance` (`'high' | 'medium' | 'low'`, absent means `'low'`). The declaration states importance, not placement; this host maps it to two surfaces: - **Prominent surface**: `relevance: 'high'` fields render as bare inline controls in the tile header, for in-context edits. - **Settings surface**: the full schema, opened from the settings trigger. The trigger shows only when some attribute is not promoted; otherwise it would repeat the prominent surface. diff --git a/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx b/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx index ee844f337d4eeb..488c37e4eecaad 100644 --- a/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx +++ b/packages/widget-dashboard/src/components/widget-actions/widget-actions.tsx @@ -12,9 +12,9 @@ const { Menu } = unlock( componentsPrivateApis ); type WidgetActionsProps = { /** - * The actions this menu materializes. The host routes them by relevance: - * the footer takes `'high'`, this menu the rest, and every action for - * full-bleed widgets, which have no footer. + * The actions this menu materializes. The host routes by relevance: + * the footer takes `'high'` and `'medium'`, this menu the rest, and + * every action for full-bleed widgets, which have no footer. */ actions: WidgetAction[]; }; diff --git a/packages/widget-primitives/README.md b/packages/widget-primitives/README.md index f797f5e9270852..3123dd7cf82e67 100644 --- a/packages/widget-primitives/README.md +++ b/packages/widget-primitives/README.md @@ -60,11 +60,11 @@ It takes host-supplied records (`WidgetModuleRecord[]`, or `null` while loading) ### `WidgetAttributeField< Item >` It's an authoring helper: a DataViews `Field` whose `id` is narrowed to the widget's attribute keys. -Its optional `relevance` hint (`'high' | 'low'`) marks attributes a host may promote to a prominent surface. +Its optional `relevance` hint (`'high' | 'medium' | 'low'`) marks attributes a host may promote to a prominent surface. ### `WidgetAction` -It's a declarative verb a widget type exposes: an envelope (`id`, `label`) plus exactly one fulfillment, named by the key carrying it. +It's a declarative verb a widget type exposes: an envelope (`id`, `label`, optional `icon` and `relevance`) plus exactly one fulfillment, named by the key carrying it. Today the only key is `href`, a link target, with optional `download` / `openInNewTab`. `data:` and `javascript:` hrefs are rejected at registration. Prefer a file next to the widget, an absolute URL, or `downloadBlob` for generated content. diff --git a/packages/widget-primitives/src/components/widget-render/stories/index.story.tsx b/packages/widget-primitives/src/components/widget-render/stories/index.story.tsx index 74d209eee70083..062ddbca04b463 100644 --- a/packages/widget-primitives/src/components/widget-render/stories/index.story.tsx +++ b/packages/widget-primitives/src/components/widget-render/stories/index.story.tsx @@ -527,7 +527,7 @@ export const WithRelevance: StoryObj = { docs: { description: { story: ` -Each attribute may carry a \`relevance\` hint (\`'high' | 'low'\`). The widget declares importance; the host chooses the surface. When absent, treat the hint as \`'low'\`. +Each attribute may carry a \`relevance\` hint (\`'high' | 'medium' | 'low'\`). The widget declares importance; the host chooses the surface. When absent, treat the hint as \`'low'\`. **In this demo** diff --git a/packages/widget-primitives/src/stories/anatomy.md b/packages/widget-primitives/src/stories/anatomy.md index 3c00a7f508a768..a02494fc19ceac 100644 --- a/packages/widget-primitives/src/stories/anatomy.md +++ b/packages/widget-primitives/src/stories/anatomy.md @@ -45,9 +45,10 @@ How the widget represents its data and the verbs it exposes: `attributes`, `acti The `attributes` are the contract between host and widget. The widget owns their shape and meaning; the host owns their values. -Each entry in `attributes` is a DataViews `Field` plus an optional `relevance` hint (`'high' | 'low'`). Its `type` may also reference a registered field type by name, resolved to plain `Field` props before any host reads the schema (see **Field Types**). The widget declares how important an attribute is; the host decides where, and whether, to expose it. When the hint is absent, treat it as `'low'`. +Each entry in `attributes` is a DataViews `Field` plus an optional `relevance` hint (`'high' | 'medium' | 'low'`). Its `type` may also reference a registered field type by name, resolved to plain `Field` props before any host reads the schema (see **Field Types**). The widget declares how important an attribute is; the host decides where, and whether, to expose it. When the hint is absent, treat it as `'low'`. - `'high'`: the host _may_ promote the field to a prominent surface near the instance, for quick in-context editing without opening a separate settings UI. +- `'medium'`: worth persistent but compact visibility; a host without such a surface treats it as `'low'`. - `'low'` (default): the field belongs in the host's settings surface, a form built from the full schema. The widget names importance, not a surface. One host might promote `'high'` fields inline; another might fold everything into a single panel. Both honor the same contract. diff --git a/packages/widget-primitives/src/stories/introduction.md b/packages/widget-primitives/src/stories/introduction.md index 8bfbb2e4b0c72b..59d45d9f840ad4 100644 --- a/packages/widget-primitives/src/stories/introduction.md +++ b/packages/widget-primitives/src/stories/introduction.md @@ -14,8 +14,8 @@ A _host_ is any context that renders widgets: a dashboard, a sidebar, a plugin p The shapes a host reads to discover and render a widget: -- `WidgetType`, `WidgetName`, `WidgetIcon` -- `WidgetRenderProps`, `ResolveWidgetModule`, `WidgetModuleRecord` +- `WidgetType`, `WidgetName`, `WidgetIcon` +- `WidgetRenderProps`, `ResolveWidgetModule`, `WidgetModuleRecord` Defined here and re-exported nowhere else. @@ -23,7 +23,7 @@ Defined here and re-exported nowhere else. `WidgetAttributeField< Item >` is for widget authors, not hosts. It narrows a DataViews `Field.id` to the keys of the widget's attribute object, so a typo'd field `id` is caught while authoring. -It also accepts an optional `relevance` hint (`'high' | 'low'`). The widget declares importance, not a surface. See **Anatomy** for how hosts may use it. +It also accepts an optional `relevance` hint (`'high' | 'medium' | 'low'`). The widget declares importance, not a surface. See **Anatomy** for how hosts may use it. How a widget is authored (its folder, `widget.json`, `widget.ts`, `render.tsx`) is covered in **System Architecture**. @@ -31,8 +31,8 @@ How a widget is authored (its folder, `widget.json`, `widget.ts`, `render.tsx`) `useWidgetTypes( records )` takes host-supplied widget-module records, imports each record's metadata module, and returns: -- `WidgetType[]` -- `isResolvingWidgetTypes`, which stays `true` before records are supplied (`null` or `undefined`) and while their metadata modules are still importing +- `WidgetType[]` +- `isResolvingWidgetTypes`, which stays `true` before records are supplied (`null` or `undefined`) and while their metadata modules are still importing The hook reaches for no store or endpoint. The host fetches the records however it wants and passes them in. diff --git a/packages/wp-build/CHANGELOG.md b/packages/wp-build/CHANGELOG.md index 15a696ca7f9076..0b8c58cf89a5ff 100644 --- a/packages/wp-build/CHANGELOG.md +++ b/packages/wp-build/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +### Documentation + +- Widget attributes: the `relevance` hint documents the `'medium'` tier + ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). + ## 0.21.0 (2026-08-12) ### Enhancements diff --git a/packages/wp-build/README.md b/packages/wp-build/README.md index f549ec0e8b0145..3b272dca9cd973 100644 --- a/packages/wp-build/README.md +++ b/packages/wp-build/README.md @@ -6,11 +6,11 @@ Build tool for WordPress plugins. `@wordpress/build` is an opinionated build system designed for WordPress plugins. It provides: -- **Transpilation**: Converts TypeScript/JSX source code to both CommonJS (`build/`) and ESM (`build-module/`) formats using esbuild -- **Style Compilation**: Processes SCSS files and CSS modules, generating LTR and RTL versions -- **Bundling**: Creates browser-ready bundles for WordPress scripts and modules -- **PHP Generation**: Automatically generates PHP registration files for scripts, modules, and styles -- **Watch Mode**: Incremental rebuilds during development +- **Transpilation**: Converts TypeScript/JSX source code to both CommonJS (`build/`) and ESM (`build-module/`) formats using esbuild +- **Style Compilation**: Processes SCSS files and CSS modules, generating LTR and RTL versions +- **Bundling**: Creates browser-ready bundles for WordPress scripts and modules +- **PHP Generation**: Automatically generates PHP registration files for scripts, modules, and styles +- **Watch Mode**: Incremental rebuilds during development ## Installation @@ -67,9 +67,9 @@ Configure your `package.json` with the following optional fields: Controls whether the package is exposed as a bundled WordPress script/module and accessible via the configured global variable. -- **`true`**: The package will be bundled and exposed as a WordPress script. It will be available in WordPress as part of the configured global (e.g., `wp.blockEditor`, `wp.data`, or a custom global name if configured differently). +- **`true`**: The package will be bundled and exposed as a WordPress script. It will be available in WordPress as part of the configured global (e.g., `wp.blockEditor`, `wp.data`, or a custom global name if configured differently). -- **Omitted or `false` (default)**: The package will not be exposed as a WordPress script. Use this for packages designed solely as dependencies for other packages. The package can still be used as a dependency via npm imports by other packages. +- **Omitted or `false` (default)**: The package will not be exposed as a WordPress script. Use this for packages designed solely as dependencies for other packages. The package can still be used as a dependency via npm imports by other packages. ```json { @@ -107,7 +107,7 @@ Additional script dependencies: ```json { - "wpScriptExtraDependencies": ["wp-polyfill"] + "wpScriptExtraDependencies": [ "wp-polyfill" ] } ``` @@ -232,8 +232,8 @@ The prefix used for WordPress script handles in `.asset.php` files (e.g., `wp-da With this configuration: -- `@my-plugin/editor` → `window.myPlugin.editor` with handle `mp-editor` -- `@my-plugin/data` → `window.myPlugin.data` with handle `mp-data` +- `@my-plugin/editor` → `window.myPlugin.editor` with handle `mp-editor` +- `@my-plugin/data` → `window.myPlugin.data` with handle `mp-data` ### `wpPlugin.externalNamespaces` @@ -258,9 +258,9 @@ Additional package namespaces to externalize (consume as externals, not expose). This allows your packages to consume third-party dependencies as externals: -- `import { Cart } from '@woo/cart'` → `window.woo.cart` with handle `woocommerce-cart` -- `import { Button } from '@acme/ui'` → `window.acme.ui` with handle `acme-plugin-ui` -- Dependencies are tracked in `.asset.php` files +- `import { Cart } from '@woo/cart'` → `window.woo.cart` with handle `woocommerce-cart` +- `import { Button } from '@acme/ui'` → `window.acme.ui` with handle `acme-plugin-ui` +- Dependencies are tracked in `.asset.php` files If `handlePrefix` is omitted, it defaults to the namespace key (e.g., `"woo"` → `woo-cart`). @@ -277,7 +277,7 @@ Pages can be defined as simple strings or as objects with initialization modules "my-admin-page", { "id": "my-other-page", - "init": ["@my-plugin/my-page-init"] + "init": [ "@my-plugin/my-page-init" ] } ] } @@ -286,19 +286,19 @@ Pages can be defined as simple strings or as objects with initialization modules **Page Configuration:** -- **String format**: `"my-admin-page"` - Simple page with no init modules -- **Object format**: `{ "id": "page-slug", "init": ["@scope/package"], "experimental": true }` - Page with optional init modules - - **`id`** (required): The page slug used in WordPress admin URLs - - **`init`** (optional): Array of script module IDs to execute during page initialization - - **`experimental`** (optional, default `false`): When `true`, the page is excluded from WordPress Core builds (`IS_WORDPRESS_CORE=true`), along with any route that belongs only to experimental pages. +- **String format**: `"my-admin-page"` - Simple page with no init modules +- **Object format**: `{ "id": "page-slug", "init": ["@scope/package"], "experimental": true }` - Page with optional init modules + - **`id`** (required): The page slug used in WordPress admin URLs + - **`init`** (optional): Array of script module IDs to execute during page initialization + - **`experimental`** (optional, default `false`): When `true`, the page is excluded from WordPress Core builds (`IS_WORDPRESS_CORE=true`), along with any route that belongs only to experimental pages. **Generated Files:** This generates two page modes: -- `build/pages/my-admin-page/page.php` - Full-page mode (takes over entire admin screen with custom sidebar) -- `build/pages/my-admin-page/page-wp-admin.php` - WP-Admin mode (integrates within standard wp-admin interface) -- `build/pages.php` - Loader for all pages +- `build/pages/my-admin-page/page.php` - Full-page mode (takes over entire admin screen with custom sidebar) +- `build/pages/my-admin-page/page-wp-admin.php` - WP-Admin mode (integrates within standard wp-admin interface) +- `build/pages.php` - Loader for all pages Each mode provides route/menu registration functions and a render callback. Routes are automatically registered for both modes. @@ -343,8 +343,8 @@ add_menu_page( 'Title', 'Menu', 'capability', 'my-admin-page', 'my_plugin_my_adm **Init Modules:** Init modules are JavaScript packages that execute during page initialization, after menu items and routes are registered and before the app renders. They're ideal for: -- Adding icons to menu items (icons can't be passed from PHP) -- Registering command palette entries +- Adding icons to menu items (icons can't be passed from PHP) +- Registering command palette entries **Creating an Init Module:** @@ -395,9 +395,9 @@ The `init()` function is **mandatory** - all init modules must export this named This configuration: -- Packages like `@wordpress/data` expose `window.wp.data` -- Packages like `@wordpress/block-editor` expose `window.wp.blockEditor` -- All packages can consume `@wordpress/*` as externals +- Packages like `@wordpress/data` expose `window.wp.data` +- Packages like `@wordpress/block-editor` expose `window.wp.blockEditor` +- All packages can consume `@wordpress/*` as externals ### Example: Third-Party Plugin @@ -413,18 +413,18 @@ This configuration: This configuration: -- Packages like `@acme/editor` expose `window.acme.editor` -- Packages like `@acme/data` expose `window.acme.data` -- All packages can still consume `@wordpress/*` → `window.wp.*` -- All packages can still consume vendors (react, lodash) → `window.React`, `window.lodash` +- Packages like `@acme/editor` expose `window.acme.editor` +- Packages like `@acme/data` expose `window.acme.data` +- All packages can still consume `@wordpress/*` → `window.wp.*` +- All packages can still consume vendors (react, lodash) → `window.React`, `window.lodash` ### Behavior -- **Packages with `wpScript: true` matching the namespace**: Bundled with global exposure -- **Packages with `wpScript: true` not matching the namespace**: Bundled without global exposure -- **Dependencies**: `@wordpress/*` packages are always externalized to `wp.*` globals -- **Vendors**: React, lodash, jQuery, moment are always externalized to their standard globals -- **Asset files**: `.asset.php` files are always generated for WordPress dependency management +- **Packages with `wpScript: true` matching the namespace**: Bundled with global exposure +- **Packages with `wpScript: true` not matching the namespace**: Bundled without global exposure +- **Dependencies**: `@wordpress/*` packages are always externalized to `wp.*` globals +- **Vendors**: React, lodash, jQuery, moment are always externalized to their standard globals +- **Asset files**: `.asset.php` files are always generated for WordPress dependency management ## Output Structure @@ -471,15 +471,15 @@ For routes that should appear on multiple pages: { "route": { "path": "/settings", - "page": ["my-admin-page", "other-page"] + "page": [ "my-admin-page", "other-page" ] } } ``` The `page` field can be either: -- **String**: Route belongs to a single page -- **Array**: Route appears on multiple pages (the build system will register the route for each page) +- **String**: Route belongs to a single page +- **Array**: Route appears on multiple pages (the build system will register the route for each page) Each page ID must match one of the pages defined in `wpPlugin.pages` in your root `package.json`. This tells the build system which page(s) this route belongs to. It can also map to existing pages registered by other plugins. @@ -513,22 +513,22 @@ The canvas is a full-screen area typically used for editor previews. To use a cu Export a `route` object with optional hooks. Each hook receives `{ params, search }` — path parameters and query string values from the URL. -- **`beforeLoad`** — Runs before navigation completes. Use for auth checks, validation, or redirects. Throw `redirect()` or `notFound()` from `@wordpress/route` to abort navigation. -- **`loader`** — Runs while the route is loading. Use to preload data (for example, `resolveSelect` from `@wordpress/data`) so `stage` components can read from the store without a loading state. May return an object whose properties are merged into the route's loader data. For data that must be available before the JavaScript application loads, use [`rest_preload_api_request()`](https://developer.wordpress.org/reference/functions/rest_preload_api_request/) in your page's PHP render callback instead. -- **`canvas`** — Runs in parallel with `loader`. Controls which canvas is rendered depending on return values: - - `CanvasData` (`{ postType, postId, isPreview?, editLink? }`) → default WordPress editor canvas - - `null` → custom `canvas.tsx` component (if provided) - - `undefined` or omitted → no canvas +- **`beforeLoad`** — Runs before navigation completes. Use for auth checks, validation, or redirects. Throw `redirect()` or `notFound()` from `@wordpress/route` to abort navigation. +- **`loader`** — Runs while the route is loading. Use to preload data (for example, `resolveSelect` from `@wordpress/data`) so `stage` components can read from the store without a loading state. May return an object whose properties are merged into the route's loader data. For data that must be available before the JavaScript application loads, use [`rest_preload_api_request()`](https://developer.wordpress.org/reference/functions/rest_preload_api_request/) in your page's PHP render callback instead. +- **`canvas`** — Runs in parallel with `loader`. Controls which canvas is rendered depending on return values: + - `CanvasData` (`{ postType, postId, isPreview?, editLink? }`) → default WordPress editor canvas + - `null` → custom `canvas.tsx` component (if provided) + - `undefined` or omitted → no canvas ```tsx export const route = { - beforeLoad: ({ params, search }) => { + beforeLoad: ( { params, search } ) => { // Pre-navigation validation, auth checks }, - loader: ({ params, search }) => { + loader: ( { params, search } ) => { // Data preloading }, - canvas: ({ params, search }) => { + canvas: ( { params, search } ) => { // Return CanvasData to use default canvas (editor) return { postType: params.type, @@ -542,7 +542,7 @@ export const route = { // Return undefined to show no canvas // return undefined; - } + }, }; ``` @@ -550,10 +550,10 @@ export const route = { The build system generates: -- `build/routes/{route-name}/content.js` - Bundled stage/inspector/canvas components -- `build/routes/{route-name}/route.js` - Bundled lifecycle hooks (if present) -- `build/routes/registry.php` - Route registry data -- `build/routes.php` - Route registration logic +- `build/routes/{route-name}/content.js` - Bundled stage/inspector/canvas components +- `build/routes/{route-name}/route.js` - Bundled lifecycle hooks (if present) +- `build/routes/registry.php` - Route registry data +- `build/routes.php` - Route registration logic The boot package in Gutenberg will automatically use these routes and make them available. @@ -580,13 +580,13 @@ widgets/ Widgets use a dual-entry pattern, similar in spirit to how blocks split metadata between `block.json` and `edit.js`: -| Concern | Lives in | Reason | -| --- | --- | --- | -| Identity (`name`) | both (must match) | server needs it to register; client uses it to resolve the runtime entry | -| Translatable metadata (`title`, `description`, `help`, `keywords`) | `widget.json` | translated server-side via `textdomain`, so the host receives localized strings without a JS runtime | -| Framing (`category`, `presentation`) | `widget.json` | plain JSON the host reads without a JS runtime | -| Attribute schema (types, options, labels, `relevance`) | `widget.ts` | needs TypeScript coupling with `render` props; labels are translated with `__()` | -| Icon and `example` | `widget.ts` | runtime values co-located with the attribute schema | +| Concern | Lives in | Reason | +| ------------------------------------------------------------------ | ----------------- | ---------------------------------------------------------------------------------------------------- | +| Identity (`name`) | both (must match) | server needs it to register; client uses it to resolve the runtime entry | +| Translatable metadata (`title`, `description`, `help`, `keywords`) | `widget.json` | translated server-side via `textdomain`, so the host receives localized strings without a JS runtime | +| Framing (`category`, `presentation`) | `widget.json` | plain JSON the host reads without a JS runtime | +| Attribute schema (types, options, labels, `relevance`) | `widget.ts` | needs TypeScript coupling with `render` props; labels are translated with `__()` | +| Icon and `example` | `widget.ts` | runtime values co-located with the attribute schema | Rule of thumb: anything the host needs before loading a widget's module — identity, translatable copy, framing — goes in `widget.json`, which the build forwards to `build/widgets/registry.php` and exposes through the REST API. Anything that needs TypeScript or runtime values (attribute schema, icon, `example`) goes in `widget.ts`. @@ -607,14 +607,14 @@ Rule of thumb: anything the host needs before loading a widget's module — iden **Fields:** -- **`name`** (required): Namespaced identifier (e.g., `"my-plugin/hello-world"`) -- **`title`** (optional): Human-readable title. Translated server-side using `textdomain`. -- **`description`** (optional): Short description. Translated server-side using `textdomain`. -- **`help`** (optional): Contextual help note for compact surfaces. An object with `content` (may carry ``/``) and optional `links` (`label`, `href`). Translated server-side using `textdomain`. -- **`keywords`** (optional): Search aliases. Translated server-side using `textdomain`. -- **`category`** (optional): Grouping category for filtering -- **`presentation`** (optional): Rendering intent (`framed`, `content-bleed`, `full-bleed`) -- **`textdomain`** (optional): Gettext text domain for translating `title`, `description`, `help`, and `keywords` +- **`name`** (required): Namespaced identifier (e.g., `"my-plugin/hello-world"`) +- **`title`** (optional): Human-readable title. Translated server-side using `textdomain`. +- **`description`** (optional): Short description. Translated server-side using `textdomain`. +- **`help`** (optional): Contextual help note for compact surfaces. An object with `content` (may carry ``/``) and optional `links` (`label`, `href`). Translated server-side using `textdomain`. +- **`keywords`** (optional): Search aliases. Translated server-side using `textdomain`. +- **`category`** (optional): Grouping category for filtering +- **`presentation`** (optional): Rendering intent (`framed`, `content-bleed`, `full-bleed`) +- **`textdomain`** (optional): Gettext text domain for translating `title`, `description`, `help`, and `keywords` ### `widget.ts` — runtime schema @@ -657,7 +657,7 @@ const widget = { export default widget; ``` -Each attribute entry is a DataViews `Field` plus an optional `relevance` hint (`'high' | 'low'`). The widget declares importance; the host decides where to expose each field. When absent, `relevance` defaults to `'low'`. +Each attribute entry is a DataViews `Field` plus an optional `relevance` hint (`'high' | 'medium' | 'low'`). The widget declares importance; the host decides where to expose each field. When absent, `relevance` defaults to `'low'`. The same `HelloWorldAttributes` type is consumed by `render.tsx`, giving the author a single source of truth for the data contract. @@ -677,7 +677,9 @@ export default function HelloWorld( { attributes }: HelloWorldRenderProps ) { return (
Hello, { attributes.greeting ?? 'World' }! - { attributes.showDate && } + { attributes.showDate && ( + + ) }
); } @@ -689,12 +691,12 @@ All non-JSON entries are optional. The build system checks for files with extens The build system generates: -- `build/widgets/{widget-name}/render.min.js` + `render.js` — Bundled UI component (ESM) -- `build/widgets/{widget-name}/render.min.asset.php` — Asset metadata for render module -- `build/widgets/{widget-name}/widget.min.js` + `widget.js` — Bundled metadata (ESM) -- `build/widgets/{widget-name}/widget.min.asset.php` — Asset metadata for widget module -- `build/widgets/registry.php` — Widget registry data -- `build/widgets.php` — Script module registration logic +- `build/widgets/{widget-name}/render.min.js` + `render.js` — Bundled UI component (ESM) +- `build/widgets/{widget-name}/render.min.asset.php` — Asset metadata for render module +- `build/widgets/{widget-name}/widget.min.js` + `widget.js` — Bundled metadata (ESM) +- `build/widgets/{widget-name}/widget.min.asset.php` — Asset metadata for widget module +- `build/widgets/registry.php` — Widget registry data +- `build/widgets.php` — Script module registration logic ### PHP Registration From 73d82b2a0f09d05b2a7cd32508e53280e2746ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 17:20:41 +0900 Subject: [PATCH 09/17] add the footer to the widget chrome anatomy story --- .../src/stories/assets/footer-anatomy.svg | 31 +++++++++++++++++++ .../src/stories/widget-chrome.md | 28 ++++++++++++++--- 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 packages/widget-dashboard/src/stories/assets/footer-anatomy.svg diff --git a/packages/widget-dashboard/src/stories/assets/footer-anatomy.svg b/packages/widget-dashboard/src/stories/assets/footer-anatomy.svg new file mode 100644 index 00000000000000..eec6a1bfe33547 --- /dev/null +++ b/packages/widget-dashboard/src/stories/assets/footer-anatomy.svg @@ -0,0 +1,31 @@ + + + + the footer strip + + + + + + + + + + + + + View all drafts + + + + + + + + High + text links · leading + + + Medium + compact · trailing + diff --git a/packages/widget-dashboard/src/stories/widget-chrome.md b/packages/widget-dashboard/src/stories/widget-chrome.md index 1bef1169453e40..e5f6ffec508de5 100644 --- a/packages/widget-dashboard/src/stories/widget-chrome.md +++ b/packages/widget-dashboard/src/stories/widget-chrome.md @@ -4,7 +4,7 @@ This package is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes. -The chrome is everything the dashboard wraps around a widget instance: the header, its controls, and the boundaries that catch errors and loading. +The chrome is everything the dashboard wraps around a widget instance: the header, its controls, the footer, and the boundaries that catch errors and loading. The widget declares its identity and how it wants to be framed; the chrome materializes both. The widget never paints its own header or toolbar. @@ -13,9 +13,9 @@ The widget never paints its own header or toolbar. The dashboard widget interprets `presentation` and determines how much chrome a widget gets. -* `framed` paints a header and pads the content. -* `content-bleed` keeps the header but lets the content fill the available area. -* `full-bleed` hides the header and gives the widget the whole tile, while keeping the identity available to assistive technology. +- `framed` paints a header and pads the content. +- `content-bleed` keeps the header but lets the content fill the available area. +- `full-bleed` hides the header and the footer and gives the widget the whole tile, while keeping the identity available to assistive technology. Whatever the presentation, an error boundary and a loading fallback wrap the content, so a widget that throws or suspends never breaks the tile. @@ -29,7 +29,7 @@ The sections are semantic. A control belongs to a section by its nature, not by - **Identity.** The widget's icon, title, and help. It names the tile, and its title truncates rather than wrapping when the row runs short. - **Attributes.** The widget's high-relevance attributes: quick in-place editing or a dropdown button when there isn't enough space. -- **More.** The widget's declared actions, gathered in a menu on the trailing edge. +- **More.** The widget's low-relevance actions, gathered in a menu on the trailing edge. ### Fitting the row @@ -46,3 +46,21 @@ It measures the identity as it stands, discounts the sections that keep their si Because the decision measures the real row, every section counts on its own. The widget declares its sections; the header measures the fit. + +## The footer + +A persistent strip under the body, for the actions the widget promotes. + +![The footer strip: a full-width divider, high-relevance actions as text links on the leading edge, medium-relevance actions as compact icon affordances on the trailing edge.](./assets/footer-anatomy.svg) + +`relevance` routes every action to its surface. + +- **`high`.** Text links on the leading edge, labels always visible. +- **`medium`.** Compact affordances on the trailing edge: icon-only with a declared icon, text links otherwise. +- **`low`** (default). The header's More menu. + +Every affordance is a real anchor: middle-click, copy address, and download survive. + +The divider spans the tile, and the body above keeps no bottom padding, so scrolled content runs flush against it. + +The widget declares importance; the footer materializes it. From 1854a342f9f5da2b62a0638f01147a69b4d5cf4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 17:48:44 +0900 Subject: [PATCH 10/17] wire footer diagram into the chrome story --- packages/widget-dashboard/src/stories/widget-chrome.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/widget-dashboard/src/stories/widget-chrome.mdx b/packages/widget-dashboard/src/stories/widget-chrome.mdx index 1f6cb049a30be7..fea1a312a541cf 100644 --- a/packages/widget-dashboard/src/stories/widget-chrome.mdx +++ b/packages/widget-dashboard/src/stories/widget-chrome.mdx @@ -2,10 +2,12 @@ import { Meta, Markdown } from '@storybook/addon-docs/blocks'; import WidgetChromeDoc from './widget-chrome.md?raw'; import headerAnatomy from './assets/header-anatomy.svg'; import headerFit from './assets/header-fit.svg'; +import footerAnatomy from './assets/footer-anatomy.svg'; { WidgetChromeDoc.replace( './assets/header-anatomy.svg', headerAnatomy ) - .replace( './assets/header-fit.svg', headerFit ) } + .replace( './assets/header-fit.svg', headerFit ) + .replace( './assets/footer-anatomy.svg', footerAnatomy ) } From 5739aa982eae02cc54d52bb8e4be9223535e7810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 20:58:26 +0900 Subject: [PATCH 11/17] update relevance union in wp-build widget typedef --- packages/wp-build/lib/widget-utils.mjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/wp-build/lib/widget-utils.mjs b/packages/wp-build/lib/widget-utils.mjs index bc2a7a7f18b770..7c042a6548ea0e 100644 --- a/packages/wp-build/lib/widget-utils.mjs +++ b/packages/wp-build/lib/widget-utils.mjs @@ -34,13 +34,13 @@ export function getAllWidgets( rootDir ) { /** * @typedef {Object} WidgetActionMetadata - * @property {string} id Stable identifier, local to the widget type. - * @property {string} label Human-readable label. Translatable. - * @property {string} [icon] Registered icon name (`collection/icon-name`). - * @property {'high'|'low'} [relevance] How relevant the action is among the widget's actions. - * @property {string} href Destination the action points at. - * @property {string|boolean} [download] Download the destination; a string sets the filename. - * @property {boolean} [openInNewTab] Open the destination in a new browser tab. + * @property {string} id Stable identifier, local to the widget type. + * @property {string} label Human-readable label. Translatable. + * @property {string} [icon] Registered icon name (`collection/icon-name`). + * @property {'high'|'medium'|'low'} [relevance] How relevant the action is among the widget's actions. + * @property {string} href Destination the action points at. + * @property {string|boolean} [download] Download the destination; a string sets the filename. + * @property {boolean} [openInNewTab] Open the destination in a new browser tab. */ /** From 1e74f1583fe73019ddb1f24cb8acf96bea66364f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 21:18:19 +0900 Subject: [PATCH 12/17] add metadata-to-tile overview to the chrome story --- .../src/stories/assets/tile-anatomy.svg | 50 +++++++++++++++++++ .../src/stories/widget-chrome.md | 8 +++ .../src/stories/widget-chrome.mdx | 4 +- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 packages/widget-dashboard/src/stories/assets/tile-anatomy.svg diff --git a/packages/widget-dashboard/src/stories/assets/tile-anatomy.svg b/packages/widget-dashboard/src/stories/assets/tile-anatomy.svg new file mode 100644 index 00000000000000..8c29b6ce4a415f --- /dev/null +++ b/packages/widget-dashboard/src/stories/assets/tile-anatomy.svg @@ -0,0 +1,50 @@ + + + + from metadata to tile + + + + + + + Goal Progress + + i + + Metric + + + + + + + + + + + + + + + View goal details + + + + + + + header + icon · title · help + attributes: high · actions: low + + + + content + render module · attribute values + + + + footer + actions: high · medium + diff --git a/packages/widget-dashboard/src/stories/widget-chrome.md b/packages/widget-dashboard/src/stories/widget-chrome.md index e5f6ffec508de5..cd0ff22cdfceaf 100644 --- a/packages/widget-dashboard/src/stories/widget-chrome.md +++ b/packages/widget-dashboard/src/stories/widget-chrome.md @@ -9,6 +9,14 @@ The chrome is everything the dashboard wraps around a widget instance: the heade The widget declares its identity and how it wants to be framed; the chrome materializes both. The widget never paints its own header or toolbar. +## From metadata to tile + +The chrome reads the widget type and materializes each field in one of three areas. + +![One widget type materialized as a tile of three areas: the header takes the identity, the high-relevance attributes, and the low-relevance actions; the content takes the render module fed with the attribute values; the footer takes the promoted actions.](./assets/tile-anatomy.svg) + +The header takes the identity (`icon`, `title`, `help`), the high-relevance `attributes`, and the low-relevance `actions`. The content belongs to the render module, fed the attribute values. The footer takes the promoted `actions`. + ## The frame The dashboard widget interprets `presentation` and determines how much chrome a widget gets. diff --git a/packages/widget-dashboard/src/stories/widget-chrome.mdx b/packages/widget-dashboard/src/stories/widget-chrome.mdx index fea1a312a541cf..a76ce70477979b 100644 --- a/packages/widget-dashboard/src/stories/widget-chrome.mdx +++ b/packages/widget-dashboard/src/stories/widget-chrome.mdx @@ -1,5 +1,6 @@ import { Meta, Markdown } from '@storybook/addon-docs/blocks'; import WidgetChromeDoc from './widget-chrome.md?raw'; +import tileAnatomy from './assets/tile-anatomy.svg'; import headerAnatomy from './assets/header-anatomy.svg'; import headerFit from './assets/header-fit.svg'; import footerAnatomy from './assets/footer-anatomy.svg'; @@ -7,7 +8,8 @@ import footerAnatomy from './assets/footer-anatomy.svg'; - { WidgetChromeDoc.replace( './assets/header-anatomy.svg', headerAnatomy ) + { WidgetChromeDoc.replace( './assets/tile-anatomy.svg', tileAnatomy ) + .replace( './assets/header-anatomy.svg', headerAnatomy ) .replace( './assets/header-fit.svg', headerFit ) .replace( './assets/footer-anatomy.svg', footerAnatomy ) } From c7434cb1e63e88e1fd8c224fb6d019045369c2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 21:21:05 +0900 Subject: [PATCH 13/17] fix header mapping in the tile overview --- .../widget-dashboard/src/stories/assets/tile-anatomy.svg | 9 +++++---- packages/widget-dashboard/src/stories/widget-chrome.md | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/widget-dashboard/src/stories/assets/tile-anatomy.svg b/packages/widget-dashboard/src/stories/assets/tile-anatomy.svg index 8c29b6ce4a415f..6cd804445184af 100644 --- a/packages/widget-dashboard/src/stories/assets/tile-anatomy.svg +++ b/packages/widget-dashboard/src/stories/assets/tile-anatomy.svg @@ -11,9 +11,9 @@ Goal Progress i - - Metric - + + Metric + @@ -36,7 +36,8 @@ header icon · title · help - attributes: high · actions: low + attributes: high inline · full schema in settings + actions: low diff --git a/packages/widget-dashboard/src/stories/widget-chrome.md b/packages/widget-dashboard/src/stories/widget-chrome.md index cd0ff22cdfceaf..e7ce69fa7552e2 100644 --- a/packages/widget-dashboard/src/stories/widget-chrome.md +++ b/packages/widget-dashboard/src/stories/widget-chrome.md @@ -15,7 +15,7 @@ The chrome reads the widget type and materializes each field in one of three are ![One widget type materialized as a tile of three areas: the header takes the identity, the high-relevance attributes, and the low-relevance actions; the content takes the render module fed with the attribute values; the footer takes the promoted actions.](./assets/tile-anatomy.svg) -The header takes the identity (`icon`, `title`, `help`), the high-relevance `attributes`, and the low-relevance `actions`. The content belongs to the render module, fed the attribute values. The footer takes the promoted `actions`. +The header takes the identity (`icon`, `title`, `help`), the high-relevance `attributes` inline plus the settings trigger for the full schema, and the low-relevance `actions` in the More menu. The content belongs to the render module, fed the attribute values. The footer takes the promoted `actions`. ## The frame From 1c249555d189e56bb10bbc8ec6a42978590fa3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 21:50:08 +0900 Subject: [PATCH 14/17] render icon prefix on high footer actions --- packages/widget-dashboard/CHANGELOG.md | 7 ++++--- packages/widget-dashboard/README.md | 2 +- .../widget-footer/widget-footer.module.css | 7 +++++++ .../src/components/widget-footer/widget-footer.tsx | 13 ++++++++++--- .../widget-dashboard/src/stories/widget-chrome.md | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/widget-dashboard/CHANGELOG.md b/packages/widget-dashboard/CHANGELOG.md index e207823f7413d5..2b6252094fc899 100644 --- a/packages/widget-dashboard/CHANGELOG.md +++ b/packages/widget-dashboard/CHANGELOG.md @@ -5,9 +5,10 @@ ### New Features - Widget chrome footer: `relevance: 'high'` actions mount as leading text - links in a persistent strip under the widget body, `'medium'` as trailing - compact affordances (icon-only with a declared icon); the "More" menu - keeps the rest, and full-bleed widgets keep every action in the menu + links (declared icon as prefix) in a persistent strip under the widget + body, `'medium'` as trailing compact affordances (icon-only with a + declared icon); the "More" menu keeps the rest, and full-bleed widgets + keep every action in the menu ([#81556](https://github.com/WordPress/gutenberg/pull/81556)). ## 0.5.0 (2026-08-12) diff --git a/packages/widget-dashboard/README.md b/packages/widget-dashboard/README.md index 39c1e74142fca8..12d456dc800944 100644 --- a/packages/widget-dashboard/README.md +++ b/packages/widget-dashboard/README.md @@ -236,7 +236,7 @@ Edits on any surface stage through the engine's internal layer and reach `onLayo Actions carry the same `relevance` scale, mapped to surfaces of decreasing prominence: -- **Footer, leading**: `relevance: 'high'` actions render as text links in a persistent strip under the widget body. +- **Footer, leading**: `relevance: 'high'` actions render as text links in a persistent strip under the widget body, a declared icon riding as prefix. - **Footer, trailing**: `relevance: 'medium'` actions render as compact affordances: icon-only links when the action declares an icon, text links otherwise. - **More menu**: the rest collapse into the three-dots menu in the tile header. diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css index 6e134a1a6dca8e..0d66b3eec5e78b 100644 --- a/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.module.css @@ -14,6 +14,13 @@ margin-inline-start: auto; } +/* High action with a declared icon: the icon rides as a prefix. */ +.prefixed-action { + display: inline-flex; + align-items: center; + gap: var(--wpds-dimension-gap-xs); +} + /* * Square the icon-only link via the Button override hooks for icon * buttons; breathing room comes from the size, not from padding. diff --git a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx index cc5741382cae2d..60815c05ae90fe 100644 --- a/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx +++ b/packages/widget-dashboard/src/components/widget-footer/widget-footer.tsx @@ -1,6 +1,6 @@ import { __, sprintf } from '@wordpress/i18n'; // eslint-disable-next-line @wordpress/use-recommended-components -import { Link, LinkButton, Stack, Tooltip } from '@wordpress/ui'; +import { Icon, Link, LinkButton, Stack, Tooltip } from '@wordpress/ui'; import type { WidgetAction, WidgetIcon } from '@wordpress/widget-primitives'; import styles from './widget-footer.module.css'; @@ -70,8 +70,9 @@ type WidgetFooterProps = { /** * Persistent strip under the widget body. `'high'` actions mount as leading - * text links; `'medium'` actions as trailing compact affordances, icon-only - * when they declare an icon. Every affordance is a real anchor. + * text links, a declared icon riding as prefix; `'medium'` actions as + * trailing compact affordances, icon-only when they declare an icon. Every + * affordance is a real anchor. * * @param {WidgetFooterProps} props Component props. */ @@ -106,7 +107,13 @@ export function WidgetFooter( { href={ action.href } download={ action.download } openInNewTab={ action.openInNewTab } + className={ + action.icon + ? styles[ 'prefixed-action' ] + : undefined + } > + { action.icon && } { action.label } ) ) } diff --git a/packages/widget-dashboard/src/stories/widget-chrome.md b/packages/widget-dashboard/src/stories/widget-chrome.md index e7ce69fa7552e2..007399c10dfb58 100644 --- a/packages/widget-dashboard/src/stories/widget-chrome.md +++ b/packages/widget-dashboard/src/stories/widget-chrome.md @@ -63,7 +63,7 @@ A persistent strip under the body, for the actions the widget promotes. `relevance` routes every action to its surface. -- **`high`.** Text links on the leading edge, labels always visible. +- **`high`.** Text links on the leading edge, labels always visible, a declared icon as prefix. - **`medium`.** Compact affordances on the trailing edge: icon-only with a declared icon, text links otherwise. - **`low`** (default). The header's More menu. From 6814811d8d245f0fb01f56b6454b330284900411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 21:56:23 +0900 Subject: [PATCH 15/17] declare review items action in site health --- widgets/site-health/render.tsx | 14 ++------------ widgets/site-health/widget.json | 7 +++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/widgets/site-health/render.tsx b/widgets/site-health/render.tsx index f2c3b766c70eba..64de536e3769f1 100644 --- a/widgets/site-health/render.tsx +++ b/widgets/site-health/render.tsx @@ -1,8 +1,8 @@ import { useState, useEffect } from '@wordpress/element'; -import { __, _n, sprintf } from '@wordpress/i18n'; +import { __ } from '@wordpress/i18n'; import apiFetch from '@wordpress/api-fetch'; import { Spinner } from '@wordpress/components'; -import { Link, Stack, Text } from '@wordpress/ui'; +import { Stack, Text } from '@wordpress/ui'; import { CircleProgress, type HealthTone } from './components'; import styles from './style.module.css'; @@ -136,7 +136,6 @@ export default function SiteHealth() { const total = counts.good + counts.recommended + counts.critical; const percentage = total > 0 ? Math.round( ( counts.good / total ) * 100 ) : 0; - const issuesTotal = counts.recommended + counts.critical; const tone = toneForPercentage( percentage ); return ( @@ -149,15 +148,6 @@ export default function SiteHealth() { > { statusMessage( counts ) } - { issuesTotal > 0 && ( - - { sprintf( - /* translators: %d: Number of issues to address. */ - _n( 'Review %d item', 'Review %d items', issuesTotal ), - issuesTotal - ) } - - ) }
); } diff --git a/widgets/site-health/widget.json b/widgets/site-health/widget.json index 7c26af92ddd295..b4631440663d2b 100644 --- a/widgets/site-health/widget.json +++ b/widgets/site-health/widget.json @@ -11,6 +11,13 @@ "presentation": "framed", "textdomain": "default", "actions": [ + { + "id": "review-items", + "label": "Review items", + "icon": "core/format-list-bullets", + "relevance": "high", + "href": "site-health.php" + }, { "id": "site-health-status", "label": "Status", From 089a763ba54f3db3ab6dd70b99dcef54562fd700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 22:03:13 +0900 Subject: [PATCH 16/17] Revert "declare review items action in site health" This reverts commit 6814811d8d245f0fb01f56b6454b330284900411. --- widgets/site-health/render.tsx | 14 ++++++++++++-- widgets/site-health/widget.json | 7 ------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/widgets/site-health/render.tsx b/widgets/site-health/render.tsx index 64de536e3769f1..f2c3b766c70eba 100644 --- a/widgets/site-health/render.tsx +++ b/widgets/site-health/render.tsx @@ -1,8 +1,8 @@ import { useState, useEffect } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; +import { __, _n, sprintf } from '@wordpress/i18n'; import apiFetch from '@wordpress/api-fetch'; import { Spinner } from '@wordpress/components'; -import { Stack, Text } from '@wordpress/ui'; +import { Link, Stack, Text } from '@wordpress/ui'; import { CircleProgress, type HealthTone } from './components'; import styles from './style.module.css'; @@ -136,6 +136,7 @@ export default function SiteHealth() { const total = counts.good + counts.recommended + counts.critical; const percentage = total > 0 ? Math.round( ( counts.good / total ) * 100 ) : 0; + const issuesTotal = counts.recommended + counts.critical; const tone = toneForPercentage( percentage ); return ( @@ -148,6 +149,15 @@ export default function SiteHealth() { > { statusMessage( counts ) } + { issuesTotal > 0 && ( + + { sprintf( + /* translators: %d: Number of issues to address. */ + _n( 'Review %d item', 'Review %d items', issuesTotal ), + issuesTotal + ) } + + ) }
); } diff --git a/widgets/site-health/widget.json b/widgets/site-health/widget.json index b4631440663d2b..7c26af92ddd295 100644 --- a/widgets/site-health/widget.json +++ b/widgets/site-health/widget.json @@ -11,13 +11,6 @@ "presentation": "framed", "textdomain": "default", "actions": [ - { - "id": "review-items", - "label": "Review items", - "icon": "core/format-list-bullets", - "relevance": "high", - "href": "site-health.php" - }, { "id": "site-health-status", "label": "Status", From eed64a0aff3a1317fa8d2d759cb6711490a00222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 13 Aug 2026 22:03:34 +0900 Subject: [PATCH 17/17] demo icon prefix on the story's high action --- packages/widget-dashboard/src/stories/index.story.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/widget-dashboard/src/stories/index.story.tsx b/packages/widget-dashboard/src/stories/index.story.tsx index 2b638d930a7085..f8d8fb843af4db 100644 --- a/packages/widget-dashboard/src/stories/index.story.tsx +++ b/packages/widget-dashboard/src/stories/index.story.tsx @@ -251,6 +251,7 @@ const GOAL_ACTIONS: WidgetAction[] = [ id: 'view-goal', label: 'View goal details', relevance: 'high', + icon: chartBar, href: 'https://wordpress.org/', openInNewTab: true, }, @@ -439,7 +440,7 @@ Their tiles compare the header presentations: The widget only declares relevance; the fit is measured by the chrome, so the same declaration adapts to any tile width. Resize the canvas to watch the headers switch presentations. -Beyond attributes, \`demo/goal-progress\` declares three \`actions\` spanning the relevance scale, and that scale routes them: "View goal details" at \`'high'\` mounts as a leading text link in a persistent chrome footer, "Export progress" at \`'medium'\` beside it as a trailing icon-only link, and "About goals" at the default \`'low'\` lands in the "More" menu. The widget declares each action as data plus its importance; the host owns the surfaces. +Beyond attributes, \`demo/goal-progress\` declares three \`actions\` spanning the relevance scale, and that scale routes them: "View goal details" at \`'high'\` mounts as a leading text link (declared icon as prefix) in a persistent chrome footer, "Export progress" at \`'medium'\` beside it as a trailing icon-only link, and "About goals" at the default \`'low'\` lands in the "More" menu. The widget declares each action as data plus its importance; the host owns the surfaces. Each type also carries a \`help\` note, opened from the info icon in the header, that describes its attributes and what they do. `,