Skip to content

Commit

Permalink
Exports and imports the correct one and edits the configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
margolisj committed Oct 5, 2023
1 parent 0c79b87 commit 7767d1e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/confirm-dialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ const UnconnectedConfirmDialog = (
* }
* ```
*/
const ConnectedConfirmDialog = contextConnect(
export const ConfirmDialog = contextConnect(
UnconnectedConfirmDialog,
'ConfirmDialog'
);
export default ConnectedConfirmDialog;
export default ConfirmDialog;
33 changes: 14 additions & 19 deletions packages/components/src/confirm-dialog/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,24 @@ import { useState } from '@wordpress/element';
* Internal dependencies
*/
import Button from '../../button';
import { ConfirmDialog } from '..';
import type { ConfirmDialogProps, DialogInputEvent } from '../types';
import { ConfirmDialog } from '../component';

const meta: Meta< typeof ConfirmDialog > = {
component: ConfirmDialog,
title: 'Components (Experimental)/ConfirmDialog',
argTypes: {
children: {
control: { type: 'text' },
},
confirmButtonText: {
control: { type: 'text' },
},
cancelButtonText: {
control: { type: 'text' },
},
isOpen: {
control: { type: null },
},
onConfirm: { action: 'onConfirm' },
onCancel: { action: 'onCancel' },
},
args: {
children: 'Would you like to privately publish the post now?',
},
parameters: {
actions: { argTypesRegex: '^on.*' },
controls: {
expanded: true,
},
docs: { canvas: { sourceState: 'shown' } },
},
};
Expand All @@ -48,15 +40,15 @@ const Template: StoryFn< typeof ConfirmDialog > = ( {
onConfirm,
onCancel,
...args
}: ConfirmDialogProps ) => {
} ) => {
const [ isOpen, setIsOpen ] = useState( false );

const handleConfirm = ( confirmArgs: DialogInputEvent ) => {
const handleConfirm: typeof onConfirm = ( confirmArgs ) => {
onConfirm( confirmArgs );
setIsOpen( false );
};

const handleCancel = ( cancelArgs: DialogInputEvent ) => {
const handleCancel: typeof onCancel = ( cancelArgs ) => {
onCancel?.( cancelArgs );
setIsOpen( false );
};
Expand All @@ -80,7 +72,7 @@ const Template: StoryFn< typeof ConfirmDialog > = ( {
};

// Simplest usage: just declare the component with the required `onConfirm` prop. Note: the `onCancel` prop is optional here, unless you'd like to render the component in Controlled mode (see below)
export const _default = Template.bind( {} );
export const Default = Template.bind( {} );
const _defaultSnippet = `() => {
const [ isOpen, setIsOpen ] = useState( false );
const [ confirmVal, setConfirmVal ] = useState('');
Expand Down Expand Up @@ -113,8 +105,10 @@ const _defaultSnippet = `() => {
</>
);
};`;
_default.args = {};
_default.parameters = {
Default.args = {
children: 'Would you like to privately publish the post now?',
};
Default.parameters = {
docs: {
source: {
code: _defaultSnippet,
Expand All @@ -127,6 +121,7 @@ _default.parameters = {
// To customize button text, pass the `cancelButtonText` and/or `confirmButtonText` props.
export const WithCustomButtonLabels = Template.bind( {} );
WithCustomButtonLabels.args = {
...Default.args,
cancelButtonText: 'No thanks',
confirmButtonText: 'Yes please!',
};

0 comments on commit 7767d1e

Please sign in to comment.