Your app looks AI-generated. Vincent Van Gogh noticed. An agent skill that finds and fixes AI-looking UI and UX in mobile apps, web apps, and websites.
JavaScript accessibilityagent-skillsagent-skills-toolsagentsagentskillsai-slopclaudeclaude-codeclaude-skillsexpoflutterfrontendionicjetpack-composemobilereact-nativeswiftuiuiuxvibe-coding
fix(detect): read #RRGGBBAA, #RGB and #RGBA hex colors (#61)
Nguyễn Tuấn Anh5eb2435bb547
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 9c4df69..7ade6e4 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -62,14 +62,22 @@ function hexToHsl(hex) {}// Six-digit hex colors in a snippet: #RRGGBB, 0xFFRRGGBB, Color(0xRRGGBB),-// and #AARRGGBB in Android XML.+// and #AARRGGBB in Android XML. #RRGGBBAA drops its alpha, and the short+// forms expand (#RGB -> #RRGGBB, #RGBA -> #RRGGBB) so alpha and short+// colors are read the same way as #RRGGBB.function hexColors(snippet, stack) {const out = [];const re = stack === "xml"? /#(?:[0-9a-fA-F]{2})?([0-9a-fA-F]{6})\b|0x[fF]{2}([0-9a-fA-F]{6})\b/g- : /#([0-9a-fA-F]{6})\b|0x[fF]{2}([0-9a-fA-F]{6})\b/g;+ : /#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b|0x[fF]{2}([0-9a-fA-F]{6})\b/g;let m;- while ((m = re.exec(snippet))) out.push((m[1] || m[2]).toUpperCase());+ while ((m = re.exec(snippet))) {+ let hex = m[1] || m[2];+ if (hex.length === 8) hex = hex.slice(0, 6);+ else if (hex.length === 4) hex = hex.slice(0, 3).split("").map((c) => c + c).join("");+ else if (hex.length === 3) hex = hex.split("").map((c) => c + c).join("");+ out.push(hex.toUpperCase());+ }return out;}diff --git a/test/detect.test.js b/test/detect.test.jsindex aa98495..d620364 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -218,6 +218,23 @@ test("slop-gradient reads Android #AARRGGBB colors", () => {assert.deepStrictEqual(scanSource(scrim, "a.css"), []);});+test("hexColors reads #RRGGBBAA, #RGB and #RGBA (issue #41)", () => {+ const shadow = ".card { box-shadow: 0 0 24px #7c3aed80; }\n";+ assert.deepStrictEqual(scanSource(shadow, "a.css").map((f) => f.rule), ["glow-shadow"]);+ const gradient = ".hero { background: linear-gradient(135deg, #7c3aedcc, #a855f7cc); }\n";+ assert.deepStrictEqual(scanSource(gradient, "a.css").map((f) => f.rule), ["slop-gradient"]);+ // Short forms expand to the same colors (#73e -> #7733EE, #73e8 -> #7733EE).+ const shortShadow = ".card { box-shadow: 0 0 24px #73e8; }\n";+ assert.deepStrictEqual(scanSource(shortShadow, "a.css").map((f) => f.rule), ["glow-shadow"]);+ const shortGradient = ".hero { background: linear-gradient(135deg, #73e, #a5f); }\n";+ assert.deepStrictEqual(scanSource(shortGradient, "a.css").map((f) => f.rule), ["slop-gradient"]);+ // A black shadow with alpha stays unflagged by glow-shadow.+ const black = ".card { box-shadow: 0 0 24px #000000cc; }\n";+ assert.deepStrictEqual(scanSource(black, "a.css"), []);+ const blackShort = ".card { box-shadow: 0 0 24px #000c; }\n";+ assert.deepStrictEqual(scanSource(blackShort, "a.css"), []);+});+test("welcome-back fires with or without '!'", () => {const withName = "export const A = () => <h1>Welcome back, {name}</h1>;\n";const bare = "export const B = () => <h1>Welcome back</h1>;\n";