I would like to start a discussion on some features and proposals for the next major version of React Color. Here is what I have been thinking:
This would require a rewrite of all of the components to use react-primitives. Everything has already been written with inline styles so this will make our job much easier. Along with support for RN, I think we should introduce a few new color pickers that are prevalent in native (Snapchat, Facebook, etc..)
I propose a base component that handles the dragging and calculating of pixel values and position and leaves the translation of color spaces to the components that use it. Right now each component does a bunch of math on their own to figure this out. There have been a couple of requests (#395, #313) to create more sliders or gradient components. This would make them easier to add as well as a great common component for people to use to make their own.
The API footprint has grown quite a bit to allow for extended functionality of the swatches (#305). I propose we instead move everything over into a new Palette component like the one that @SpencerDawson has been working on and allow people to change the swatches by passing them down as children:
<SketchPicker>
<MyCustomPalette />
// or
{ colors.map((color) => (
<div style={{ background: color }} />
)) }
</SketchPicker>
I also propose that the NPM package have a dist folder with both a bundled and a minified version of react-color for use as drop in JS files. This has been requested in #310 and #364.
There is a ts definition file in definitely typed, but it is always out of date. I think we should provide both TS and Flow definition files alongside the library for people using typed environments.
Right now the documentation site uses a very janky setup that I created a long time ago. I think we should probably move it over to something that has better community support such as Gatsby. I am open to suggestions here.
@casesandberg for your color conversions, maybe colr?
EDIT: the minified version of tinycolor2 is twice the sice of Colr, and Colr, according to their benchmarks, is faster.
Per Documentation: We should use https://www.gitbook.com/ until Workbench is done
About typescript, as an author of the mentioned definitions I can provide support for these in the repo. Anyway, maybe rewriting the library in typescript wouldn't be that bad of an idea? It's just superset of javascript so current code will still be fine and would just need some types sugar. Probably won't take more than a couple of days to do that.
AH, great to hear about TypeScript! I am actually going to be kicking off the rewrite using flow, do you know if there is an easy way to sync definition files between the two?
Unfortunately there is no automated way of syncing TS and Flow easy way. At least not any popular one that works most cases. If you want to add static types to your code you should decide between the two and probably backport types definitions to the other one.
Since I don't know (yet) much about javascript or react native, I'll make this request: can you make react-color modular in such a way that app could load only selected color pickers instead of everything? Actually I don't know, if this is already possible :)
Btw comment about colr mentioned above: benchmarking on their README was done 3 years ago, according to git blame. It might still be correct, but I would not trust it without new tests.
@jomnius that is a very valid point. I missed that. ty.
I wrote some type definitions for Flow (for the current version of react-color) and put them in flow-typed in case it is of use.
Look like I missed this issue.
and please, allow me to publish it to NPM because I need it ASAP,
https://unpkg.com/@pake/react-color/
Hi. First of all nice work with color picker. It has helped our project a lot.
Do you have some estimate on when 3.0.0 would be released with flow type annotations? To me it seems that some of the annotations in flow-typed repository are no more up to date. I have already done some changes to them but I think there is still some types that are not up to date. If it looks like 3.0.0 with flow types are not going to land anytime soon I can help with updating the flow-typed annotations.
Hello!
Great work with these, they're super slick!
I was just curious if there had been an update as well to the 3.0 release, as I am hoping to use this within a react-native application. Is the 3.0 branch currently compatible?
Thanks again!
Does this work in react native?
Does this work in React Native yet?
Does this works in React Native yet or not?
Most helpful comment
Does this work in React Native yet?