-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V2 Proposal: Color models #11
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I would make the default export color mode HEX, even though it's the heaviest one, it looks like the most used one. It's always nice if you can use the library without looking at the docs. In terms of the color modes API — it looks ok! We can actually go deeper in terms of the DX, providing the following API: import ColorPicker from "react-colorful/hsv";
<ColorPicker color={hsv} /> |
hi @omgovich |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal:
Provide the support of HSL, RGB, and HSV input/output formats without affecting the bundle size (which is ~1,47 KB now).
The most popular React color pickers just include a color conversion library (like
TinyColor
) and use it for detection and conversion. But the cost of this kind of library is 10KB or more.I would like to make react-colorful modular in order to be able to add more input/output color formats if someone will ask about that. And I want to keep the picker's bundle light — no matter how many color models it supports.
Proposal
Provide different color models using additional imports. Example:
In this PR I already implemented sources and a build script for 6 different color models:
Problem
I want to make the library modular, but I don't want to make DX worse.
So it's hard to decide what should be the default state of the bundle:
I'm pretty sure that the most popular color model is HEX, but it's the heaviest one in terms of code size:
Here is a benchmark:
Bundle size when a default color model is included by default:
Bundle size without any default color model (will crash if a user forgets to import a color model and pass it to
colorModel
prop):