Skip to content

Commit 2d8042a

Browse files
committed
docs: Update readme
1 parent 92777b7 commit 2d8042a

File tree

1 file changed

+16
-48
lines changed

1 file changed

+16
-48
lines changed

README.md

+16-48
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Great UX starts with two basic principles - ease of use and simplicity. Selecting a color should be as easy as moving a slider, clicking a checkbox or pressing a key just like other basic form elements behave.
2020

2121
This is a flexible and minimalistic color picker. Developed with mobile devices and keyboard usage in mind. Key features:
22-
* Small size - 3.6 KB gzipped (JS and CSS combined)
22+
* Small size - 2.9 KB gzipped (JS and CSS combined)
2323
* Supports touch devices
2424
* Optimized animations
2525
* Ease of use
@@ -38,18 +38,6 @@ The right color picker, but not the framework you're looking for?
3838
* [AngularJs][link-angularjs-color-picker]
3939
* [Angular][link-angular-color-picker]
4040

41-
## Quick Links
42-
43-
* [Demos](#demos)
44-
* [Usage](#usage)
45-
* [Options](#options)
46-
* [FAQ](#first-asked-questions)
47-
* [Change log](#change-log)
48-
* [Migration](#migration)
49-
* [Contributing](#contributing)
50-
* [Credits](#credits)
51-
* [License](#license)
52-
5341
## Demos
5442

5543
* Basic Example - [Codepen](https://codepen.io/rkunev/pen/mjKoyK/)
@@ -71,39 +59,32 @@ import ColorPicker from '@radial-color-picker/react-color-picker';
7159
import '@radial-color-picker/react-color-picker/dist/style.css';
7260

7361
function App() {
74-
const [color, setColor] = React.useState({
62+
const [color, setColor] = useState({
7563
hue: 90,
7664
saturation: 100,
7765
luminosity: 50,
7866
alpha: 1,
7967
});
8068

81-
const onInput = hue => {
82-
setColor(prev => {
83-
return {
84-
...prev,
85-
hue,
86-
};
87-
});
69+
const onInput = (hue) => {
70+
setColor((prev) => ({ ...prev, hue }));
8871
};
8972

9073
return <ColorPicker {...color} onInput={onInput} />;
9174
}
9275
```
9376

94-
Depending on your build tool of choice (webpack, parcel, rollup) you may have to setup the appropriate loaders or plugins. If you're using `create-react-app` you don't have to do anything else - it comes preconfigured and supports CSS import out of the box.
95-
96-
[Back To Top](#quick-links)
77+
Depending on your build tool of choice (vite, webpack, etc.) you may have to setup the appropriate plugins or loaders. If you're using `vite` you don't have to do anything else - it comes preconfigured and supports CSS import out of the box.
9778

9879
## Options
9980

10081
`ColorPicker` can be used either as a controlled component or as uncontrolled component.
10182
```jsx
10283
// Controlled component. Its current state is defined and updated by the props you pass to it.
103-
<ColorPicker hue={value} onInput={hue => setValue(hue)} />
84+
<ColorPicker hue={value} onInput={(hue) => setValue(hue)} />
10485

10586
// Uncontrolled component. You can use onChange to react to knob rotation stop for example.
106-
<ColorPicker onChange={hue => console.log('Current color:', hue)} />
87+
<ColorPicker onChange={(hue) => console.log('Current color:', hue)} />
10788
```
10889

10990
| Name | Type | Default | Description |
@@ -122,8 +103,6 @@ Depending on your build tool of choice (webpack, parcel, rollup) you may have to
122103
| onChange | Function | noop | Called every time the color changes, but unlike onInput this is not called while rotating the knob. |
123104
| onSelect | Function | noop | Called when the user dismisses the color picker (i.e. interacting with the middle color well). |
124105

125-
[Back To Top](#quick-links)
126-
127106
## First Asked Questions
128107

129108
<details>
@@ -146,24 +125,21 @@ Depending on your build tool of choice (webpack, parcel, rollup) you may have to
146125
<p>It's another non-passive event that could potentially introduce jank on scroll. To rotate the color knob, but stay on the same scrolling position the <code>wheel</code> event is blocked with <code>preventDefault()</code>. Thus, if you really want this feature for your users you'll have to explicitly add <code>mouseScroll={true}</code>.</p>
147126
</details>
148127

149-
<details>
150-
<summary>Why does Google Chrome throw a <code>[Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event.</code> warning in the console?</summary>
151-
<p><code>touchmove</code> is used with <code>preventDefault()</code> to block scrolling on mobile while rotating the color knob. Even the <a href="https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#removing-the-need-to-cancel-events">Web Incubator Community Group</a> acknowledges that in some cases a passive event listener can't be used.</p>
152-
</details>
153-
154128
<br>
155129

156-
[Back To Top](#quick-links)
157-
158130
## Change log
159131

160132
Please see [Releases][link-releases] for more information on what has changed recently.
161133

162-
[Back To Top](#quick-links)
163-
164134
## Migration
165135

166-
### Migration from v2
136+
### Migration from v3 to v4
137+
138+
1. In an effort of project modernization, CJS build is no longer provided. The UMD build is deprecated and will be removed in a future version.
139+
2. Non-minified builds are no longer provided. Use the minified build artifacts instead.
140+
3. The StyleSheet in the `dist` directory has been renamed from `react-color-picker.min.css` to `style.css`.
141+
142+
### Migration from v2 to v3
167143

168144
1. Double-click to move the knob to the current position of the pointer is gone since this is now the default behavior as soon as the clicks on the palette. If you had a tooltip or a help section in your app that described the shortcut you should remove it.
169145

@@ -186,7 +162,7 @@ Please see [Releases][link-releases] for more information on what has changed re
186162
/>
187163
```
188164

189-
### Migration from v1
165+
### Migration from v1 to v2
190166

191167
v2 comes with lots of performance improvements like native CSS `conic-gradient` support and lots of bugfixes, but some things were changed as well.
192168

@@ -232,25 +208,19 @@ v2 comes with lots of performance improvements like native CSS `conic-gradient`
232208
* `@keyframes color-picker-ripple` -> `@keyframes rcp-ripple`
233209
* `@keyframes color-picker-beat` -> `@keyframes rcp-beat`
234210

235-
[Back To Top](#quick-links)
236-
237211
## Contributing
238212

239213
If you're interested in the project you can help out with feature requests, bugfixes, documentation improvements or any other helpful contributions. You can use the issue list of this repo for bug reports and feature requests and as well as for questions and support.
240214

241215
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.
242216

243-
[Back To Top](#quick-links)
244-
245217
## Credits
246218

247219
- [Rosen Kanev][link-author]
248220
- [All Contributors][link-contributors]
249221

250222
This component is based on the great work that was done for the AngularJs color picker [angular-radial-color-picker][link-angularjs-color-picker].
251223

252-
[Back To Top](#quick-links)
253-
254224
## License
255225

256226
The MIT License (MIT). Please see [License File](LICENSE) for more information.
@@ -261,6 +231,4 @@ The MIT License (MIT). Please see [License File](LICENSE) for more information.
261231
[link-angularjs-color-picker]: https://github.com/talamaska/angular-radial-color-picker
262232
[link-author]: https://github.com/rkunev
263233
[link-contributors]: ../../contributors
264-
[link-releases]: ../../releases
265-
266-
[Back To Top](#quick-links)
234+
[link-releases]: ../../releases

0 commit comments

Comments
 (0)