From 84ef842d442e2cea10c214bff78f6830d8e4805f Mon Sep 17 00:00:00 2001 From: James Koster Date: Fri, 29 May 2026 13:43:28 +0100 Subject: [PATCH 1/7] Storybook: Enhance Theme Provider example with admin-ui Page. Use the full Page header demo and a bordered app shell so the example better reflects real admin UI theming. Co-authored-by: Cursor --- storybook/decorators/with-router.tsx | 27 ++ .../theme-example-application.story.tsx | 353 ++++++++---------- 2 files changed, 177 insertions(+), 203 deletions(-) create mode 100644 storybook/decorators/with-router.tsx diff --git a/storybook/decorators/with-router.tsx b/storybook/decorators/with-router.tsx new file mode 100644 index 00000000000000..2cccb9d8216478 --- /dev/null +++ b/storybook/decorators/with-router.tsx @@ -0,0 +1,27 @@ +import { privateApis as routePrivateApis } from '@wordpress/route'; +import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; + +const { unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( + 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', + '@wordpress/route' +); + +const { createMemoryHistory, createRootRoute, createRouter, RouterProvider } = + unlock( routePrivateApis ); + +/** + * Storybook decorator that provides a router context. + * + * Wraps stories in a minimal tanstack router (via @wordpress/route private + * APIs) so that components consuming `Link` from `@wordpress/route` can + * render without errors. + */ +export function withRouter( Story: React.ComponentType ) { + const rootRoute = createRootRoute( { component: Story } ); + const router = createRouter( { + routeTree: rootRoute, + history: createMemoryHistory( { initialEntries: [ '/' ] } ), + defaultNotFoundComponent: () => null, + } ); + return ; +} diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index cd90d2bd6b7eac..a9eb2cfb8849d5 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -1,5 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; +import { Breadcrumbs, Page } from '@wordpress/admin-ui'; import { useState } from '@wordpress/element'; +import { Icon, wordpress } from '@wordpress/icons'; import { privateApis as themeApis } from '@wordpress/theme'; import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; import { @@ -13,6 +15,8 @@ import { Text, } from '@wordpress/ui'; +import { withRouter } from '../../decorators/with-router'; + const { unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/theme' @@ -40,8 +44,8 @@ const meta: Meta< typeof ThemeProvider > = { export default meta; /** - * A mock application page demonstrating how `ThemeProvider` affects multiple - * `@wordpress/ui` components in concert. Use the inline controls to adjust + * A mock application page demonstrating how `ThemeProvider` affects + * `@wordpress/ui` and `@wordpress/admin-ui` components in concert. Use the inline controls to adjust * the `primary` and `bg` seed colors, and observe how every surface, text * element, and interactive control adapts accordingly. */ @@ -103,6 +107,9 @@ export const ExampleApplication: StoryObj< typeof ThemeProvider > = { gridTemplateColumns: '200px 1fr', minHeight: '500px', color: 'var(--wpds-color-fg-content-neutral)', + borderRadius: 'var(--wpds-border-radius-lg)', + border: 'var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak)', + overflow: 'hidden', } } > { /* Sidebar */ } @@ -146,219 +153,159 @@ export const ExampleApplication: StoryObj< typeof ThemeProvider > = { - { /* Page content (header + content area) */ } -
} + subTitle="All of the subtitle text you need goes here." + breadcrumbs={ + + } + badges={ + Status + } + actions={ + <> + + + } + showSidebarToggle={ false } + hasPadding > -
- { /* Header */ } -
-
- } - style={ { - margin: 0, - } } - > - Settings - - - Beta - -
- -
+ + + Welcome to your new site + + + Complete the steps below to finish + setting up. + + - { /* Content area */ } -
- - - - Welcome to your new site - - - Complete the steps below to - finish setting up. - - + { /* Card 1: General */ } + + + General + + + + + Configure the basic settings for + your site. You can update your{ ' ' } + site title + , tagline, and{ ' ' } + + admin email address + { ' ' } + at any time. + + + For more advanced options, visit + the{ ' ' } + + developer documentation + + . + + + + - { /* Card 1: General */ } - - - General - - - + + Display + + + + + + Appearance + + + Layout + + + Accessibility + + + + - - Configure the basic - settings for your site. - You can update your{ ' ' } - - site title - - , tagline, and{ ' ' } - - admin email address - { ' ' } - at any time. - - - For more advanced - options, visit the{ ' ' } - - developer - documentation - - . - - - - - - { /* Card 2: Display */ } - - - Display - - - - - - Appearance - - - Layout - - - Accessibility - - - - - Control how your - site looks to - visitors. Adjust{ ' ' } - - typography - - ,{ ' ' } - - colors - - , and spacing to - match your brand. - - - - - Choose a layout - structure for your - pages. Options - include full-width, - boxed, and{ ' ' } - - custom layouts - - . - - - - - Review your - site's{ ' ' } - - accessibility - settings - { ' ' } - to ensure it meets - WCAG guidelines. - - - - - - -
-
-
+ Control how your site looks + to visitors. Adjust{ ' ' } + + typography + + ,{ ' ' } + colors + , and spacing to match your + brand. + + + + + Choose a layout structure + for your pages. Options + include full-width, boxed, + and{ ' ' } + + custom layouts + + . + + + + + Review your site's{ ' ' } + + accessibility settings + { ' ' } + to ensure it meets WCAG + guidelines. + + + + + + + ); }, + decorators: [ withRouter ], parameters: { controls: { disable: true }, }, From 40e4da688cd810d332384bac0b5b92f3ab44dcb3 Mon Sep 17 00:00:00 2001 From: James Koster Date: Mon, 1 Jun 2026 14:16:19 +0100 Subject: [PATCH 2/7] Storybook: Use Icon from @wordpress/ui in theme example. Prefer the design system Icon component over the legacy @wordpress/icons wrapper. Co-authored-by: Cursor --- .../stories/design-system/theme-example-application.story.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index a9eb2cfb8849d5..a5d3f340f617e1 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -1,13 +1,14 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; import { Breadcrumbs, Page } from '@wordpress/admin-ui'; import { useState } from '@wordpress/element'; -import { Icon, wordpress } from '@wordpress/icons'; +import { wordpress } from '@wordpress/icons'; import { privateApis as themeApis } from '@wordpress/theme'; import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; import { Badge, Button, Card, + Icon, Link, Notice, Stack, From 74eada2ec0afcd354cadf71a7228a298ee05e266 Mon Sep 17 00:00:00 2001 From: James Koster Date: Mon, 1 Jun 2026 14:22:17 +0100 Subject: [PATCH 3/7] Storybook: Add ariaLabel to theme example Page. Label the navigable region when the page uses breadcrumbs without a title. Co-authored-by: Cursor --- .../stories/design-system/theme-example-application.story.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index a5d3f340f617e1..13f6c97301bbfc 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -155,6 +155,7 @@ export const ExampleApplication: StoryObj< typeof ThemeProvider > = { } subTitle="All of the subtitle text you need goes here." breadcrumbs={ From deb02b19559ef81a3f1f2f4c6856401f8f9bfcf0 Mon Sep 17 00:00:00 2001 From: James Koster Date: Mon, 1 Jun 2026 16:07:36 +0100 Subject: [PATCH 4/7] Storybook: Wrap theme example tab panels in Stack. Use medium top padding for consistent spacing between tab labels and panel content. Co-authored-by: Cursor --- .../theme-example-application.story.tsx | 80 +++++++++++-------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index 13f6c97301bbfc..9314eb82b6286c 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -248,54 +248,70 @@ export const ExampleApplication: StoryObj< typeof ThemeProvider > = { - - Control how your site looks - to visitors. Adjust{ ' ' } - - typography - - ,{ ' ' } - colors - , and spacing to match your - brand. - + + Control how your site + looks to visitors. + Adjust{ ' ' } + + typography + + ,{ ' ' } + + colors + + , and spacing to match + your brand. + + - - Choose a layout structure - for your pages. Options - include full-width, boxed, - and{ ' ' } - - custom layouts - - . - + + Choose a layout + structure for your + pages. Options include + full-width, boxed, and{ ' ' } + + custom layouts + + . + + - - Review your site's{ ' ' } - - accessibility settings - { ' ' } - to ensure it meets WCAG - guidelines. - + + Review your site's{ ' ' } + + accessibility + settings + { ' ' } + to ensure it meets WCAG + guidelines. + + From 8e28fc06fca92a5cfcca3764f655ed6f451dbffc Mon Sep 17 00:00:00 2001 From: James Koster Date: Mon, 1 Jun 2026 16:08:48 +0100 Subject: [PATCH 5/7] Storybook: Add sidebar divider to theme example. Separate the sidebar from main content with a neutral stroke border. Co-authored-by: Cursor --- .../stories/design-system/theme-example-application.story.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storybook/stories/design-system/theme-example-application.story.tsx b/storybook/stories/design-system/theme-example-application.story.tsx index 9314eb82b6286c..fe45ef34672394 100644 --- a/storybook/stories/design-system/theme-example-application.story.tsx +++ b/storybook/stories/design-system/theme-example-application.story.tsx @@ -120,6 +120,8 @@ export const ExampleApplication: StoryObj< typeof ThemeProvider > = { 'var(--wpds-color-bg-surface-neutral-weak)', padding: 'var(--wpds-dimension-padding-xl) var(--wpds-dimension-padding-lg)', + borderInlineEnd: + 'var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak)', } } > Date: Wed, 3 Jun 2026 10:44:03 +0100 Subject: [PATCH 6/7] Update storybook/decorators/with-router.tsx Co-authored-by: Andrew Duthie <1779930+aduth@users.noreply.github.com> --- storybook/decorators/with-router.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storybook/decorators/with-router.tsx b/storybook/decorators/with-router.tsx index 2cccb9d8216478..0dbe7d98195e6d 100644 --- a/storybook/decorators/with-router.tsx +++ b/storybook/decorators/with-router.tsx @@ -3,7 +3,7 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri const { unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', - '@wordpress/route' + '@wordpress/storybook' ); const { createMemoryHistory, createRootRoute, createRouter, RouterProvider } = From 7bb944457f3cfb08138ee10da261eecd69d7f798 Mon Sep 17 00:00:00 2001 From: James Koster Date: Thu, 4 Jun 2026 15:36:47 +0100 Subject: [PATCH 7/7] Private APIs: Allow @wordpress/storybook to opt in to private APIs. Unblocks Storybook router decorators that unlock @wordpress/route APIs from the storybook package. Co-authored-by: Cursor --- packages/private-apis/CHANGELOG.md | 4 ++++ packages/private-apis/src/implementation.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/private-apis/CHANGELOG.md b/packages/private-apis/CHANGELOG.md index 04175037d8aa17..8acbb0bb6e4a3f 100644 --- a/packages/private-apis/CHANGELOG.md +++ b/packages/private-apis/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Enhancements + +- Allow `@wordpress/storybook` to opt in to private APIs. ([#78814](https://github.com/WordPress/gutenberg/pull/78814)) + ## 1.47.0 (2026-05-27) ## 1.46.0 (2026-05-14) diff --git a/packages/private-apis/src/implementation.ts b/packages/private-apis/src/implementation.ts index 28e6aef9471051..b744a4bd984847 100644 --- a/packages/private-apis/src/implementation.ts +++ b/packages/private-apis/src/implementation.ts @@ -40,6 +40,7 @@ const CORE_MODULES_USING_PRIVATE_APIS = [ '@wordpress/route', '@wordpress/router', '@wordpress/routes', + '@wordpress/storybook', '@wordpress/sync', '@wordpress/theme', '@wordpress/dataviews',