-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ColorPicker: TypeScript refactor (#49214)
* Rename tests/index * fix existing typos * Type unit test utils * Ensure `saturation` is not null * Consolidate type data into `types.ts` * Initial updates to stories * Remove obselete `import` * Unit tests: add explicit check and throw error if `saturation` is `null` * Remove outdated `WordPressComponentProps` usage * Type `onChange` as `Never` for `LegacyProps` * Restore default `value` in unit test constructor * Improve unit test to check for null/undefined `pageX` and `pageY` values * Provide expected `string` value for `color` in all unit tests * Hide legacy props from Storybook docs * Add JSDoc descriptions to component prop types * Simplify `FakeMouseEvent` constructor * update CHANGELOG * Update docs to reflect onChange accepting a hex or hex8 * Show props in Storybook only for new version of the component --------- Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
- Loading branch information
Showing
15 changed files
with
243 additions
and
183 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
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.
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 > = { | ||
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, | ||
...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.
0ce63b4
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.
Flaky tests detected in 0ce63b4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4512708200
📝 Reported issues:
/test/e2e/specs/site-editor/writing-flow.spec.js