-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the color picker component with the new version (#35220)
Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
- Loading branch information
1 parent
e839a9d
commit a969d28
Showing
38 changed files
with
299 additions
and
3,164 deletions.
There are no files selected for viewing
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
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
95 changes: 12 additions & 83 deletions
95
packages/components/src/color-palette/test/__snapshots__/index.js.snap
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,53 @@ | ||
# ColorPicker | ||
|
||
Accessible color picker. | ||
|
||
_Parts of the source code were derived and modified from [react-color](https://github.com/casesandberg/react-color/), released under the MIT license._ | ||
`ColorPicker` is a color picking component based on `react-colorful`. It lets you pick a color visually or by manipulating the individual RGB(A), HSL(A) and Hex(8) color values. | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { ColorPicker } from '@wordpress/components'; | ||
import { useState } from '@wordpress/element'; | ||
|
||
const MyColorPicker = () => { | ||
const [ color, setColor ] = useState( '#f00' ); | ||
import { ColorPicker } from '@wordpress/components/ui'; | ||
|
||
function Example() { | ||
const [color, setColor] = useState(); | ||
return ( | ||
<ColorPicker | ||
color={ color } | ||
onChangeComplete={ ( value ) => setColor( value.hex ) } | ||
disableAlpha | ||
color={color} | ||
onChange={setColor} | ||
enableAlpha | ||
defaultValue="#000" | ||
/> | ||
); | ||
}; | ||
} | ||
``` | ||
|
||
## Props | ||
|
||
### `color` | ||
|
||
**Type**: `string` | ||
|
||
The current color value to display in the picker. Must be a hex or hex8 string. | ||
|
||
### `onChange` | ||
|
||
**Type**: `(hex8Color: string) => void` | ||
|
||
Fired when the color changes. Always passes a hex8 color string. | ||
|
||
### `enableAlpha` | ||
|
||
**Type**: `boolean` | ||
|
||
Defaults to `false`. When `true` the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself. | ||
|
||
### `defaultValue` | ||
|
||
**Type**: `string | undefined` | ||
|
||
An optional default value to use for the color picker. | ||
|
||
### `copyFormat` | ||
|
||
**Type**: `'hex' | 'hsl' | 'rgb' | undefined` | ||
|
||
The format to copy when clicking the displayed color format. |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
Oops, something went wrong.