Skip to content

[types] Add collapse option to SerializeOptions - #712

Merged
MysteryBlokHed merged 1 commit into
mainfrom
types/add-collapse-option
Jan 28, 2026
Merged

MysteryBlokHed merged 1 commit into
mainfrom
types/add-collapse-option

Conversation

@MysteryBlokHed

@MysteryBlokHed MysteryBlokHed commented Jan 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #266 (comment)

The sRGB space defines this option here:

serialize: (
coords,
alpha,
{
collapse = true, // collapse to 3-4 digit hex when possible?
alpha: alphaFormat,
} = {},
) => {

Which can be called from serialize via:

if (format.type === "custom") {
if (format.serialize) {
ret = format.serialize(coords, colorWithMeta.alpha, options);
}
else {
throw new TypeError(
`format ${formatId} can only be used to parse colors, not for serialization`,
);
}
}

@netlify

netlify Bot commented Jan 28, 2026 •

Copy link
Copy Markdown

βœ… Deploy Preview for colorjs ready!

Name Link
πŸ”¨ Latest commit 7f0ab40
πŸ” Latest deploy log https://app.netlify.com/projects/colorjs/deploys/697a3f11a401810009e67570
😎 Deploy Preview https://deploy-preview-712--colorjs.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@MysteryBlokHed
MysteryBlokHed requested a review from lloydk January 28, 2026 17:00

@lloydk lloydk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@MysteryBlokHed
MysteryBlokHed merged commit c6d4bc1 into main Jan 28, 2026
5 checks passed
@MysteryBlokHed
MysteryBlokHed deleted the types/add-collapse-option branch January 28, 2026 19:38
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.

toString return complete hex color

2 participants