Skip to content

fix(color): normalize scheme seeds without # to #RRGGBB - #459

Merged
lnkiai merged 1 commit into
lnkiai:mainfrom
kevin9327:fix/scheme-seed-normalize-hash
Oct 8, 2026
Merged

lnkiai merged 1 commit into
lnkiai:mainfrom
kevin9327:fix/scheme-seed-normalize-hash

Conversation

@kevin9327

@kevin9327 kevin9327 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

hexToRgb already accepts a 6-digit seed without a leading # ("ff00aa"). schemeFromSeed still stored seedHex.toUpperCase() as palette.seed, so that input became "FF00AA" instead of the canonical "#FF00AA" used everywhere else (and required by isHex).

When the seed parses, set seed from rgbToHex so it is always #RRGGBB. Invalid seeds are still uppercased as before.

Test plan

  • npx vitest run lib/color.extended.test.ts lib/color.test.ts
  • New case: schemeFromSeed("ff00aa").seed === "#FF00AA" (fails before, passes after)
  • npm run typecheck

Summary by cubic

Fixes schemeFromSeed so valid seeds without # are stored as #RRGGBB in palette.seed, matching the canonical format used elsewhere and required by isHex. Previously schemeFromSeed("ff00aa").seed returned "FF00AA".

  • Invalid seeds are still uppercased as before.

Written for commit 36f1e6d. Summary will update on new commits.

Review in cubic

hexToRgb already accepts "ff00aa", but schemeFromSeed stored the
uppercased raw string as seed, so the palette carried "FF00AA" instead
of "#FF00AA". Write the canonical #RRGGBB when the seed parses.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@lnkiai
lnkiai merged commit 0239ae1 into lnkiai:main Oct 8, 2026
1 check passed
@lnkiai

lnkiai commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Thanks, merged. The app itself always passes a seed with #, so this mostly keeps schemeFromSeed consistent for other callers, but it's the right normalization.

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.

2 participants