diff --git a/clients/web/.storybook/preview.tsx b/clients/web/.storybook/preview.tsx index 6b419a43..e1669ea0 100644 --- a/clients/web/.storybook/preview.tsx +++ b/clients/web/.storybook/preview.tsx @@ -1,14 +1,11 @@ import type { Preview } from "@storybook/react-vite"; -import { - MantineProvider, - useMantineColorScheme, - type CSSVariablesResolver, -} from "@mantine/core"; +import { MantineProvider, useMantineColorScheme } from "@mantine/core"; import { Notifications } from "@mantine/notifications"; import "@mantine/core/styles.css"; import "@mantine/notifications/styles.css"; import "../src/App.css"; import { theme } from "../src/theme/theme"; +import { cssVariablesResolver } from "../src/theme/cssVariables"; import { useEffect } from "react"; // eslint-disable-next-line react-refresh/only-export-components @@ -28,14 +25,6 @@ function ColorSchemeWrapper({ return <>{children}; } -const resolver: CSSVariablesResolver = () => ({ - variables: {}, - light: {}, - dark: { - "--mantine-color-body": "var(--mantine-color-dark-9)", - }, -}); - const preview: Preview = { globalTypes: { colorScheme: { @@ -61,7 +50,7 @@ const preview: Preview = { ({ - variables: {}, - light: {}, - dark: { - // Matches `.storybook/preview.tsx` so the dev app and the story preview - // share the same dark-mode page background. - "--mantine-color-body": "var(--mantine-color-dark-9)", - }, -}); - createRoot(document.getElementById("root")!).render( diff --git a/clients/web/src/test/renderWithMantine.tsx b/clients/web/src/test/renderWithMantine.tsx index ea291c6b..677d9ca0 100644 --- a/clients/web/src/test/renderWithMantine.tsx +++ b/clients/web/src/test/renderWithMantine.tsx @@ -3,6 +3,7 @@ import { act, render, type RenderOptions } from "@testing-library/react"; import { MantineProvider, type MantineColorScheme } from "@mantine/core"; import { afterEach, expect, vi } from "vitest"; import { theme } from "../theme/theme"; +import { cssVariablesResolver } from "../theme/cssVariables"; // Options accepted by both render helpers: the standard RTL options (minus // `wrapper`, which we own) plus an optional forced `colorScheme`. The default @@ -30,7 +31,12 @@ export type MantineTransitionsRenderOptions = MantineRenderOptions & { function makeWrapper(env: "test" | "default", colorScheme: MantineColorScheme) { return function Wrapper({ children }: { children: ReactNode }) { return ( - + {children} ); diff --git a/clients/web/src/theme/cssVariables.ts b/clients/web/src/theme/cssVariables.ts new file mode 100644 index 00000000..11bad0f9 --- /dev/null +++ b/clients/web/src/theme/cssVariables.ts @@ -0,0 +1,34 @@ +import type { CSSVariablesResolver } from "@mantine/core"; + +/** + * Overrides for the Mantine CSS variables that `MantineProvider` injects at + * runtime. + * + * These cannot be set from `App.css`: the provider appends its generated + * `