Skip to content

Commit

Permalink
Show props in Storybook only for new version of the component
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Mar 24, 2023
1 parent e0f60d5 commit ff362ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
9 changes: 6 additions & 3 deletions packages/components/src/color-picker/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const options = [
{ label: 'Hex', value: 'hex' as const },
];

const ColorPicker = (
const UnconnectedColorPicker = (
props: ColorPickerProps,
forwardedRef: ForwardedRef< any >
) => {
Expand Down Expand Up @@ -112,6 +112,9 @@ const ColorPicker = (
);
};

const ConnectedColorPicker = contextConnect( ColorPicker, 'ColorPicker' );
export const ColorPicker = contextConnect(
UnconnectedColorPicker,
'ColorPicker'
);

export default ConnectedColorPicker;
export default ColorPicker;
28 changes: 5 additions & 23 deletions packages/components/src/color-picker/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,26 @@
* External dependencies
*/
import type { ComponentMeta, ComponentStory } from '@storybook/react';

/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import { ColorPicker } from '..';
import { ColorPicker } from '../component';

const meta: ComponentMeta< typeof ColorPicker > = {
component: ColorPicker,
title: 'Components/ColorPicker',
argTypes: {
as: { control: { type: null } },
color: { control: { type: null } },
copyFormat: {
control: { type: 'select' },
options: [ 'rgb', 'hsl', 'hex', undefined ],
},
onChangeComplete: {
table: {
disable: true,
},
},
oldHue: {
table: {
disable: true,
},
},
disableAlpha: {
table: {
disable: true,
},
},
// We can't use a `on*` regex because this component will switch to
// legacy mode when an onChangeComplete prop is passed.
onChange: { action: 'onChange' },
},
parameters: {
actions: { argTypesRegex: '^on.*' },
controls: {
expanded: true,
},
Expand Down

0 comments on commit ff362ff

Please sign in to comment.