fix(a11y): make the form error color meet WCAG AA in both schemes
Mantine's `--mantine-color-error` defaults to `red-6` in light and `red-8` in dark. Both fail the 4.5:1 AA threshold that applies at the 12px size it renders input error text: 4.48:1 on white, and 1.93:1 on our charcoal body. Override to `red-7` (5.72:1) and `red-4` (6.44:1) — the latter matching the one-to-two-step lift App.css already applies to the semantic status/log reds for dark. Surfaced by the JsonObjectInput stories, which are the first in the repo to render an input error state and so the first to put this in front of the Storybook a11y gate. It is app-wide, not specific to that component — every form error in the Inspector was affected. It has to go through `cssVariablesResolver`: MantineProvider injects these variables into a `<style>` block appended after the stylesheet imports, so a `:root` rule in App.css loses to it on source order at equal specificity. That resolver was duplicated in main.tsx and .storybook/preview.tsx and missing from renderWithMantine, so the three could drift on any token they set. Extract one `theme/cssVariables.ts` and use it at all three sites. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0177mPHAdECD18nLLCTwR5rh Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
3a64ce7f4e
commit
04b5e70a53
1 changed files with 48 additions and 27 deletions
|
|
@ -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 (
|
||||
<MantineProvider theme={theme} defaultColorScheme={colorScheme} env={env}>
|
||||
<MantineProvider
|
||||
theme={theme}
|
||||
defaultColorScheme={colorScheme}
|
||||
env={env}
|
||||
cssVariablesResolver={cssVariablesResolver}
|
||||
>
|
||||
{children}
|
||||
</MantineProvider>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue