The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Add the "Theme preset" selection in Embed JS Wizard when no feature token is available (#66495)
Timofey Kachalov25fc5ea0c26a
diff --git a/e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-guest-embeds-helpers.tsx b/e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-guest-embeds-helpers.tsxindex 6c1bd393e69..3ddf6ad435c 100644--- a/e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-guest-embeds-helpers.tsx+++ b/e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-guest-embeds-helpers.tsx@@ -1,14 +1,23 @@-import { StaticDashboard, StaticQuestion } from "@metabase/embedding-sdk-react";+import {+ type MetabaseProviderProps,+ StaticDashboard,+ StaticQuestion,+} from "@metabase/embedding-sdk-react";import type { ComponentProps } from "react";+import type { DeepPartial } from "metabase/embedding-sdk/types/utils";+import { mountSdkContent } from "./component-embedding-sdk-helpers";export function mountGuestEmbedQuestion(extraProps: Partial<ComponentProps<typeof StaticQuestion>> = {},{shouldAssertCardQuery,- locale,- }: { shouldAssertCardQuery?: boolean; locale?: string } = {+ sdkProviderProps,+ }: {+ shouldAssertCardQuery?: boolean;+ sdkProviderProps?: DeepPartial<MetabaseProviderProps>;+ } = {shouldAssertCardQuery: true,},) {@@ -17,7 +26,7 @@ export function mountGuestEmbedQuestion(cy.intercept("GET", "/api/embed/pivot/card/*/query*").as("getCardPivotQuery");mountSdkContent(<StaticQuestion {...extraProps} />, {- sdkProviderProps: { authConfig: { isGuest: true }, locale },+ sdkProviderProps: { authConfig: { isGuest: true }, ...sdkProviderProps },});if (shouldAssertCardQuery) {diff --git a/e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers.ts b/e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers.tsindex 5682c4eaa52..89620232e06 100644--- a/e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers.ts+++ b/e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers.ts@@ -81,7 +81,7 @@ export function signInAsAdminAndEnableEmbeddingSdk() {export function signInAsAdminAndSetupGuestEmbedding({token,}: {- token: "starter" | "pro-cloud";+ token: "starter" | "pro-cloud" | "bleeding-edge";}) {Cypress.config("baseUrl", METABASE_INSTANCE_URL);diff --git a/e2e/test-component/scenarios/embedding-sdk/guest-embed-content-translations.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/guest-embed-content-translations.cy.spec.tsxindex df578038347..4ab17721b75 100644--- a/e2e/test-component/scenarios/embedding-sdk/guest-embed-content-translations.cy.spec.tsx+++ b/e2e/test-component/scenarios/embedding-sdk/guest-embed-content-translations.cy.spec.tsx@@ -63,7 +63,9 @@ describe("scenarios > embedding-sdk > guest-embed-content-translations", () => {mountGuestEmbedQuestion({ token, title: true },{- locale: "de",+ sdkProviderProps: {+ locale: "de",+ },},);diff --git a/e2e/test-component/scenarios/embedding-sdk/guest-embed-happy-path.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/guest-embed-happy-path.cy.spec.tsxindex 28f8125f6e8..051d882b477 100644--- a/e2e/test-component/scenarios/embedding-sdk/guest-embed-happy-path.cy.spec.tsx+++ b/e2e/test-component/scenarios/embedding-sdk/guest-embed-happy-path.cy.spec.tsx@@ -15,7 +15,7 @@ import {} from "e2e/support/helpers/embedding-sdk-component-testing";import { signInAsAdminAndSetupGuestEmbedding } from "e2e/support/helpers/embedding-sdk-testing";import { questionAsPinMapWithTiles } from "e2e/test/scenarios/embedding/shared/embedding-questions";-import type { Card } from "metabase-types/api";+import type { Card, TemplateTags } from "metabase-types/api";import { createMockParameter } from "metabase-types/api/mocks";const { ORDERS, ORDERS_ID, PEOPLE_ID } = SAMPLE_DATABASE;@@ -49,7 +49,7 @@ const PARAMETERS = [},}),];-const TEMPLATE_TAGS = {+const TEMPLATE_TAGS: TemplateTags = {quantity: {id: "quantity",name: "quantity",diff --git a/e2e/test-component/scenarios/embedding-sdk/guest-embed-theming.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/guest-embed-theming.cy.spec.tsxnew file mode 100644index 00000000000..2dfe68cfe8b--- /dev/null+++ b/e2e/test-component/scenarios/embedding-sdk/guest-embed-theming.cy.spec.tsx@@ -0,0 +1,83 @@+import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";+import {+ type StructuredQuestionDetails,+ createQuestion,+ getSignedJwtForResource,+} from "e2e/support/helpers";+import { getSdkRoot } from "e2e/support/helpers/e2e-embedding-sdk-helpers";+import { mountGuestEmbedQuestion } from "e2e/support/helpers/embedding-sdk-component-testing";+import { signInAsAdminAndSetupGuestEmbedding } from "e2e/support/helpers/embedding-sdk-testing";+import type { Card } from "metabase-types/api";++const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;++const QUESTION: StructuredQuestionDetails = {+ name: "Question for Guest Embed SDK",+ enable_embedding: true,+ embedding_type: "guest-embed",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["max", ["field", ORDERS.QUANTITY, null]]],+ breakout: [["field", ORDERS.PRODUCT_ID, null]],+ limit: 2,+ },+};++describe("scenarios > embedding-sdk > guest-embed-theming", () => {+ const setup = ({ display }: { display?: Card["display"] } = {}) => {+ signInAsAdminAndSetupGuestEmbedding({+ token: "starter",+ });++ createQuestion({+ ...QUESTION,+ display,+ }).then(({ body: question }) => {+ cy.wrap(question.id).as("questionId");+ });++ cy.signOut();+ };++ describe("theming", () => {+ it("should apply a theme preset", () => {+ setup();++ cy.get("@questionId").then(async (questionId) => {+ const token = await getSignedJwtForResource({+ resourceId: questionId as unknown as number,+ resourceType: "question",+ });++ mountGuestEmbedQuestion(+ { token, title: true },+ {+ sdkProviderProps: {+ theme: {+ preset: "dark",+ colors: {+ // Override text+ "text-primary": "red",+ },+ },+ },+ },+ );++ getSdkRoot().within(() => {+ cy.findByTestId("table-root").should(+ "have.css",+ "background-color",+ "rgb(7, 23, 34)",+ );++ cy.findByText("Question for Guest Embed SDK").should(+ "have.css",+ "color",+ "rgba(255, 255, 255, 0.95)",+ );+ });+ });+ });+ });+});diff --git a/e2e/test-component/scenarios/embedding-sdk/sdk-question-theming.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/sdk-question-theming.cy.spec.tsxindex 9140a029e43..788e67b3428 100644--- a/e2e/test-component/scenarios/embedding-sdk/sdk-question-theming.cy.spec.tsx+++ b/e2e/test-component/scenarios/embedding-sdk/sdk-question-theming.cy.spec.tsx@@ -14,6 +14,8 @@ import { Box } from "metabase/ui";const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;+const QUESTION_NAME = "47563";+const darken = (color: string | undefined, amount: number) =>Color(color).darken(amount).rgb().toString();@@ -29,7 +31,7 @@ describe(signInAsAdminAndEnableEmbeddingSdk();createQuestion({- name: "47563",+ name: QUESTION_NAME,query: {"source-table": ORDERS_ID,aggregation: [["max", ["field", ORDERS.QUANTITY, null]]],@@ -89,6 +91,29 @@ describe(});});+ it("applies a theme preset and overrides it with a theme", () => {+ setupInteractiveQuestionWithTheme({+ preset: "dark",+ colors: {+ "text-primary": "red",+ },+ });++ getSdkRoot().within(() => {+ cy.findByTestId("table-root").should(+ "have.css",+ "background-color",+ "rgb(7, 23, 34)",+ );++ cy.findByText(QUESTION_NAME).should(+ "have.css",+ "color",+ "rgb(255, 0, 0)",+ );+ });+ });+it("derives dynamic css variables for light theme", () => {const BACKGROUND_COLOR = "rgb(255, 255, 255)";diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.tsindex 872ea9e5e41..15610dd1243 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.ts@@ -194,6 +194,10 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {cy.findByText("Foo Bar Baz").should("be.visible");});+ H.getSimpleEmbedIframeContent()+ .findByTestId("embedding-footer")+ .should("not.exist");+getEmbedSidebar().within(() => {cy.findByText("Get code").click();});@@ -244,6 +248,8 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {frame.within(() => {cy.findByText("Foo Bar Baz").should("be.visible");++ cy.findByTestId("embedding-footer").should("not.exist");});});});diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.tsindex 5da422c7506..ef40ebdf015 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.ts@@ -198,12 +198,26 @@ describe(.find("input").type("Foo Bar Baz");+ H.getSimpleEmbedIframeContent()+ .findByTestId("embedding-footer")+ .should("be.visible");++ H.getSimpleEmbedIframeContent()+ .findByTestId("question-download-widget-button")+ .should("have.css", "background-color", "rgb(255, 255, 255)");+getEmbedSidebar().within(() => {cy.findByTestId("appearance-section").within(() => {cy.findByTestId("upsell-gem").should("be.visible");++ cy.findByText("Dark").click();});});+ H.getSimpleEmbedIframeContent()+ .findByTestId("question-download-widget-button")+ .should("have.css", "background-color", "rgb(7, 23, 34)");+H.publishChanges("card");cy.button("Unpublish").should("be.visible");@@ -223,6 +237,10 @@ describe(// Get code stepgetEmbedSidebar().within(() => {+ codeBlock()+ .invoke("text")+ .should("match", /"theme":\s*\{\s*"preset":\s*"dark"\s*},/);+cy.findAllByText(/Copy code/).first().click();@@ -261,6 +279,8 @@ describe(frame.within(() => {cy.findByText("Foo Bar Baz").should("be.visible");++ cy.findByTestId("embedding-footer").should("be.visible");});});});diff --git a/enterprise/frontend/src/embedding-sdk-package/components/private/ComponentWrapper/ComponentWrapper.tsx b/enterprise/frontend/src/embedding-sdk-package/components/private/ComponentWrapper/ComponentWrapper.tsxindex 29aab070ff5..7f50e1d8622 100644--- a/enterprise/frontend/src/embedding-sdk-package/components/private/ComponentWrapper/ComponentWrapper.tsx+++ b/enterprise/frontend/src/embedding-sdk-package/components/private/ComponentWrapper/ComponentWrapper.tsx@@ -5,6 +5,7 @@ import {type PropsWithChildren,useEffect,useId,+ useMemo,useRef,} from "react";@@ -23,6 +24,7 @@ import {import { EnsureSingleInstance } from "embedding-sdk-shared/components/EnsureSingleInstance/EnsureSingleInstance";import { useMetabaseProviderPropsStore } from "embedding-sdk-shared/hooks/use-metabase-provider-props-store";import { useSdkLoadingState } from "embedding-sdk-shared/hooks/use-sdk-loading-state";+import { applyThemePreset } from "embedding-sdk-shared/lib/apply-theme-preset";import { ensureMetabaseProviderPropsStore } from "embedding-sdk-shared/lib/ensure-metabase-provider-props-store";import { getWindow } from "embedding-sdk-shared/lib/get-window";import {@@ -150,16 +152,21 @@ const ComponentWrapperInner = <TComponentProps,>({} = useMetabaseProviderPropsStore();const { isLoading, isError, isNotStartedLoading } = useSdkLoadingState();+ const { theme } = metabaseProviderProps ?? {};+ const adjustedTheme = useMemo(() => applyThemePreset(theme), [theme]);+if (isError) {- return <Error message={SDK_LOADING_ERROR_MESSAGE} />;+ return <Error theme={adjustedTheme} message={SDK_LOADING_ERROR_MESSAGE} />;}if (isNotStartedLoading) {- return <Error message={SDK_NOT_STARTED_LOADING_MESSAGE} />;+ return (+ <Error theme={adjustedTheme} message={SDK_NOT_STARTED_LOADING_MESSAGE} />+ );}if (isLoading || !metabaseProviderInternalProps.loadingState) {- return <Loader />;+ return <Loader theme={adjustedTheme} />;}const ComponentProvider = isLoading@@ -171,13 +178,18 @@ const ComponentWrapperInner = <TComponentProps,>({!metabaseProviderInternalProps.reduxStore ||!metabaseProviderProps) {- return <Error message={SDK_NOT_LOADED_YET_MESSAGE} />;+ return <Error theme={adjustedTheme} message={SDK_NOT_LOADED_YET_MESSAGE} />;}const Component = getComponent();if (!Component) {- return <Error message={SDK_COMPONENT_NOT_YET_AVAILABLE_MESSAGE} />;+ return (+ <Error+ theme={adjustedTheme}+ message={SDK_COMPONENT_NOT_YET_AVAILABLE_MESSAGE}+ />+ );}return (diff --git a/enterprise/frontend/src/embedding-sdk-package/components/private/Error/Error.tsx b/enterprise/frontend/src/embedding-sdk-package/components/private/Error/Error.tsxindex 414e3e0d5c3..c8a1b4b93d2 100644--- a/enterprise/frontend/src/embedding-sdk-package/components/private/Error/Error.tsx+++ b/enterprise/frontend/src/embedding-sdk-package/components/private/Error/Error.tsx@@ -1,29 +1,33 @@import { useMetabaseProviderPropsStore } from "embedding-sdk-shared/hooks/use-metabase-provider-props-store";+import type { MetabaseTheme } from "metabase/embedding-sdk/theme";// eslint-disable-next-line no-external-references-for-sdk-package-codeimport { colors } from "metabase/lib/colors/colors";type Props = {message: string;+ theme: MetabaseTheme | undefined;};// Mimics the frontend/src/metabase/common/components/Alert/Alert.styled.tsx-const DefaultErrorMessage = ({ message }: Props) => (- <div- style={{- display: "flex",- alignItems: "center",- padding: "1.25rem 1rem",- background: colors["bg-error"],- color: colors["text-dark"],- border: `1px solid ${colors.error}`,- borderRadius: "0.5rem",- textAlign: "center",- lineHeight: "1.4rem",- }}- >- {message}- </div>-);+const DefaultErrorMessage = ({ message, theme }: Props) => {+ return (+ <div+ style={{+ display: "flex",+ alignItems: "center",+ padding: "1.25rem 1rem",+ background: theme?.colors?.background ?? colors["bg-error"],+ color: theme?.colors?.["text-primary"] ?? colors["text-dark"],+ border: `1px solid ${theme?.colors?.error ?? colors.error}`,+ borderRadius: "0.5rem",+ textAlign: "center",+ lineHeight: "1.4rem",+ }}+ >+ {message}+ </div>+ );+};export const Error = ({ message }: Props) => {const {@@ -37,7 +41,10 @@ export const Error = ({ message }: Props) => {{ErrorComponent ? (<ErrorComponent message={message} />) : (- <DefaultErrorMessage message={message} />+ <DefaultErrorMessage+ message={message}+ theme={metabaseProviderProps?.theme}+ />)}</div>);diff --git a/enterprise/frontend/src/embedding-sdk-package/components/private/Loader/Loader.tsx b/enterprise/frontend/src/embedding-sdk-package/components/private/Loader/Loader.tsxindex d45163c934c..a7947ec17ff 100644--- a/enterprise/frontend/src/embedding-sdk-package/components/private/Loader/Loader.tsx+++ b/enterprise/frontend/src/embedding-sdk-package/components/private/Loader/Loader.tsx@@ -2,6 +2,7 @@import { getSdkLoaderCss } from "embedding/sdk-common/lib/get-sdk-loader-css";import type { CommonStylingProps } from "embedding-sdk-bundle/types/props";import { useMetabaseProviderPropsStore } from "embedding-sdk-shared/hooks/use-metabase-provider-props-store";+import type { MetabaseTheme } from "metabase/embedding-sdk/theme";type SpinnerProps = {size?: string;@@ -23,13 +24,16 @@ const Spinner = ({ size = "1.5rem", color = "#509EE3" }: SpinnerProps) => {);};-export const Loader = ({ className, style }: CommonStylingProps) => {+export const Loader = ({+ className,+ style,+ theme,+}: CommonStylingProps & { theme?: MetabaseTheme }) => {const {state: { props: metabaseProviderProps },} = useMetabaseProviderPropsStore();const LoaderComponent = metabaseProviderProps?.loaderComponent;- const theme = metabaseProviderProps?.theme;return (<divdiff --git a/enterprise/frontend/src/embedding-sdk-package/index.ts b/enterprise/frontend/src/embedding-sdk-package/index.tsindex 98f12903413..0152b786d66 100644--- a/enterprise/frontend/src/embedding-sdk-package/index.ts+++ b/enterprise/frontend/src/embedding-sdk-package/index.ts@@ -110,6 +110,7 @@ export type {MetabasePluginsConfig,MetabaseQuestion,MetabaseTheme,+ MetabaseThemePreset,MetabaseUser,SdkEntityToken,SdkCollectionId,diff --git a/frontend/src/embedding-sdk-bundle/components/private/SdkThemeProvider.tsx b/frontend/src/embedding-sdk-bundle/components/private/SdkThemeProvider.tsxindex f48b02bd1f1..f47fddb33a4 100644--- a/frontend/src/embedding-sdk-bundle/components/private/SdkThemeProvider.tsx+++ b/frontend/src/embedding-sdk-bundle/components/private/SdkThemeProvider.tsx@@ -6,6 +6,7 @@ import { DEFAULT_FONT } from "embedding-sdk-bundle/config";import { getEmbeddingThemeOverride } from "embedding-sdk-bundle/lib/theme";import type { MetabaseTheme } from "embedding-sdk-bundle/types/ui";import { EnsureSingleInstance } from "embedding-sdk-shared/components/EnsureSingleInstance/EnsureSingleInstance";+import { applyThemePreset } from "embedding-sdk-shared/lib/apply-theme-preset";import { useSetting } from "metabase/common/hooks";import { setGlobalEmbeddingColors } from "metabase/embedding-sdk/theme/embedding-color-palette";import { useSelector } from "metabase/lib/redux";@@ -24,11 +25,13 @@ export const SdkThemeProvider = ({ theme, children }: Props) => {const appColors = useSetting("application-colors");const themeOverride = useMemo(() => {+ const themeWithPreset = applyThemePreset(theme);+// !! Mutate the global colors object to apply the new colors.// This must be done before ThemeProvider calls getThemeOverrides.- setGlobalEmbeddingColors(theme?.colors, appColors ?? {});+ setGlobalEmbeddingColors(themeWithPreset?.colors, appColors ?? {});- return getEmbeddingThemeOverride(theme || {}, font);+ return getEmbeddingThemeOverride(themeWithPreset || {}, font);}, [appColors, theme, font]);const { withCssVariables, withGlobalClasses } =diff --git a/frontend/src/embedding-sdk-bundle/hooks/private/use-normalize-component-provider-props.ts b/frontend/src/embedding-sdk-bundle/hooks/private/use-normalize-component-provider-props.tsindex 99852639eee..dfc6ef3c4d9 100644--- a/frontend/src/embedding-sdk-bundle/hooks/private/use-normalize-component-provider-props.ts+++ b/frontend/src/embedding-sdk-bundle/hooks/private/use-normalize-component-provider-props.ts@@ -1,3 +1,5 @@+import _ from "underscore";+import type { ComponentProviderInternalProps } from "embedding-sdk-bundle/components/public/ComponentProvider";import { useSdkSelector } from "embedding-sdk-bundle/store";import { getHasTokenFeature } from "embedding-sdk-bundle/store/selectors";@@ -8,10 +10,14 @@ export const useNormalizeComponentProviderProps = (const hasTokenFeature = useSdkSelector(getHasTokenFeature);const normalizedProps = { ...props };- // For OSS usage we prevent defining a locale or themeif (!hasTokenFeature) {+ // We prevent defining a localedelete normalizedProps.locale;- delete normalizedProps.theme;++ // We allow only defining a theme preset+ if (normalizedProps.theme) {+ normalizedProps.theme = _.pick(normalizedProps.theme, "preset");+ }}return normalizedProps;diff --git a/frontend/src/embedding-sdk-bundle/hooks/private/use-normalize-component-provider-props.unit.spec.ts b/frontend/src/embedding-sdk-bundle/hooks/private/use-normalize-component-provider-props.unit.spec.tsnew file mode 100644index 00000000000..16c087376bd--- /dev/null+++ b/frontend/src/embedding-sdk-bundle/hooks/private/use-normalize-component-provider-props.unit.spec.ts@@ -0,0 +1,92 @@+import type { ComponentProviderInternalProps } from "embedding-sdk-bundle/components/public/ComponentProvider";+import { useSdkSelector } from "embedding-sdk-bundle/store";++import { useNormalizeComponentProviderProps } from "./use-normalize-component-provider-props";++jest.mock("embedding-sdk-bundle/store", () => ({+ useSdkSelector: jest.fn(),+}));++const mockUseSdkSelector = useSdkSelector as jest.Mock;++const BASE_PROPS = {+ authConfig: { uri: "http://localhost" },+} as unknown as ComponentProviderInternalProps;++const FULL_THEME = {+ preset: "light" as const,+ colors: { brand: "#ff0000" },+};++describe("useNormalizeComponentProviderProps", () => {+ describe("when embedding SDK feature is enabled", () => {+ beforeEach(() => {+ mockUseSdkSelector.mockReturnValue(true);+ });++ it("returns props unchanged", () => {+ const props = {+ ...BASE_PROPS,+ locale: "de",+ theme: FULL_THEME,+ allowConsoleLog: false,+ };++ expect(useNormalizeComponentProviderProps(props)).toEqual(props);+ });++ it.each([+ { locale: "fr" },+ { theme: { preset: "dark" as const } },+ { theme: { colors: { brand: "#00ff00" } } },+ { pluginsConfig: { mapQuestionClickActions: () => [] } },+ ])("preserves %p", (extraProps) => {+ const props = { ...BASE_PROPS, ...extraProps };++ expect(useNormalizeComponentProviderProps(props)).toEqual(props);+ });+ });++ describe("when embedding SDK feature is disabled (OSS)", () => {+ beforeEach(() => {+ mockUseSdkSelector.mockReturnValue(false);+ });++ it("removes locale from props", () => {+ const props = { ...BASE_PROPS, locale: "de" };++ const result = useNormalizeComponentProviderProps(props);++ expect(result.locale).toBeUndefined();+ expect(result.authConfig).toEqual(BASE_PROPS.authConfig);+ });++ it("keeps only preset when theme has preset", () => {+ const props = { ...BASE_PROPS, theme: FULL_THEME };++ const result = useNormalizeComponentProviderProps(props);++ expect(result.theme).toEqual({ preset: "light" });+ });++ it("strips all theme properties when no preset exists", () => {+ const themeWithoutPreset = { colors: { brand: "#ff0000" } };+ const props = { ...BASE_PROPS, theme: themeWithoutPreset };++ const result = useNormalizeComponentProviderProps(props);++ expect(result.theme).toEqual({});+ });++ it.each(["pluginsConfig", "eventHandlers", "allowConsoleLog"] as const)(+ "preserves %s prop",+ (propName) => {+ const props = { ...BASE_PROPS, [propName]: "test-value" };++ const result = useNormalizeComponentProviderProps(props);++ expect(result[propName]).toBe("test-value");+ },+ );+ });+});diff --git a/frontend/src/embedding-sdk-bundle/types/ui.ts b/frontend/src/embedding-sdk-bundle/types/ui.tsindex ace9ebf398c..ba3efe54ec0 100644--- a/frontend/src/embedding-sdk-bundle/types/ui.ts+++ b/frontend/src/embedding-sdk-bundle/types/ui.ts@@ -39,6 +39,7 @@ export type { ButtonProps } from "metabase/ui";export type {ChartColor,MetabaseTheme,+ MetabaseThemePreset,MetabaseColors,MetabaseComponentTheme,} from "metabase/embedding-sdk/theme";diff --git a/frontend/src/embedding-sdk-shared/.storybook/main.js b/frontend/src/embedding-sdk-shared/.storybook/main.jsindex cc2696bcb13..dfa0e4ba0fa 100644--- a/frontend/src/embedding-sdk-shared/.storybook/main.js+++ b/frontend/src/embedding-sdk-shared/.storybook/main.js@@ -30,6 +30,10 @@ module.exports = {rootRepoPath,"enterprise/frontend/src/embedding-sdk-ee/**/*.stories.tsx",),+ path.resolve(+ rootRepoPath,+ "enterprise/frontend/src/embedding-sdk-package/**/*.stories.tsx",+ ),],staticDirs: [path.resolve(rootRepoPath, "resources/frontend_client"),diff --git a/frontend/src/embedding-sdk-shared/lib/apply-theme-preset.ts b/frontend/src/embedding-sdk-shared/lib/apply-theme-preset.tsnew file mode 100644index 00000000000..36f97b14773--- /dev/null+++ b/frontend/src/embedding-sdk-shared/lib/apply-theme-preset.ts@@ -0,0 +1,57 @@+import type {+ MetabaseColors,+ MetabaseTheme,+ MetabaseThemePreset,+} from "metabase/embedding-sdk/theme";+import {+ type MappableSdkColor,+ SDK_TO_MAIN_APP_COLORS_MAPPING,+} from "metabase/embedding-sdk/theme/embedding-color-palette";+import { getColors, getDarkColors } from "metabase/lib/colors/colors";+import type { ColorName, ColorPalette } from "metabase/lib/colors/types";++const PRESET_SDK_COLORS: MappableSdkColor[] = [+ "background",+ "background-hover",+ "background-disabled",+ "background-secondary",+ "background-light",+ "text-primary",+ "text-secondary",+ "text-tertiary",+ "border",+ "brand-hover",+ "brand-hover-light",+];++const COLOR_GETTERS: Record<MetabaseThemePreset, () => ColorPalette> = {+ light: getColors,+ dark: getDarkColors,+};++const getPresetColors = (preset: MetabaseThemePreset): MetabaseColors => {+ const palette = COLOR_GETTERS[preset]();++ return Object.fromEntries(+ PRESET_SDK_COLORS.map((sdkColor) => {+ const mainAppColor = SDK_TO_MAIN_APP_COLORS_MAPPING[sdkColor][0];+ return [sdkColor, palette[mainAppColor as ColorName]];+ }),+ );+};++export const applyThemePreset = (+ theme: MetabaseTheme | undefined,+): MetabaseTheme | undefined => {+ if (!theme?.preset) {+ return theme;+ }++ return {+ ...theme,+ colors: {+ ...getPresetColors(theme.preset),+ ...theme.colors,+ },+ };+};diff --git a/frontend/src/embedding-sdk-shared/lib/apply-theme-preset.unit.spec.ts b/frontend/src/embedding-sdk-shared/lib/apply-theme-preset.unit.spec.tsnew file mode 100644index 00000000000..39e770ba775--- /dev/null+++ b/frontend/src/embedding-sdk-shared/lib/apply-theme-preset.unit.spec.ts@@ -0,0 +1,69 @@+import { applyThemePreset } from "./apply-theme-preset";++const PRESET_COLOR_KEYS = [+ "background",+ "background-hover",+ "background-disabled",+ "background-secondary",+ "background-light",+ "text-primary",+ "text-secondary",+ "text-tertiary",+ "border",+ "brand-hover",+ "brand-hover-light",+] as const;++describe("applyThemePreset", () => {+ describe.each(["light", "dark"] as const)("%s preset", (preset) => {+ it("applies preset colors as base", () => {+ const result = applyThemePreset({ preset });++ PRESET_COLOR_KEYS.forEach((key) => {+ expect(result?.colors?.[key]).toBeDefined();+ });+ });++ it("allows user colors to override preset colors", () => {+ const theme = {+ preset,+ colors: {+ background: "#custom-bg",+ brand: "#custom-brand",+ },+ };++ const result = applyThemePreset(theme);++ expect(result?.colors?.background).toBe("#custom-bg");+ expect(result?.colors?.brand).toBe("#custom-brand");+ expect(result?.colors?.["text-primary"]).toBeDefined();+ });++ it("preserves other theme properties", () => {+ const theme = {+ preset,+ fontSize: "18px",+ fontFamily: "Custom Font",+ };++ const result = applyThemePreset(theme);++ expect(result?.fontSize).toBe("18px");+ expect(result?.fontFamily).toBe("Custom Font");+ expect(result?.preset).toBe(preset);+ });+ });++ describe("no preset", () => {+ it("returns undefined for undefined theme", () => {+ expect(applyThemePreset(undefined)).toBeUndefined();+ });++ it("returns theme unchanged when no preset specified", () => {+ const theme = { colors: { brand: "#000" } };++ expect(applyThemePreset(theme)).toEqual(theme);+ });+ });+});diff --git a/frontend/src/metabase/embedding-sdk/theme/MetabaseTheme.ts b/frontend/src/metabase/embedding-sdk/theme/MetabaseTheme.tsindex 3dee7383c53..852a5f6f89e 100644--- a/frontend/src/metabase/embedding-sdk/theme/MetabaseTheme.ts+++ b/frontend/src/metabase/embedding-sdk/theme/MetabaseTheme.ts@@ -6,10 +6,17 @@ import type { DeepPartial } from "../types/utils";import type { MetabaseFontFamily } from "./fonts";+export type MetabaseThemePreset = "light" | "dark";+/*** Theme configuration for embedded Metabase components.*/export interface MetabaseTheme {+ /**+ * Predefined theme preset to use as a base.+ */+ preset?: MetabaseThemePreset;+/*** Base font size.* Supported units are px, em and rem.diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.tsindex df111a3d015..7b3ed101b8a 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.ts@@ -93,6 +93,7 @@ export const trackEmbedWizardOptionsCompleted = ({experience,resource,settings,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,embeddingParameters,}: {@@ -100,6 +101,7 @@ export const trackEmbedWizardOptionsCompleted = ({experience: SdkIframeEmbedSetupExperience;resource: Dashboard | Card | null;settings: Partial<SdkIframeEmbedSetupSettings>;+ isSimpleEmbedFeatureAvailable: boolean;isGuestEmbedsEnabled: boolean;embeddingParameters: EmbeddingParameters;}) => {@@ -108,6 +110,7 @@ export const trackEmbedWizardOptionsCompleted = ({initialState,experience,resourceId: 0,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,});diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/BaseAppearanceSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/BaseAppearanceSection.tsxnew file mode 100644index 00000000000..fd3936afa81--- /dev/null+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/BaseAppearanceSection.tsx@@ -0,0 +1,31 @@+import type { PropsWithChildren, ReactNode } from "react";+import { t } from "ttag";++import { Flex, Group, Text } from "metabase/ui";++type Props = {+ icons?: ReactNode;+};++export const BaseAppearanceSection = ({+ children,+ icons,+}: PropsWithChildren<Props>) => {+ return (+ <Flex direction="column" data-testid="appearance-section">+ <Group justify="space-between" align="center" mb="lg">+ <Text size="lg" fw="bold">+ {t`Appearance`}+ </Text>++ <Flex gap="md" align="center">+ {icons}+ </Flex>+ </Group>++ <Group align="start" gap="xl">+ {children}+ </Group>+ </Flex>+ );+};diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/ColorCustomizationSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/ColorCustomizationSection.tsxnew file mode 100644index 00000000000..f765e4ae692--- /dev/null+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/ColorCustomizationSection.tsx@@ -0,0 +1,93 @@+import { useCallback, useState } from "react";+import { t } from "ttag";++import { ColorPillPicker } from "metabase/common/components/ColorPicker";+import { useSetting } from "metabase/common/hooks";+import type { MetabaseColors } from "metabase/embedding-sdk/theme";+import { originalColors, staticVizOverrides } from "metabase/lib/colors";+import { ActionIcon, Icon, Stack, Text, Tooltip } from "metabase/ui";++import { getConfigurableThemeColors } from "../../utils/theme-colors";++import { BaseAppearanceSection } from "./BaseAppearanceSection";++const defaultMetabaseColorsWithoutAlpha = {+ ...originalColors,+ ...staticVizOverrides,+};++interface ColorCustomizationSectionProps {+ theme?: { colors?: Partial<MetabaseColors> };+ onColorChange: (colors: Partial<MetabaseColors>) => void;+ onColorReset?: () => void;+}++export const ColorCustomizationSection = ({+ theme,+ onColorChange,+ onColorReset,+}: ColorCustomizationSectionProps) => {+ const applicationColors = useSetting("application-colors");++ // Undebounced color values to keep color selection fast.+ const [colorPreviewValues, setColorPreviewValues] = useState<+ Record<string, string>+ >({});++ const resetColors = useCallback(() => {+ setColorPreviewValues({});+ onColorReset?.();+ }, [onColorReset]);++ // If some of the colors are set, then `theme.colors` would be no longer empty.+ // This also matches when the `theme` key is shown in the code snippets.+ const hasColorChanged = !!theme?.colors;++ return (+ <BaseAppearanceSection+ icons={+ <>+ {hasColorChanged && (+ <Tooltip label={t`Reset colors`}>+ <ActionIcon+ variant="subtle"+ size="sm"+ onClick={resetColors}+ aria-label={t`Reset colors`}+ >+ <Icon name="revert" c="brand" />+ </ActionIcon>+ </Tooltip>+ )}+ </>+ }+ >+ {getConfigurableThemeColors().map(({ key, name, originalColorKey }) => {+ // Use the default from appearance settings. If not set, use the default Metabase color.+ const originalColor =+ applicationColors?.[originalColorKey] ??+ defaultMetabaseColorsWithoutAlpha[originalColorKey];++ const previewValue = colorPreviewValues[key] ?? theme?.colors?.[key];++ return (+ <Stack gap="xs" align="start" key={key}>+ <Text size="sm" fw="bold">+ {name}+ </Text>++ <ColorPillPicker+ onChange={(color) => onColorChange({ [key]: color })}+ originalColor={originalColor}+ previewValue={previewValue}+ onPreviewChange={(color: string) =>+ setColorPreviewValues((prev) => ({ ...prev, [key]: color }))+ }+ data-testid={`${key}-color-picker`}+ />+ </Stack>+ );+ })}+ </BaseAppearanceSection>+ );+};diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/SimpleThemeSwitcherSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/SimpleThemeSwitcherSection.tsxnew file mode 100644index 00000000000..b03726222d8--- /dev/null+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/SimpleThemeSwitcherSection.tsx@@ -0,0 +1,33 @@+import type { ReactNode } from "react";+import { t } from "ttag";++import type { MetabaseThemePreset } from "metabase/embedding-sdk/theme";+import { Radio, Stack } from "metabase/ui";++import { BaseAppearanceSection } from "./BaseAppearanceSection";++type Props = {+ preset: MetabaseThemePreset | undefined;+ upsellIcon: ReactNode;+ onPresetChange: (themePreset: MetabaseThemePreset) => void;+};++export const SimpleThemeSwitcherSection = ({+ preset,+ upsellIcon,+ onPresetChange,+}: Props) => {+ return (+ <BaseAppearanceSection icons={upsellIcon}>+ <Radio.Group+ value={preset}+ onChange={(value) => onPresetChange(value as MetabaseThemePreset)}+ >+ <Stack gap="sm">+ <Radio value="light" label={t`Light`} />+ <Radio value="dark" label={t`Dark`} />+ </Stack>+ </Radio.Group>+ </BaseAppearanceSection>+ );+};diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/ColorCustomizationSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/ColorCustomizationSection.tsxdeleted file mode 100644index a5f917d6c36..00000000000--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/ColorCustomizationSection.tsx+++ /dev/null@@ -1,123 +0,0 @@-import cx from "classnames";-import { type ReactNode, useCallback, useState } from "react";-import { t } from "ttag";--import { ColorPillPicker } from "metabase/common/components/ColorPicker";-import { useSetting } from "metabase/common/hooks";-import CS from "metabase/css/core/index.css";-import type { MetabaseColors } from "metabase/embedding-sdk/theme";-import { originalColors, staticVizOverrides } from "metabase/lib/colors";-import {- ActionIcon,- Flex,- Group,- Icon,- Stack,- Text,- Tooltip,-} from "metabase/ui";--import { getConfigurableThemeColors } from "../utils/theme-colors";--const defaultMetabaseColorsWithoutAlpha = {- ...originalColors,- ...staticVizOverrides,-};--interface ColorCustomizationSectionProps {- theme?: { colors?: Partial<MetabaseColors> };- disabled: boolean;- hoverCard: ReactNode;- onColorChange: (colors: Partial<MetabaseColors>) => void;- onColorReset?: () => void;-}--export const ColorCustomizationSection = ({- theme,- disabled,- hoverCard,- onColorChange,- onColorReset,-}: ColorCustomizationSectionProps) => {- const applicationColors = useSetting("application-colors");-- // Undebounced color values to keep color selection fast.- const [colorPreviewValues, setColorPreviewValues] = useState<- Record<string, string>- >({});-- const resetColors = useCallback(() => {- setColorPreviewValues({});- onColorReset?.();- }, [onColorReset]);-- // If some of the colors are set, then `theme.colors` would be no longer empty.- // This also matches when the `theme` key is shown in the code snippets.- const hasColorChanged = !!theme?.colors;-- return (- <>- <Group- justify="space-between"- align="center"- mb="lg"- data-testid="appearance-section"- >- <Text size="lg" fw="bold">- {t`Appearance`}- </Text>-- <Flex gap="md" align="center">- {hasColorChanged && (- <Tooltip label={t`Reset colors`}>- <ActionIcon- variant="subtle"- size="sm"- onClick={resetColors}- aria-label={t`Reset colors`}- >- <Icon name="revert" c="brand" />- </ActionIcon>- </Tooltip>- )}-- {hoverCard}- </Flex>- </Group>-- <Group- align="start"- gap="xl"- opacity={!disabled ? 1 : 0.5}- className={cx(disabled && CS.pointerEventsNone)}- >- {getConfigurableThemeColors().map(({ key, name, originalColorKey }) => {- // Use the default from appearance settings. If not set, use the default Metabase color.- const originalColor =- applicationColors?.[originalColorKey] ??- defaultMetabaseColorsWithoutAlpha[originalColorKey];-- const previewValue = colorPreviewValues[key] ?? theme?.colors?.[key];-- return (- <Stack gap="xs" align="start" key={key}>- <Text size="sm" fw="bold">- {name}- </Text>-- <ColorPillPicker- onChange={(color) => onColorChange({ [key]: color })}- originalColor={originalColor}- previewValue={previewValue}- onPreviewChange={(color: string) =>- setColorPreviewValues((prev) => ({ ...prev, [key]: color }))- }- data-testid={`${key}-color-picker`}- />- </Stack>- );- })}- </Group>- </>- );-};diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedPreview.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedPreview.tsxindex b6d0828bc9d..c9230d0f5cf 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedPreview.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedPreview.tsx@@ -8,6 +8,7 @@ import {} from "react";import { match } from "ts-pattern";+import { applyThemePreset } from "embedding-sdk-shared/lib/apply-theme-preset";import { useSetting } from "metabase/common/hooks";import { METABASE_CONFIG_IS_PROXY_FIELD_NAME } from "metabase/embedding/embedding-iframe-sdk/constants";// we import the equivalent of embed.js so that we don't add extra loading time@@ -35,8 +36,12 @@ declare global {}const SdkIframeEmbedPreviewInner = () => {- const { experience, settings, guestEmbedSignedTokenForPreview } =- useSdkIframeEmbedSetupContext();+ const {+ isSimpleEmbedFeatureAvailable,+ experience,+ settings,+ guestEmbedSignedTokenForPreview,+ } = useSdkIframeEmbedSetupContext();const [isLoading, setIsLoading] = useState(true);const instanceUrl = useSetting("site-url");@@ -60,7 +65,11 @@ const SdkIframeEmbedPreviewInner = () => {}}, []);- const derivedTheme = useMemo(() => {+ const theme = useMemo(() => {+ if (settings.theme?.preset) {+ return applyThemePreset(settings.theme);+ }+// TODO(EMB-696): There is a bug in the SDK where if we set the theme back to undefined,// some color will not be reset to the default (e.g. text color, CSS variables).// We can remove this block once EMB-696 is fixed.@@ -74,20 +83,23 @@ const SdkIframeEmbedPreviewInner = () => {),};- return getDerivedDefaultColorsForEmbedFlow(- settings.theme ?? defaultTheme,- applicationColors ?? undefined,- );- }, [applicationColors, settings.theme]);+ const derivedTheme = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme: settings.theme ?? defaultTheme,+ applicationColors: applicationColors ?? undefined,+ });++ return derivedTheme;+ }, [isSimpleEmbedFeatureAvailable, applicationColors, settings.theme]);const metabaseConfig = useMemo(() => ({instanceUrl,- theme: derivedTheme,+ theme,useExistingUserSession: true,isGuest: settings.isGuest,}),- [instanceUrl, derivedTheme, settings.isGuest],+ [instanceUrl, theme, settings.isGuest],);// initial configuration, needed so that the element finds the config on first render@@ -135,7 +147,7 @@ const SdkIframeEmbedPreviewInner = () => {<CardclassName={S.EmbedPreviewIframe}id="iframe-embed-container"- bg={settings.theme?.colors?.background}+ bg={theme?.colors?.background}h="100%"ref={containerRef}pos="relative"@@ -161,7 +173,7 @@ const SdkIframeEmbedPreviewInner = () => {<EmbedPreviewLoadingOverlayisVisible={isLoading}- bg={settings.theme?.colors?.background}+ bg={theme?.colors?.background}/></Card>);diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedExperienceStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedExperienceStep.tsxindex f7ddbba01d2..3a46c9e4e38 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedExperienceStep.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedExperienceStep.tsx@@ -59,6 +59,7 @@ export const SelectEmbedExperienceStep = () => {initialState,experience,resourceId: defaultResourceId,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,}),});diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsxindex 0c5cd362665..40526cc85f7 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx@@ -7,9 +7,13 @@ import {UPSELL_CAMPAIGN_AUTH,UPSELL_CAMPAIGN_BEHAVIOR,} from "metabase/embedding/embedding-iframe-sdk-setup/analytics";+import { SimpleThemeSwitcherSection } from "metabase/embedding/embedding-iframe-sdk-setup/components/Appearance/SimpleThemeSwitcherSection";import { getAuthTypeForSettings } from "metabase/embedding/embedding-iframe-sdk-setup/utils/get-auth-type-for-settings";import { isQuestionOrDashboardSettings } from "metabase/embedding/embedding-iframe-sdk-setup/utils/is-question-or-dashboard-settings";-import type { MetabaseColors } from "metabase/embedding-sdk/theme";+import type {+ MetabaseColors,+ MetabaseThemePreset,+} from "metabase/embedding-sdk/theme";import {Card,Checkbox,@@ -24,7 +28,7 @@ import {import { useSdkIframeEmbedSetupContext } from "../context";-import { ColorCustomizationSection } from "./ColorCustomizationSection";+import { ColorCustomizationSection } from "./Appearance/ColorCustomizationSection";import { LegacyStaticEmbeddingAlert } from "./LegacyStaticEmbeddingAlert";import { MetabotLayoutSetting } from "./MetabotLayoutSetting";import { ParameterSettings } from "./ParameterSettings";@@ -323,6 +327,13 @@ const AppearanceSection = () => {const { theme } = settings;+ const updateThemePreset = useCallback(+ (preset: MetabaseThemePreset) => {+ updateSettings({ theme: { preset } });+ },+ [updateSettings],+ );+const updateColors = useCallback((nextColors: Partial<MetabaseColors>) => {updateSettings({@@ -361,13 +372,21 @@ const AppearanceSection = () => {campaign={UPSELL_CAMPAIGN_BEHAVIOR}>{({ disabled, hoverCard }) => (- <ColorCustomizationSection- theme={theme}- disabled={disabled}- hoverCard={hoverCard}- onColorChange={updateColors}- onColorReset={() => updateSettings({ theme: undefined })}- />+ <>+ {disabled ? (+ <SimpleThemeSwitcherSection+ preset={theme?.preset}+ upsellIcon={hoverCard}+ onPresetChange={updateThemePreset}+ />+ ) : (+ <ColorCustomizationSection+ theme={theme}+ onColorChange={updateColors}+ onColorReset={() => updateSettings({ theme: undefined })}+ />+ )}+ </>)}</WithNotAvailableWithoutSimpleEmbeddingFeatureWarning>diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsxindex 7ae5f22f895..cf52bb9eba0 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsx@@ -45,7 +45,7 @@ export const WithSimpleEmbeddingFeatureUpsellTooltip = ({buttonText={t`Upgrade to Metabase Pro`}maxWidth={UPSELL_CARD_WIDTH}>- {t`Upgrade to get access to embeds with single sign-on, drill through, the SDK for React, and more.`}+ {t`Upgrade to get access to embeds with single sign-on, drill through, advanced theming, the SDK for React, and more.`}</UpsellCard>}disabled={disabled}diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.tsindex cc91ed51a60..09c48252c9b 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.ts@@ -11,6 +11,7 @@ import { useSdkIframeEmbedSetupContext } from "../context";export function useSdkIframeEmbedNavigation() {const {+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,initialState,experience,@@ -54,6 +55,7 @@ export function useSdkIframeEmbedNavigation() {experience,resource,settings,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,embeddingParameters,});diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-settings.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-settings.tsindex 4c04ccee6e7..3d3d0f495e5 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-settings.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-settings.ts@@ -97,6 +97,7 @@ export const useSdkIframeEmbedSettings = ({initialState,experience: "dashboard",resourceId: initialState.resourceId,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,}),)@@ -107,6 +108,7 @@ export const useSdkIframeEmbedSettings = ({initialState,experience: "chart",resourceId: initialState.resourceId,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,}),)@@ -115,10 +117,16 @@ export const useSdkIframeEmbedSettings = ({initialState,experience: "dashboard",resourceId: recentDashboards[0]?.id ?? EMBED_FALLBACK_DASHBOARD_ID,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,}),);- }, [recentDashboards, initialState, isGuestEmbedsEnabled]);+ }, [+ recentDashboards,+ initialState,+ isSimpleEmbedFeatureAvailable,+ isGuestEmbedsEnabled,+ ]);const [rawSettings, setRawSettings] = useState<SdkIframeEmbedSetupSettings>();diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-snippet.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-snippet.tsindex a3b03f232a6..3890f576664 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-snippet.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-snippet.ts@@ -9,17 +9,22 @@ import { getEmbedSnippet } from "../utils/embed-snippet";export function useSdkIframeEmbedSnippet() {const instanceUrl = useSetting("site-url");const applicationColors = useSetting("application-colors");- const { settings, experience, guestEmbedSignedTokenForSnippet } =- useSdkIframeEmbedSetupContext();+ const {+ isSimpleEmbedFeatureAvailable,+ settings,+ experience,+ guestEmbedSignedTokenForSnippet,+ } = useSdkIframeEmbedSetupContext();return useMemo(() => {// Apply derived colors to the settings for the code snippetconst derivedTheme =settings.theme &&- getDerivedDefaultColorsForEmbedFlow(- settings.theme,- applicationColors ?? undefined,- );+ getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme: settings.theme,+ applicationColors: applicationColors ?? undefined,+ });return getEmbedSnippet({settings: { ...settings, theme: derivedTheme },@@ -32,6 +37,7 @@ export function useSdkIframeEmbedSnippet() {applicationColors,instanceUrl,experience,+ isSimpleEmbedFeatureAvailable,guestEmbedSignedTokenForSnippet,]);}diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.tsindex 322a9bc7b0e..8a5a5741c30 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.ts@@ -30,16 +30,27 @@ const PRIMARY_COLORS = [* @param appColors Optional application colors from instance settings* @returns A new MetabaseTheme with derived colors added*/-export function getDerivedDefaultColorsForEmbedFlow(- theme: MetabaseTheme,- appColors: ColorPalette = {},-): MetabaseTheme {+export function getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme,+ applicationColors = {},+}: {+ isSimpleEmbedFeatureAvailable: boolean;+ theme: MetabaseTheme;+ applicationColors?: ColorPalette;+}): MetabaseTheme {+ if (!isSimpleEmbedFeatureAvailable) {+ return {+ preset: theme.preset,+ };+ }+const userColors = theme.colors ?? {};const backgroundColor = getSdkColorByName("background",userColors,- appColors,+ applicationColors,);const isDarkTheme = backgroundColor && isDark(backgroundColor);@@ -48,7 +59,7 @@ export function getDerivedDefaultColorsForEmbedFlow(// Ensure the primary colors are defined, as they cannot be derived.for (const colorKey of PRIMARY_COLORS) {derivedColors[colorKey] =- getSdkColorByName(colorKey, userColors, appColors) ?? undefined;+ getSdkColorByName(colorKey, userColors, applicationColors) ?? undefined;}// Apply theme-aware derived colors for SDK colors not defined by the user@@ -75,7 +86,7 @@ export function getDerivedDefaultColorsForEmbedFlow(const sourceColor = getSdkColorByName(operation.source,userColors,- appColors,+ applicationColors,);if (sourceColor === null) {diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.unit.spec.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.unit.spec.tsindex b3e2dc6ad60..04944b36c93 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.unit.spec.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/derived-colors-for-embed-flow.unit.spec.ts@@ -3,90 +3,135 @@ import type { MetabaseTheme } from "embedding-sdk-bundle/types/ui";import { getDerivedDefaultColorsForEmbedFlow } from "./derived-colors-for-embed-flow";describe("getDerivedDefaultColorsForEmbedFlow", () => {- it("derives colors for light theme", () => {- const theme: MetabaseTheme = {- colors: {- background: "#ffffff",- "text-primary": "#333333",- brand: "#509ee3",- border: "#d9d9d9",- },- };-- const { colors } = getDerivedDefaultColorsForEmbedFlow(theme);-- expect(colors?.background).toBe("#ffffff");- expect(colors?.["text-primary"]).toBe("#333333");- expect(colors?.["background-hover"]).toBe("rgb(252, 252, 252)");- expect(colors?.["background-disabled"]).toBe("rgb(247, 247, 247)");- expect(colors?.["text-secondary"]).toBe("rgb(66, 66, 66)");- expect(colors?.["text-tertiary"]).toBe("rgb(82, 82, 82)");+ describe('when "Simple Embed" feature is available', () => {+ const isSimpleEmbedFeatureAvailable = true;++ it("derives colors for light theme", () => {+ const theme: MetabaseTheme = {+ colors: {+ background: "#ffffff",+ "text-primary": "#333333",+ brand: "#509ee3",+ border: "#d9d9d9",+ },+ };++ const { colors } = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme,+ });++ expect(colors?.background).toBe("#ffffff");+ expect(colors?.["text-primary"]).toBe("#333333");+ expect(colors?.["background-hover"]).toBe("rgb(252, 252, 252)");+ expect(colors?.["background-disabled"]).toBe("rgb(247, 247, 247)");+ expect(colors?.["text-secondary"]).toBe("rgb(66, 66, 66)");+ expect(colors?.["text-tertiary"]).toBe("rgb(82, 82, 82)");+ });++ it("derives colors for dark theme", () => {+ const theme: MetabaseTheme = {+ colors: {+ background: "#1a1a1a",+ "text-primary": "#ffffff",+ brand: "#509ee3",+ },+ };++ const { colors } = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme,+ });++ expect(colors?.background).toBe("#1a1a1a");+ expect(colors?.["text-primary"]).toBe("#ffffff");+ expect(colors?.["background-hover"]).toBe("rgb(39, 39, 39)");+ expect(colors?.["background-disabled"]).toBe("rgb(31, 31, 31)");+ expect(colors?.["text-secondary"]).toBe("rgb(179, 179, 179)");+ expect(colors?.["text-tertiary"]).toBe("rgb(102, 102, 102)");+ });++ it("uses the default text-primary color if only background is defined", () => {+ const theme: MetabaseTheme = {+ colors: {+ background: "#1a1a1a",+ },+ };++ const { colors } = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme,+ });+ expect(colors?.["text-primary"]).toBe("hsla(204, 66%, 8%, 0.84)");+ });++ it("should not override existing colors", () => {+ const theme: MetabaseTheme = {+ colors: {+ background: "#ffffff",+ "text-primary": "#333333",+ "background-hover": "#existing-color",+ },+ };++ const { colors } = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme,+ });++ expect(colors?.background).toBe("#ffffff");+ expect(colors?.["text-primary"]).toBe("#333333");+ expect(colors?.["background-hover"]).toBe("#existing-color");+ });++ it("derives color from white-labeled colors", () => {+ const theme: MetabaseTheme = {};++ const applicationColors = {+ "bg-white": "#2d3030",+ "text-dark": "#eee",+ };++ const { colors } = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme,+ applicationColors,+ });++ expect(colors?.["background-hover"]).toBe("rgb(68, 72, 72)");+ });++ it("derives default colors for empty themes", () => {+ const { colors } = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme: {},+ });++ expect(colors).toBeDefined();+ expect(colors?.["background-hover"]).toBeDefined();+ expect(colors?.["text-secondary"]).toBeDefined();+ });});- it("derives colors for dark theme", () => {- const theme: MetabaseTheme = {- colors: {- background: "#1a1a1a",- "text-primary": "#ffffff",- brand: "#509ee3",- },- };-- const { colors } = getDerivedDefaultColorsForEmbedFlow(theme);-- expect(colors?.background).toBe("#1a1a1a");- expect(colors?.["text-primary"]).toBe("#ffffff");- expect(colors?.["background-hover"]).toBe("rgb(39, 39, 39)");- expect(colors?.["background-disabled"]).toBe("rgb(31, 31, 31)");- expect(colors?.["text-secondary"]).toBe("rgb(179, 179, 179)");- expect(colors?.["text-tertiary"]).toBe("rgb(102, 102, 102)");- });-- it("uses the default text-primary color if only background is defined", () => {- const theme: MetabaseTheme = {- colors: {- background: "#1a1a1a",- },- };-- const { colors } = getDerivedDefaultColorsForEmbedFlow(theme);- expect(colors?.["text-primary"]).toBe("hsla(204, 66%, 8%, 0.84)");- });-- it("should not override existing colors", () => {- const theme: MetabaseTheme = {- colors: {- background: "#ffffff",- "text-primary": "#333333",- "background-hover": "#existing-color",- },- };-- const { colors } = getDerivedDefaultColorsForEmbedFlow(theme);-- expect(colors?.background).toBe("#ffffff");- expect(colors?.["text-primary"]).toBe("#333333");- expect(colors?.["background-hover"]).toBe("#existing-color");- });-- it("derives color from white-labeled colors", () => {- const theme: MetabaseTheme = {};-- const appColors = {- "bg-white": "#2d3030",- "text-dark": "#eee",- };-- const { colors } = getDerivedDefaultColorsForEmbedFlow(theme, appColors);-- expect(colors?.["background-hover"]).toBe("rgb(68, 72, 72)");- });-- it("derives default colors for empty themes", () => {- const { colors } = getDerivedDefaultColorsForEmbedFlow({});-- expect(colors).toBeDefined();- expect(colors?.["background-hover"]).toBeDefined();- expect(colors?.["text-secondary"]).toBeDefined();+ describe('when "Simple Embed" feature is not available', () => {+ const isSimpleEmbedFeatureAvailable = false;++ it("returns only the preset from the theme", () => {+ const theme: MetabaseTheme = {+ preset: "dark",+ colors: {+ background: "#1a1a1a",+ "text-primary": "#ffffff",+ brand: "#509ee3",+ },+ };++ const result = getDerivedDefaultColorsForEmbedFlow({+ isSimpleEmbedFeatureAvailable,+ theme,+ });++ expect(result).toEqual({ preset: "dark" });+ });});});diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.tsindex 95e68cf3d86..0d031cb1ce6 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts@@ -7,6 +7,7 @@ import type {ExplorationEmbedOptions,MetabotEmbedOptions,QuestionEmbedOptions,+ SdkIframeEmbedBaseSettings,} from "metabase/embedding/embedding-iframe-sdk/types/embed";import type { SdkIframeEmbedSetupModalInitialState } from "metabase/plugins";@@ -21,14 +22,24 @@ export const getDefaultSdkIframeEmbedSettings = ({initialState,experience,resourceId,+ isSimpleEmbedFeatureAvailable,isGuestEmbedsEnabled,}: {initialState: SdkIframeEmbedSetupModalInitialState | undefined;experience: SdkIframeEmbedSetupExperience;resourceId: SdkDashboardId | SdkQuestionId;+ isSimpleEmbedFeatureAvailable: boolean;isGuestEmbedsEnabled: boolean;}): SdkIframeEmbedSetupSettings => {- const defaults = match(experience)+ const baseSettingsDefaults: Partial<SdkIframeEmbedBaseSettings> = {+ useExistingUserSession: true,+ // When `simple embed` feature is not available, we allow to set only a theme preset, so we default it to `light`+ ...(!isSimpleEmbedFeatureAvailable && {+ theme: { preset: "light" },+ }),+ };++ const experienceSettingsDefaults = match(experience).with("dashboard",(): DashboardEmbedOptions => ({@@ -75,8 +86,8 @@ export const getDefaultSdkIframeEmbedSettings = ({.exhaustive();return {- useExistingUserSession: true,- ...defaults,+ ...baseSettingsDefaults,+ ...experienceSettingsDefaults,...getCommonEmbedSettings({state: initialState,experience,diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.unit.spec.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.unit.spec.tsnew file mode 100644index 00000000000..23720173e8c--- /dev/null+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.unit.spec.ts@@ -0,0 +1,148 @@+import type { SdkIframeEmbedSetupExperience } from "../types";++import {+ getDefaultSdkIframeEmbedSettings,+ getExperienceFromSettings,+ getResourceIdFromSettings,+} from "./get-default-sdk-iframe-embed-setting";++jest.mock("./get-common-embed-settings", () => ({+ getCommonEmbedSettings: jest.fn(() => ({ isGuest: false })),+}));++const BASE_PARAMS = {+ initialState: undefined,+ resourceId: 123,+ isSimpleEmbedFeatureAvailable: true,+ isGuestEmbedsEnabled: false,+} as const;++describe("getDefaultSdkIframeEmbedSettings", () => {+ describe.each<{+ experience: SdkIframeEmbedSetupExperience;+ componentName: string;+ expectedProps: Record<string, unknown>;+ }>([+ {+ experience: "dashboard",+ componentName: "metabase-dashboard",+ expectedProps: {+ dashboardId: 123,+ drills: true,+ withDownloads: false,+ withTitle: true,+ },+ },+ {+ experience: "chart",+ componentName: "metabase-question",+ expectedProps: {+ questionId: 123,+ drills: true,+ withDownloads: false,+ withTitle: true,+ isSaveEnabled: false,+ },+ },+ {+ experience: "exploration",+ componentName: "metabase-question",+ expectedProps: { template: "exploration", isSaveEnabled: false },+ },+ {+ experience: "browser",+ componentName: "metabase-browser",+ expectedProps: { initialCollection: "root", readOnly: true },+ },+ {+ experience: "metabot",+ componentName: "metabase-metabot",+ expectedProps: {},+ },+ ])(+ "$experience experience",+ ({ experience, componentName, expectedProps }) => {+ it("returns correct component name and properties", () => {+ const result = getDefaultSdkIframeEmbedSettings({+ ...BASE_PARAMS,+ experience,+ });++ expect(result).toMatchObject({+ componentName,+ useExistingUserSession: true,+ ...expectedProps,+ });+ });+ },+ );++ describe("when simple embed feature is not available", () => {+ it("defaults theme to light preset", () => {+ const result = getDefaultSdkIframeEmbedSettings({+ ...BASE_PARAMS,+ experience: "dashboard",+ isSimpleEmbedFeatureAvailable: false,+ });++ expect(result.theme).toEqual({ preset: "light" });+ });+ });++ describe("when simple embed feature is available", () => {+ it("does not set a default theme", () => {+ const result = getDefaultSdkIframeEmbedSettings({+ ...BASE_PARAMS,+ experience: "dashboard",+ isSimpleEmbedFeatureAvailable: true,+ });++ expect(result.theme).toBeUndefined();+ });+ });+});++describe("getResourceIdFromSettings", () => {+ it.each([+ { settings: { initialCollection: "root" }, expected: "root" },+ { settings: { initialCollection: 42 }, expected: 42 },+ { settings: { dashboardId: 123 }, expected: 123 },+ { settings: { dashboardId: "abc" }, expected: "abc" },+ { settings: { questionId: 456 }, expected: 456 },+ { settings: { questionId: "xyz" }, expected: "xyz" },+ { settings: {}, expected: undefined },+ { settings: { componentName: "metabase-metabot" }, expected: undefined },+ ])("returns $expected for $settings", ({ settings, expected }) => {+ expect(getResourceIdFromSettings(settings as never)).toBe(expected);+ });+});++describe("getExperienceFromSettings", () => {+ it.each<{+ settings: Record<string, unknown>;+ expected: SdkIframeEmbedSetupExperience;+ }>([+ {+ settings: { template: "exploration", componentName: "metabase-question" },+ expected: "exploration",+ },+ {+ settings: { componentName: "metabase-question" },+ expected: "chart",+ },+ {+ settings: { componentName: "metabase-browser" },+ expected: "browser",+ },+ {+ settings: { componentName: "metabase-dashboard" },+ expected: "dashboard",+ },+ {+ settings: { componentName: "metabase-metabot" },+ expected: "metabot",+ },+ ])("returns $expected for $settings", ({ settings, expected }) => {+ expect(getExperienceFromSettings(settings as never)).toBe(expected);+ });+});diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsxindex ffa3812cc6c..37b144ee2c2 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx@@ -1,4 +1,4 @@-import type { ReactNode } from "react";+import { type ReactNode, useMemo } from "react";import { P, match } from "ts-pattern";import { PublicComponentStylesWrapper } from "embedding-sdk-bundle/components/private/PublicComponentStylesWrapper";@@ -17,6 +17,7 @@ import { getLoginStatus } from "embedding-sdk-bundle/store/selectors";import type { MetabaseAuthConfig } from "embedding-sdk-bundle/types/auth-config";import type { SdkDashboardEntityPublicProps } from "embedding-sdk-bundle/types/dashboard";import type { SdkQuestionEntityPublicProps } from "embedding-sdk-bundle/types/question";+import { applyThemePreset } from "embedding-sdk-shared/lib/apply-theme-preset";import { EmbeddingFooter } from "metabase/embedding/components/EmbeddingFooter/EmbeddingFooter";import { EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG } from "metabase/embedding-sdk/config";import { createTracker } from "metabase/lib/analytics-untyped";@@ -50,6 +51,11 @@ export const SdkIframeEmbedRoute = () => {onSettingsChanged,});+ const adjustedTheme = useMemo(+ () => applyThemePreset(embedSettings?.theme),+ [embedSettings?.theme],+ );+// The embed settings won't be available until the parent sends it via postMessage.// The SDK will show its own loading indicator, so we don't need to show it twice.if (!embedSettings || !embedSettings.instanceUrl) {@@ -58,7 +64,7 @@ export const SdkIframeEmbedRoute = () => {const hasEmbedTokenFeature = PLUGIN_EMBEDDING_IFRAME_SDK.hasValidLicense();- const { isGuest, theme, locale } = embedSettings;+ const { isGuest, locale } = embedSettings;const isProduction = !embedSettings._isLocalhost;// If the parent page is not running on localhost, it's not the unauthenticated embedding, and@@ -86,14 +92,14 @@ export const SdkIframeEmbedRoute = () => {return (<ComponentProviderauthConfig={authConfig}- theme={theme}+ theme={adjustedTheme}locale={locale}reduxStore={store}isLocalHost={embedSettings._isLocalhost}><Stackmih="100vh"- bg={theme?.colors?.background}+ bg={adjustedTheme?.colors?.background}style={{display: "grid",width: "100%",diff --git a/frontend/src/metabase/lib/colors/colors.ts b/frontend/src/metabase/lib/colors/colors.tsindex e367e2ddcb1..91f4460130f 100644--- a/frontend/src/metabase/lib/colors/colors.ts+++ b/frontend/src/metabase/lib/colors/colors.ts@@ -668,6 +668,14 @@ export const getColors = (settings?: ColorSettings) =>...settings,}) as Record<keyof typeof colorConfig, string>;+export const getDarkColors = (settings?: ColorSettings) =>+ ({+ ...Object.fromEntries(+ Object.entries(getColorConfig(settings)).map(([k, v]) => [k, v.dark]),+ ),+ ...settings,+ }) as Record<keyof typeof colorConfig, string>;+export const colors = getColors(whitelabelColors);export const mutateColors = (settings: ColorSettings) => {