|
35 | 35 | // app colors before React mounts. |
36 | 36 | const DEFAULT_THEME_PALETTES = { |
37 | 37 | light: { |
38 | | - background: "#fdf7fd", |
39 | | - foreground: "#501854", |
40 | | - accent: "#db2777", |
41 | | - chrome: "#fdf7fd", |
| 38 | + background: "oklch(0.982446 0.010114 325.653)", |
| 39 | + foreground: "oklch(0.325698 0.116116 325.037)", |
| 40 | + accent: "oklch(0.591646 0.217985 0.584)", |
| 41 | + chrome: "oklch(0.982446 0.010114 325.653)", |
42 | 42 | }, |
43 | 43 | dark: { |
44 | | - background: "#1f1a24", |
45 | | - foreground: "#f9f8fb", |
46 | | - accent: "#a3004c", |
47 | | - chrome: "#1f1a24", |
| 44 | + background: "oklch(0.22813 0.020366 307.469)", |
| 45 | + foreground: "oklch(0.980735 0.004092 301.426)", |
| 46 | + accent: "oklch(0.460685 0.185347 4.099)", |
| 47 | + chrome: "oklch(0.22813 0.020366 307.469)", |
48 | 48 | }, |
49 | 49 | }; |
50 | 50 | // Keep this small boot-time copy in sync with the built-in palettes so |
51 | 51 | // the selected theme is visible before the app has mounted. |
52 | 52 | const BUILT_IN_THEME_PALETTES = { |
53 | 53 | "t3-chat": { |
54 | 54 | light: { |
55 | | - background: "#fdf7fd", |
56 | | - foreground: "#501854", |
57 | | - accent: "#db2777", |
58 | | - chrome: "#fdf7fd", |
| 55 | + background: "oklch(0.982446 0.010114 325.653)", |
| 56 | + foreground: "oklch(0.325698 0.116116 325.037)", |
| 57 | + accent: "oklch(0.591646 0.217985 0.584)", |
| 58 | + chrome: "oklch(0.982446 0.010114 325.653)", |
59 | 59 | }, |
60 | 60 | dark: { |
61 | | - background: "#1f1a24", |
62 | | - foreground: "#f9f8fb", |
63 | | - accent: "#a3004c", |
64 | | - chrome: "#1f1a24", |
| 61 | + background: "oklch(0.22813 0.020366 307.469)", |
| 62 | + foreground: "oklch(0.980735 0.004092 301.426)", |
| 63 | + accent: "oklch(0.460685 0.185347 4.099)", |
| 64 | + chrome: "oklch(0.22813 0.020366 307.469)", |
65 | 65 | }, |
66 | 66 | }, |
67 | 67 | grove: { |
68 | 68 | light: { |
69 | | - background: "#f3f7f4", |
70 | | - foreground: "#241523", |
71 | | - accent: "#1b7d50", |
72 | | - chrome: "#f3f7f4", |
| 69 | + background: "oklch(0.972369 0.005497 157.15)", |
| 70 | + foreground: "oklch(0.222003 0.03479 328.979)", |
| 71 | + accent: "oklch(0.523295 0.112292 158.089)", |
| 72 | + chrome: "oklch(0.972369 0.005497 157.15)", |
73 | 73 | }, |
74 | 74 | dark: { |
75 | | - background: "#1b2821", |
76 | | - foreground: "#fffaff", |
77 | | - accent: "#69d69a", |
78 | | - chrome: "#1b2821", |
| 75 | + background: "oklch(0.260865 0.02152 162.75)", |
| 76 | + foreground: "oklch(0.990339 0.008411 325.64)", |
| 77 | + accent: "oklch(0.796228 0.133058 157.319)", |
| 78 | + chrome: "oklch(0.260865 0.02152 162.75)", |
79 | 79 | }, |
80 | 80 | }, |
81 | 81 | ocean: { |
82 | 82 | light: { |
83 | | - background: "#f5f7f8", |
84 | | - foreground: "#241523", |
85 | | - accent: "#2672af", |
86 | | - chrome: "#f5f7f8", |
| 83 | + background: "oklch(0.974199 0.002856 241.597)", |
| 84 | + foreground: "oklch(0.222003 0.03479 328.979)", |
| 85 | + accent: "oklch(0.536684 0.120219 247.01)", |
| 86 | + chrome: "oklch(0.974199 0.002856 241.597)", |
87 | 87 | }, |
88 | 88 | dark: { |
89 | | - background: "#17212b", |
90 | | - foreground: "#fffaff", |
91 | | - accent: "#70b9ee", |
92 | | - chrome: "#17212b", |
| 89 | + background: "oklch(0.242641 0.024125 250.573)", |
| 90 | + foreground: "oklch(0.990339 0.008411 325.64)", |
| 91 | + accent: "oklch(0.758933 0.105833 241.548)", |
| 92 | + chrome: "oklch(0.242641 0.024125 250.573)", |
93 | 93 | }, |
94 | 94 | }, |
95 | 95 | ember: { |
96 | 96 | light: { |
97 | | - background: "#f9f7f5", |
98 | | - foreground: "#241523", |
99 | | - accent: "#ae552a", |
100 | | - chrome: "#f9f7f5", |
| 97 | + background: "oklch(0.976527 0.002685 60.725)", |
| 98 | + foreground: "oklch(0.222003 0.03479 328.979)", |
| 99 | + accent: "oklch(0.552831 0.129438 44.656)", |
| 100 | + chrome: "oklch(0.976527 0.002685 60.725)", |
101 | 101 | }, |
102 | 102 | dark: { |
103 | | - background: "#291e1a", |
104 | | - foreground: "#fffaff", |
105 | | - accent: "#f09a64", |
106 | | - chrome: "#291e1a", |
| 103 | + background: "oklch(0.245899 0.019144 42.044)", |
| 104 | + foreground: "oklch(0.990339 0.008411 325.64)", |
| 105 | + accent: "oklch(0.762174 0.124117 52.082)", |
| 106 | + chrome: "oklch(0.245899 0.019144 42.044)", |
107 | 107 | }, |
108 | 108 | }, |
109 | 109 | iris: { |
110 | 110 | light: { |
111 | | - background: "#f8f7f9", |
112 | | - foreground: "#241523", |
113 | | - accent: "#7253b9", |
114 | | - chrome: "#f8f7f9", |
| 111 | + background: "oklch(0.976531 0.003855 303.226)", |
| 112 | + foreground: "oklch(0.222003 0.03479 328.979)", |
| 113 | + accent: "oklch(0.525348 0.15373 294.176)", |
| 114 | + chrome: "oklch(0.976531 0.003855 303.226)", |
115 | 115 | }, |
116 | 116 | dark: { |
117 | | - background: "#1d1929", |
118 | | - foreground: "#fffaff", |
119 | | - accent: "#9d7df2", |
120 | | - chrome: "#1d1929", |
| 117 | + background: "oklch(0.225975 0.031062 293.741)", |
| 118 | + foreground: "oklch(0.990339 0.008411 325.64)", |
| 119 | + accent: "oklch(0.671712 0.169136 293.929)", |
| 120 | + chrome: "oklch(0.225975 0.031062 293.741)", |
121 | 121 | }, |
122 | 122 | }, |
123 | 123 | }; |
|
152 | 152 | } |
153 | 153 | }; |
154 | 154 |
|
155 | | - const isHexColor = (value) => |
156 | | - typeof value === "string" && |
157 | | - /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(value); |
| 155 | + // The runtime decodes the same literal CSS formats into OKLCH. Keep |
| 156 | + // contextual colors out: they cannot be resolved from stored data. |
| 157 | + const SYSTEM_COLOR_KEYWORD = |
| 158 | + /^(?:accentcolor(?:text)?|active(?:border|caption|text)|appworkspace|background|button(?:border|face|highlight|shadow|text)|canvas(?:text)?|captiontext|field(?:text)?|graytext|highlight(?:text)?|inactive(?:border|caption(?:text)?)|info(?:background|text)|linktext|mark(?:text)?|menu(?:text)?|scrollbar|selecteditem(?:text)?|threed(?:darkshadow|face|highlight|lightshadow|shadow)|visitedtext|window(?:frame|text)?)$/i; |
| 159 | + const isThemeColor = (value) => { |
| 160 | + if (typeof value !== "string" || typeof CSS === "undefined") return false; |
| 161 | + const color = value.trim(); |
| 162 | + if ( |
| 163 | + /^(?:currentcolor|inherit|initial|revert|revert-layer|unset)$/i.test(color) || |
| 164 | + SYSTEM_COLOR_KEYWORD.test(color) || |
| 165 | + /\bfrom\b|(?:var|env|attr|calc|min|max|clamp)\(/i.test(color) |
| 166 | + ) { |
| 167 | + return false; |
| 168 | + } |
| 169 | + const isLiteralColor = |
| 170 | + /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color) || |
| 171 | + /^[a-z]+$/i.test(color) || |
| 172 | + /^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(/i.test(color); |
| 173 | + return isLiteralColor && CSS.supports("color", color); |
| 174 | + }; |
158 | 175 | const isRecord = (value) => |
159 | 176 | typeof value === "object" && value !== null && !Array.isArray(value); |
160 | 177 | const isThemeId = (value) => |
|
322 | 339 | const fallbackSplash = isDark ? SPLASH_COLORS.dark : SPLASH_COLORS.light; |
323 | 340 | const customSplash = customColors |
324 | 341 | ? { |
325 | | - background: isHexColor(customColors.canvas) |
| 342 | + background: isThemeColor(customColors.canvas) |
326 | 343 | ? customColors.canvas |
327 | 344 | : (customDefaults?.background ?? fallbackSplash.background), |
328 | | - foreground: isHexColor(customColors.text) |
| 345 | + foreground: isThemeColor(customColors.text) |
329 | 346 | ? customColors.text |
330 | 347 | : (customDefaults?.foreground ?? fallbackSplash.foreground), |
331 | | - accent: isHexColor(customColors.accent) |
| 348 | + accent: isThemeColor(customColors.accent) |
332 | 349 | ? customColors.accent |
333 | 350 | : (customDefaults?.accent ?? fallbackSplash.accent), |
334 | 351 | } |
|
350 | 367 | } |
351 | 368 | document.documentElement.classList.toggle("dark", isDark); |
352 | 369 | const chromeColor = customColors |
353 | | - ? isHexColor(customColors.chrome) |
| 370 | + ? isThemeColor(customColors.chrome) |
354 | 371 | ? customColors.chrome |
355 | 372 | : (customDefaults?.chrome ?? fallbackSplash.background) |
356 | 373 | : builtInSplash |
|
0 commit comments