-
Notifications
You must be signed in to change notification settings - Fork 4.6k
components: Add new ColorPicker #33714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ef5731d
components: InputControl to TypeScript
sarayourfriend f97cc19
Add back event to onChange
sarayourfriend 0d57ecb
Convert select-control to TS and ts-nocheck the rest of color picker …
sarayourfriend 72037c9
components: Add new ColorPicker
sarayourfriend 97b51ef
Fix various visual issues and rapid color change stuttering
sarayourfriend f81bcbc
Rename to `enableAlpha` and add a README
sarayourfriend 0233254
Add copy format and better defaults
sarayourfriend a50675f
More closely mimic "half-controlled" values
sarayourfriend 597cfdf
Fix misaligned value display in Chrome
sarayourfriend e1474b6
Update react-colorful styles to better match designs
sarayourfriend 9635658
Add CHANGELOG entry for RangeControl prop update
sarayourfriend 630d060
Fix bad rebase and bad types
sarayourfriend eb5c33f
Fix html number arrows showing on Chrome
sarayourfriend f405c0a
Switch to HSL(A) based input and output to fix HSL UX
sarayourfriend 1496e0a
Move styled components and get rid of unnecessary ones
sarayourfriend 70eb0fd
Fix onChange parameter name
sarayourfriend da321a2
Add missing labels
sarayourfriend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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 hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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 hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
1 change: 1 addition & 0 deletions
1
packages/components/src/range-control/styles/range-control-styles.js
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
1 change: 1 addition & 0 deletions
1
packages/components/src/slot-fill/bubbles-virtually/slot-fill-context.js
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
1 change: 1 addition & 0 deletions
1
packages/components/src/slot-fill/bubbles-virtually/slot-fill-provider.js
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
1 change: 1 addition & 0 deletions
1
packages/components/src/slot-fill/bubbles-virtually/use-slot.js
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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,3 +1,4 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * External dependencies | ||
| */ | ||
|
|
||
This file contains hidden or 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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||||||||||||||||||
| # ColorPicker | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| <div class="callout callout-alert"> | ||||||||||||||||||||||||
| This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes. | ||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| `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/ui'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function Example() { | ||||||||||||||||||||||||
| const [color, setColor] = useState(); | ||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||
| <ColorPicker | ||||||||||||||||||||||||
| 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. | ||||||||||||||||||||||||
|
Comment on lines
+41
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: should we use the same format we've been using for newer components?
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### `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. | ||||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.