-
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 1 commit
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
Switch to HSL(A) based input and output to fix HSL UX
- Loading branch information
commit f405c0aab73ea2e9e2258c2badf2090bd10e9c34
There are no files selected for viewing
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
19 changes: 0 additions & 19 deletions
19
packages/components/src/ui/color-picker/hex-color-picker.tsx
This file was deleted.
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import type { ColorFormats } from 'tinycolor2'; | ||
| import { HslColorPicker, HslaColorPicker } from 'react-colorful'; | ||
|
|
||
| interface PickerProps { | ||
| color: ColorFormats.HSL | ColorFormats.HSLA; | ||
| enableAlpha: boolean; | ||
| onChange: ( nextColor: ColorFormats.HSL | ColorFormats.HSLA ) => void; | ||
| } | ||
|
|
||
| export const Picker = ( { color, enableAlpha, onChange }: PickerProps ) => { | ||
| // RC accepts s and l as a range from 0 - 100, whereas tinycolor expects a decimal value representing the percentage | ||
| // so we need to make sure that we're giving RC the correct color format that it expects | ||
| const reactColorfulColor = { | ||
| h: color.h, | ||
| s: color.s <= 1 ? Math.floor( color.s * 100 ) : color.s, | ||
| l: color.l <= 1 ? Math.floor( color.l * 100 ) : color.l, | ||
| a: ( color as ColorFormats.HSLA ).a, | ||
| }; | ||
|
|
||
| const Component = enableAlpha ? HslaColorPicker : HslColorPicker; | ||
|
|
||
| return <Component color={ reactColorfulColor } onChange={ onChange } />; | ||
| }; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed a minor UX improvement that we could make:
This to say, should we use a timer to unset the
copiedColorafter some time has passed?