Skip to content

Commit 1d8dab8

Browse files
committed
docs: Update docs
1 parent 4fb13fd commit 1d8dab8

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

README.md

+27-22
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.7 KB gzipped (JS and CSS combined)
22+
* Small size - 3.45 KB gzipped (JS and CSS combined)
2323
* Supports touch devices
2424
* Optimized animations
2525
* Ease of use
@@ -36,7 +36,7 @@ The right color picker, but not the framework you're looking for?
3636
* [React][link-react-color-picker] - you're here!
3737
* [Vue][link-vue-color-picker]
3838
* [AngularJs][link-angularjs-color-picker]
39-
* [Angular][link-angular-color-picker] (under construction)
39+
* [Angular][link-angular-color-picker]
4040

4141
## Quick Links
4242

@@ -65,22 +65,27 @@ And in your app:
6565

6666
```jsx
6767
import ColorPicker from '@radial-color-picker/react-color-picker';
68-
import '@radial-color-picker/react-color-picker/dist/react-color-picker.umd.min.css';
68+
import '@radial-color-picker/react-color-picker/dist/react-color-picker.min.css';
6969

70-
class App extends React.Component {
71-
state = {
70+
function App() {
71+
const [color, setColor] = React.useState({
7272
hue: 90,
7373
saturation: 100,
7474
luminosity: 50,
7575
alpha: 1,
76-
};
77-
78-
onChange = ({ hue, saturation, luminosity, alpha }) => {
79-
this.setState({ hue, saturation, luminosity, alpha });
76+
});
77+
78+
const onInput = hue => {
79+
setColor(prev => {
80+
return {
81+
...prev,
82+
hue,
83+
};
84+
});
8085
};
8186

8287
render() {
83-
return <ColorPicker {...this.state} onChange={this.onChange} />;
88+
return <ColorPicker {...color} onInput={onInput} />;
8489
}
8590
}
8691
```
@@ -94,16 +99,17 @@ Depending on your build tool of choice (webpack, parcel, rollup) you may have to
9499

95100
### Props
96101

97-
| Options | Type | Default/Description |
98-
|---------------|---------|---------------------|
99-
| `hue` | Number | Defaults to 0 (red color) |
100-
| `saturation` | Number | Defaults to 100 |
101-
| `luminosity` | Number | Defaults to 50 |
102-
| `alpha` | Number | Defaults to 1 |
103-
| `mouseScroll` | Boolean | Use wheel (scroll) event to rotate. Defaults to false. |
104-
| `step` | Number | Amount of degrees to rotate the picker with keyboard and/or wheel. <br> Defaults to 2 degrees. |
105-
| `onSelect` | Function | Callback which is triggered when a color is selected. |
106-
| `onChange` | Function | A function to invoke when color is changed (i.e. on rotation). |
102+
| Name | Type | Default | Description |
103+
|--------------|---------|----------------|-------------|
104+
| hue | Number | `0` | A number between `0-359`. **Required**. |
105+
| saturation | Number | `100` | A number between `0-100` |
106+
| luminosity | Number | `50` | A number between `0-100` |
107+
| alpha | Number | `1` | A number between `0-1` |
108+
| disabled | Boolean | `false` | A boolean to disable UI interactions |
109+
| step | Number | `2` | Amount of degrees to rotate the picker with keyboard and/or wheel. |
110+
| variant | String | `collapsible` | Use `persistent` to prevent collapsing/closing |
111+
| initiallyCollapsed | Boolean | `false` | Hides the palette initially |
112+
| mouseScroll | Boolean | `false` | Use wheel (scroll) event to rotate. |
107113

108114
[Back To Top](#quick-links)
109115

@@ -121,13 +127,12 @@ Depending on your build tool of choice (webpack, parcel, rollup) you may have to
121127

122128
<details>
123129
<summary>Why is the scroll-to-rotate functionality not turned on by default?</summary>
124-
<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>:mouse-scroll="true"</code>.</p>
130+
<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>
125131
</details>
126132
<br>
127133

128134
[Back To Top](#quick-links)
129135

130-
131136
## Change log
132137

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

0 commit comments

Comments
 (0)