Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { getMobileThemeRuntimeVariables } from "./mobileThemeVariables";
4import type { MaterialYouPalette } from "./materialYouPalette";
5import { materialYouPaletteToMobileThemeVariables } from "./materialYouTheme";
6
7const palette: MaterialYouPalette = {
8 primary: "#6750A4FF",
9 onPrimary: "#FFFFFFFF",
10 primaryContainer: "#EADDFFFF",
11 onPrimaryContainer: "#21005DFF",
12 inversePrimary: "#D0BCFFFF",
13 secondaryContainer: "#E8DEF8FF",
14 onSecondaryContainer: "#1D192BFF",
15 tertiary: "#7D5260FF",
16 tertiaryContainer: "#FFD8E4FF",
17 onTertiaryContainer: "#31111DFF",
18 surface: "#FFFBFEFF",
19 onSurface: "#1C1B1FFF",
20 onSurfaceVariant: "#49454FFF",
21 surfaceContainer: "#F3EDF7FF",
22 surfaceContainerHigh: "#ECE6F0FF",
23 surfaceContainerHighest: "#E6E0E9FF",
24 surfaceContainerLow: "#F7F2FAFF",
25 surfaceContainerLowest: "#FFFFFFFF",
26 errorContainer: "#F9DEDCFF",
27 onErrorContainer: "#410E0BFF",
28 outline: "#79747EFF",
29 outlineVariant: "#CAC4D0FF",
30 scrim: "#000000FF",
31};
32
33describe("Material You system colors", () => {
34 it("overrides the selected theme without mutating its base variables", () => {
35 const base = getMobileThemeRuntimeVariables("t3-code", "dark");
36 const snapshot = { ...base };
37
38 const variables = materialYouPaletteToMobileThemeVariables(palette, "dark", base);
39
40 expect(base).toEqual(snapshot);
41 expect(variables["--color-screen"]).toBe(palette.surface);
42 expect(variables["--color-thread-canvas"]).toBe(palette.surfaceContainerLow);
43 expect(variables["--color-thread-selected"]).toBe(palette.surfaceContainer);
44 expect(variables["--color-header"]).toBe(palette.surfaceContainerHigh);
45 expect(variables["--color-primary"]).toBe(palette.primary);
46 expect(variables["--color-placeholder"]).toBe("#1C1B1F9E");
47 });
48
49 it("uses the Messages-style RCS tones for sent messages", () => {
50 const base = getMobileThemeRuntimeVariables("t3-code", "dark");
51 const dark = materialYouPaletteToMobileThemeVariables(
52 { ...palette, inversePrimary: "#A31D8DFF" },
53 "dark",
54 base,
55 );
56 const light = materialYouPaletteToMobileThemeVariables(
57 { ...palette, inversePrimary: "#A31D8DFF" },
58 "light",
59 getMobileThemeRuntimeVariables("t3-code", "light"),
60 );
61
62 expect(dark["--color-user-bubble"]).toBe("#850073FF");
63 expect(dark["--color-user-bubble-foreground"]).toBe("#FFD7EFFF");
64 expect(light["--color-user-bubble"]).toBe(palette.primary);
65 expect(light["--color-user-bubble-foreground"]).toBe(palette.onPrimary);
66 });
67});