-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
ColorPicker: TypeScript refactor #49214
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
106c26a
Rename tests/index
chad1008 6bda057
fix existing typos
chad1008 253e063
Type unit test utils
chad1008 b69a560
Ensure `saturation` is not null
chad1008 3b2e7c4
Consolidate type data into `types.ts`
chad1008 4875c9f
Initial updates to stories
chad1008 74ca3a9
Remove obselete `import`
chad1008 13a2081
Unit tests: add explicit check and throw error if `saturation` is `null`
chad1008 9b16f0e
Remove outdated `WordPressComponentProps` usage
chad1008 fc816d2
Type `onChange` as `Never` for `LegacyProps`
chad1008 e4f62b5
Restore default `value` in unit test constructor
chad1008 efba007
Improve unit test to check for null/undefined `pageX` and `pageY` values
chad1008 0a3c7b1
Provide expected `string` value for `color` in all unit tests
chad1008 c689dde
Hide legacy props from Storybook docs
chad1008 fc9c021
Add JSDoc descriptions to component prop types
chad1008 64cdb79
Simplify `FakeMouseEvent` constructor
chad1008 4252290
update CHANGELOG
chad1008 e0f60d5
Update docs to reflect onChange accepting a hex or hex8
chad1008 ff362ff
Show props in Storybook only for new version of the component
ciampo 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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
chad1008 marked this conversation as resolved.
Show resolved
Hide resolved
|
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ColorPicker } from '../component'; | ||
|
||
const meta: ComponentMeta< typeof ColorPicker > = { | ||
ciampo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
component: ColorPicker, | ||
title: 'Components/ColorPicker', | ||
argTypes: { | ||
as: { control: { type: null } }, | ||
color: { control: { type: null } }, | ||
}, | ||
parameters: { | ||
actions: { argTypesRegex: '^on.*' }, | ||
controls: { | ||
expanded: true, | ||
}, | ||
docs: { source: { state: 'open' } }, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
const Template: ComponentStory< typeof ColorPicker > = ( { | ||
onChange, | ||
chad1008 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
...props | ||
} ) => { | ||
const [ color, setColor ] = useState< string | undefined >(); | ||
|
||
return ( | ||
<ColorPicker | ||
{ ...props } | ||
color={ color } | ||
onChange={ ( ...changeArgs ) => { | ||
onChange?.( ...changeArgs ); | ||
setColor( ...changeArgs ); | ||
} } | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind( {} ); |
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.
onChange
previously always passed a hex8 string, but since #35562,Colord.toHex()
will return a hex or a hex8 (hex8 only if the color's alpha is < 1)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.
Nice catch, thank you!