Skip to content

doc: add registry parseAsColor using tinycolor2#1348

Open
jo-chemla wants to merge 2 commits into47ng:nextfrom
jo-chemla:parseAsColor-registry
Open

doc: add registry parseAsColor using tinycolor2#1348
jo-chemla wants to merge 2 commits into47ng:nextfrom
jo-chemla:parseAsColor-registry

Conversation

@jo-chemla
Copy link
Copy Markdown

See discussion #1342 Adding parseAsColor registry item here https://github.com/47ng/nuqs/tree/next/packages/docs/src/registry/items tinycolor is 5kB minified + gzipped, smaller than chromajs 16kB

See discussion 47ng#1342
Adding `parseAsColor` registry item here https://github.com/47ng/nuqs/tree/next/packages/docs/src/registry/items
tinycolor is 5kB minified + gzipped, smaller than chromajs 16kB
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 2, 2026

@jo-chemla is attempting to deploy a commit to the 47ng Team on Vercel.

A member of the Team first needs to authorize it.

@franky47 franky47 changed the title Add registry parseAsColor using tinycolor2 doc: add registry parseAsColor using tinycolor2 Mar 2, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nuqs Ready Ready Preview, Comment Mar 3, 2026 10:34am

Request Review

Updated color parsing to decode URL-encoded characters before processing.
const color = tinycolor(value)

// Decode URL-encoded characters (e.g., %23 -> #)
const decodedValue = decodeURIComponent(value)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: to keep the URL small we could forego the hash, just with the character set and its length we should be able to detect hex color codes, no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes indeed, by default when the hash is not present the color is still correctly parsed. When serializing, we don't prefix with the hash, only use the 6 digits hex string.

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