Skip to content

feat(color-converter): accept hex without # and CSS named colors - #501

Open
joshuaallgaier2-cmd wants to merge 2 commits into
codercops:developfrom
joshuaallgaier2-cmd:fix/496-hex-and-named-colors
Open

joshuaallgaier2-cmd wants to merge 2 commits into
codercops:developfrom
joshuaallgaier2-cmd:fix/496-hex-and-named-colors

Conversation

@joshuaallgaier2-cmd

@joshuaallgaier2-cmd joshuaallgaier2-cmd commented Nov 15, 2026 •

Copy link
Copy Markdown

What and why

The color converter now accepts hex values without # and the 148 CSS named colors, case-insensitively, plus transparent. currentcolor remains 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 constructor and __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:

  • Added two regression cases before changing the parser: both failed, confirming the inherited-property bug.
  • After the one-line fix, the complete color-utils file passes all 78 tests.
  • 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).
  • Focused rerun of color-utils, csv-utils, and RegexTesterClient with two workers and a 30-second timeout: all 233 tests passed across three files.
  • npm run lint: passed with 11 existing warnings in untouched code.
  • npm run build: passed.

To check manually, run npm run dev and open /color-converter. Valid examples include F26DF0, rebeccapurple, RED, and transparent; constructor and __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

  • Bug fix
  • New tool or feature (additional accepted color formats)
  • Tests
  • Refactor or cleanup
  • Docs

Checklist

  • I was assigned the linked issue
  • npm run lint && npm run test && npm run build passes locally (two full-suite timeouts; focused reruns passed as described above)
  • Logic changes live in lib/ and have a test in lib/__tests__/
  • For a bug fix: the new test fails without my change
  • No analytics, trackers, or calls that send user data off-device
  • Works in both light and dark themes (if UI changed)
  • Inputs have labels and it works with the keyboard alone (if UI changed)
  • New tool: registry entry, 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 0xRRGGBB values. 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.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Color converter: accept hex without # and CSS color names like rebeccapurple

1 participant