Conversation
parseColor() now parses 3, 4, 6, and 8 digit hex values that arrive without the # prefix (as Figma's picker shows them) and the 148 CSS Color Module Level 4 named colors, including transparent. currentcolor stays an error because it can only be resolved from the surrounding text color. The input placeholder, the error message, and the color-converter FAQ mention the new formats.
anurag629
left a comment
There was a problem hiding this comment.
Thanks @joshuaallgaier2-cmd, this does what #496 asks. Lint (develop's 11 warnings), all 2663 tests and the build pass on top of develop, and 5 of the new tests fail on develop's color-utils.ts. All 148 names match the values in the color-name package, and constructor, toString and __proto__ are rejected. On a built copy F26DF0 and RebeccaPurple convert in the main input, white on 663399 gives 8.40:1 in the contrast checker, and currentcolor shows its own message, at 375px and in both themes.
|
Merged, thanks @joshuaallgaier2-cmd! If you haven't yet, come join our Discord (https://discord.gg/mpGdJyjaRQ) and run |
What and why
The color converter now accepts hex values without
#and the 148 CSS named colors, case-insensitively, plus transparent.currentcolorremains an error because it depends on the surrounding text color. The placeholder, error message, and FAQ describe the accepted formats.The review revision also rejects inherited object properties such as
constructorand__proto__. Previously, the named-color lookup incorrectly returned opaque black for both. An own-property check limits it to the color table's entries.Closes #496
How I tested this
OpenAI Codex ran these checks on Windows for the latest revision:
npm test: 2,661 passed; two untouched tests timed out at the default five seconds (csv-utils' TypeScript compiler test and RegexTesterClient's 1,000-match navigation test).npm run lint: passed with 11 existing warnings in untouched code.npm run build: passed.To check manually, run
npm run devand open/color-converter. Valid examples includeF26DF0,rebeccapurple,RED, andtransparent;constructorand__proto__should show an error. This manual browser check was not performed during this revision.AI assistance
The original implementation was written with Claude in the DeepSeek Harness. OpenAI Codex reviewed the open PR, reproduced and fixed the inherited-property bug, added regression cases, reviewed the revision diff, and ran the checks reported above. Joshua is not claimed to have personally run or reviewed this revision.
Type of change
Checklist
npm run lint && npm run test && npm run buildpasses locally (two full-suite timeouts; focused reruns passed as described above)lib/and have a test inlib/__tests__/page.tsx, client component,opengraph-image.tsx, and the bug report dropdown are all done (not applicable: existing tool)Notes for reviewers
The named-color table is alphabetically ordered and stores
0xRRGGBBvalues. Transparent is handled separately for its alpha value. The existing claim remains pending: the maintainer said assignment and review will follow once codercops/chatcops#617 merges. No assignment or CI policy was changed.