Skip to content

Define an extension API for registering custom color formatter #135

@bgrins

Description

@bgrins

Originally from #98.

There are a bunch of color formats, and it doesn't make sense to build all of them into the library. If we had an extension API where someone could register something like:

id,
shouldHandleInput(input) -> bool,
toRgb(input) -> {r,g,b,a}
toString({r,g,b,a})

Then the lib could loop through extensions and send tinycolor(input) into the toRgb method if shouldHandleInput is true (which would be true for something like 0xaabbcc in a "number" extension. Then when tinycolor(0xaabbcc).toString("number") is called it would defer to the extension's implementation.

So proposed API is something like:

`tinycolor.registerFormat(id, options)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions