diff --git a/packages/components/src/color-picker/stories/index.js b/packages/components/src/color-picker/stories/index.js index 98bd612e631218..b3dfb21fb1c489 100644 --- a/packages/components/src/color-picker/stories/index.js +++ b/packages/components/src/color-picker/stories/index.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { boolean, select } from '@storybook/addon-knobs'; - /** * WordPress dependencies */ @@ -12,70 +7,35 @@ import { useState } from '@wordpress/element'; * Internal dependencies */ import { ColorPicker } from '..'; -import { Flex } from '../../flex'; -import { Spacer } from '../../spacer'; -import { space } from '../../ui/utils/space'; export default { component: ColorPicker, title: 'Components/ColorPicker', - parameters: { - knobs: { disable: false }, + argTypes: { + color: { control: { type: null } }, + copyFormat: { + control: { type: 'select' }, + options: [ 'rgb', 'hsl', 'hex', undefined ], + }, + // We can't use a `on*` regex because this component will switch to + // legacy mode when an onChangeComplete prop is passed. + onChange: { action: 'onChange' }, }, }; -const PROP_UNSET = 'unset'; - -const Example = () => { - const [ color, setColor ] = useState( undefined ); - const props = { - enableAlpha: boolean( 'enableAlpha', false ), - copyFormat: select( - 'copyFormat', - [ PROP_UNSET, 'rgb', 'hsl', 'hex' ], - PROP_UNSET - ), - }; - - if ( props.copyFormat === PROP_UNSET ) { - delete props.copyFormat; - } - - return ( - - - { color } - - - ); -}; - -export const _default = () => { - return ; -}; - -const LegacyExample = () => { - const [ legacyColor, setLegacyColor ] = useState( '#fff' ); - const legacyProps = { - color: legacyColor, - onChangeComplete: setLegacyColor, - disableAlpha: boolean( 'disableAlpha', true ), - }; +const Template = ( { onChange, ...props } ) => { + const [ color, setColor ] = useState(); return ( - - - - { JSON.stringify( legacyColor, undefined, 4 ) } - - + { + onChange( ...changeArgs ); + setColor( ...changeArgs ); + } } + /> ); }; -export const legacy = () => ; +export const Default = Template.bind( {} );
- { JSON.stringify( legacyColor, undefined, 4 ) } -