Skip to content

Commit 67a1d75

Browse files
committed
docs: Add migration guide
1 parent e939ed2 commit 67a1d75

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The right color picker, but not the framework you're looking for?
4545
* [Options](#options)
4646
* [FAQ](#first-asked-questions)
4747
* [Change log](#change-log)
48+
* [Migration from v1](#migration-from-v1)
4849
* [Contributing](#contributing)
4950
* [Credits](#credits)
5051
* [License](#license)
@@ -139,6 +140,60 @@ Please see [Releases][link-releases] for more information on what has changed re
139140

140141
[Back To Top](#quick-links)
141142

143+
## Migration from v1
144+
145+
v2 comes with lots of performance improvements like native CSS `conic-gradient` support and lots of bugfixes, but some things were changed as well.
146+
147+
1. The UMD prefix in the CSS file name is now gone:
148+
149+
```diff
150+
- import '@radial-color-picker/react-color-picker/dist/react-color-picker.umd.min.css';
151+
+ import '@radial-color-picker/react-color-picker/dist/react-color-picker.min.css';
152+
```
153+
154+
2. The `onChange` prop is called `onInput` and `onSelect` prop is called `onChange` now. The reason for that is to align with the event names on the HTML `<input type="color">`.
155+
156+
```diff
157+
- <ColorPicker {...color} onChange={onHueChange} onSelect={onMiddleSelectorClick} />
158+
+ <ColorPicker {...color} onInput={onHueChange} onChange={onMiddleSelectorClick} />
159+
```
160+
161+
<details>
162+
<summary>Details</summary>
163+
<p>As is the case with other <code>&lt;input&gt;</code> types, there are two events that can be used to detect changes to the color value: input and change. input is fired on the <code>&lt;input&gt;</code> element every time the color changes. The change event is fired when the user dismisses the color picker.</p>
164+
<p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/color#Tracking_color_changes">Source</p>
165+
</details>
166+
167+
<br>
168+
169+
3. The `onInput` and `onChange` props were streamlined and will no longer pass the `saturation`, `luminosity` and `alpha` props back. Instead `hue` will be the only param. This reduces unneeded object creation and in certain edge-cases skips unneeded re-renders (comparing two numbers vs. two objects).
170+
171+
```diff
172+
- const onHueChange = (color) => {
173+
- setHue(color.hue);
174+
- };
175+
176+
+ const onHueChange = (hue) => {
177+
+ setHue(hue);
178+
+ };
179+
```
180+
181+
4. The internal CSS class names also changed. You should avoid relying on the inner DOM structure and CSS class names, but if you did here's a handy list of what was renamed:
182+
* `.color-picker` -> `.rcp`
183+
* `.palette` -> `.rcp__palette`
184+
* `.knob` -> `.rcp__knob`
185+
* `.rotator` -> `.rcp__rotator`
186+
* `.selector` -> `.rcp__well`
187+
* `.ripple` -> `.rcp__ripple`
188+
* `.is-in` -> `.in`
189+
* `.is-out` -> `.out`
190+
* `.is-pressed` -> `.pressed`
191+
* `.is-rippling` -> `.rippling`
192+
* `@keyframes color-picker-ripple` -> `@keyframes rcp-ripple`
193+
* `@keyframes color-picker-beat` -> `@keyframes rcp-beat`
194+
195+
[Back To Top](#quick-links)
196+
142197
## Contributing
143198

144199
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.

0 commit comments

Comments
 (0)