From e21dd5edc4351c708e83656ec17eb9d75ebdd274 Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Mon, 30 Mar 2026 11:49:34 +0100 Subject: [PATCH] fix(storybook): register appThemeApiRef in Storybook API providers Add AppThemeSelector as an implementation for appThemeApiRef in the shared Storybook API registry. Without this, any story that renders a ToastContainer fails with NotImplementedError for core.apptheme. Signed-off-by: Charles de Dreuille Made-with: Cursor --- .storybook/support/apis.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.storybook/support/apis.js b/.storybook/support/apis.js index 905c5f2dc8..38bb2817e2 100644 --- a/.storybook/support/apis.js +++ b/.storybook/support/apis.js @@ -1,5 +1,6 @@ import { AlertApiForwarder, + AppThemeSelector, ErrorAlerter, ErrorApiForwarder, GithubAuth, @@ -13,6 +14,7 @@ import { import { alertApiRef, + appThemeApiRef, errorApiRef, githubAuthApiRef, gitlabAuthApiRef, @@ -24,10 +26,16 @@ import { featureFlagsApiRef, } from '@backstage/core-plugin-api'; +import { themes } from '@backstage/theme'; + import { translationApiRef } from '@backstage/core-plugin-api/alpha'; import { MockTranslationApi } from '@backstage/test-utils/alpha'; const configApi = new ConfigReader({}); +const appThemeApi = AppThemeSelector.createWithStorage([ + { id: 'light', title: 'Light', variant: 'light', theme: themes.light }, + { id: 'dark', title: 'Dark', variant: 'dark', theme: themes.dark }, +]); const featureFlagsApi = new LocalStorageFeatureFlags(); const alertApi = new AlertApiForwarder(); const errorApi = new ErrorAlerter(alertApi, new ErrorApiForwarder()); @@ -62,6 +70,7 @@ const translationApi = MockTranslationApi.create(); export const apis = [ [configApiRef, configApi], + [appThemeApiRef, appThemeApi], [featureFlagsApiRef, featureFlagsApi], [alertApiRef, alertApi], [errorApiRef, errorApi],