diff --git a/apps/mobile/src/lib/mobileTheme.test.ts b/apps/mobile/src/lib/mobileTheme.test.ts index 1c7643f989..c1b4ce553f 100644 --- a/apps/mobile/src/lib/mobileTheme.test.ts +++ b/apps/mobile/src/lib/mobileTheme.test.ts @@ -158,6 +158,21 @@ describe("mobile themes", () => { } }); + it.each(MOBILE_THEME_IDS)("keeps %s sidebar text readable on Android", (themeId) => { + for (const appearance of ["light", "dark"] as const) { + const variables = getMobileThemeRuntimeVariables(themeId, appearance, "android"); + for (const foreground of [ + "--color-drawer-foreground", + "--color-drawer-foreground-muted", + ] as const) { + expect( + contrastRatio(variables[foreground], variables["--color-drawer"]), + `${appearance}: ${foreground}`, + ).toBeGreaterThanOrEqual(4.5); + } + } + }); + it("applies palette overrides on top of the selected built-in theme", () => { const variables = getMobileThemeVariables("ocean", "dark", { "--color-primary": "#123456", @@ -182,9 +197,11 @@ describe("mobile themes", () => { runtime[platform === "android" ? "--color-header" : "--color-drawer"], runtime["--color-screen"], ); - expect(relativeLuminance(sidebar)).toBeLessThan( - relativeLuminance(runtime["--color-thread-canvas"]), - ); + if (platform === "ios") { + expect(relativeLuminance(sidebar)).toBeLessThan( + relativeLuminance(runtime["--color-thread-canvas"]), + ); + } expect(contrastRatio(chrome, runtime["--color-screen"])).toBeGreaterThanOrEqual(1.06); const foregroundRoles = platform === "android" diff --git a/apps/mobile/src/lib/mobileThemeVariables.test.ts b/apps/mobile/src/lib/mobileThemeVariables.test.ts index 1fecf3074b..c3e275f3dc 100644 --- a/apps/mobile/src/lib/mobileThemeVariables.test.ts +++ b/apps/mobile/src/lib/mobileThemeVariables.test.ts @@ -24,7 +24,7 @@ describe("mobile theme runtime variables", () => { }); it.each(MOBILE_THEME_IDS)( - "keeps %s colors on Android with an opaque Material frame", + "uses a screen-colored %s sidebar beneath an opaque Android frame", (themeId) => { for (const appearance of ["light", "dark"] as const) { const base = getMobileThemeVariables( @@ -43,6 +43,7 @@ describe("mobile theme runtime variables", () => { 1, ), "--color-header-foreground": base["--color-drawer-foreground"], + "--color-drawer": base["--color-screen"], }); expect(android["--color-header"]).toMatch(/^rgba\(\d+, \d+, \d+, 1\)$/); } @@ -76,7 +77,6 @@ describe("mobile theme runtime variables", () => { expect(ios["--color-header-foreground"]).toBe(ios["--color-drawer-foreground"]); } else { expect(ios).toEqual(getMobileThemeVariables("t3-code", appearance)); - expect(ios["--color-drawer"]).toBe(android["--color-drawer"]); expect(ios["--color-drawer"]).toBe("#000000"); expect(ios["--color-thread-canvas"]).toBe("#0a0a0a"); } diff --git a/apps/mobile/src/lib/mobileThemeVariables.ts b/apps/mobile/src/lib/mobileThemeVariables.ts index 15096c0fd1..8fd82955b7 100644 --- a/apps/mobile/src/lib/mobileThemeVariables.ts +++ b/apps/mobile/src/lib/mobileThemeVariables.ts @@ -48,5 +48,6 @@ export function getMobileThemeRuntimeVariables( ...variables, "--color-header": frame, "--color-header-foreground": variables["--color-drawer-foreground"], + "--color-drawer": variables["--color-screen"], }; }