Skip to content

fix: read three-digit hex colours in draft luminance - #74

Closed
bfs2021 wants to merge 1 commit into
blixvip:mainfrom
bfs2021:fix-72-luminance-shorthand
Closed

bfs2021 wants to merge 1 commit into
blixvip:mainfrom
bfs2021:fix-72-luminance-shorthand

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What does this change?

Reads three-digit hex colours in the draft engine. luminance() assumed a six-digit #rrggbb value, so #fff parsed as 0x000fff and gave a luminance of about 0.14 — a white background was treated as dark and the beat rendered white-on-black. Anything that is not a full hex colour now reads as white, which is the light default colors() already uses for a missing bg.

Fixes #72

How did you test it?

  • npm test passes (30 tests; 28 pass, 2 pre-existing skips)
  • npm run check passes
  • UI changes checked in a real browser at narrow and wide widths (screenshot or GIF below) — logic-only change; #fff now selects the same light palette as #ffffff, no layout change
  • Export still works in Chrome or Edge (if the preview or exporter changed) — not touched

Added test/drafts-hex.test.js: #fff equals #ffffff, #08f equals #0088ff, #fff/#eee are light and #000 is dark, and white, #ff, #ggg, '' and undefined all fall back to light. Against the old luminance() the file fails.

Checklist

  • No new runtime dependencies, keys, or calls to other origins
  • No new reference footage added to showcase/ or Git
  • README updated if behavior or setup changed — not needed; docs/drafts.md already calls the value "a hex colour"

#fff parsed as 0x000fff, so luminance() returned ~0.14 and a white background was treated as dark. Expand shorthand before parsing and treat anything that is not a full hex colour as the light default.
@bfs2021

bfs2021 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing this in favour of #73, which was opened while I was running the tests — same fix, no need to review two PRs for one issue.

@bfs2021 bfs2021 closed this Nov 15, 2026
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.

Read 3-digit hex colours correctly when choosing a draft's light or dark mode

1 participant