Skip to content

Commit

Permalink
ResizableBox: Remove knobs in stories
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Dec 23, 2022
1 parent 96a8df7 commit 74d0ac4
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 99 deletions.
6 changes: 4 additions & 2 deletions packages/components/src/resizable-box/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type ResizableBoxProps = ResizableProps & {
__experimentalTooltipProps: Parameters< typeof ResizeTooltip >[ 0 ];
};

function ResizableBox(
function UnforwardedResizableBox(
{
className,
children,
Expand Down Expand Up @@ -124,4 +124,6 @@ function ResizableBox(
);
}

export default forwardRef( ResizableBox );
const ResizableBox = forwardRef( UnforwardedResizableBox );

export default ResizableBox;
97 changes: 0 additions & 97 deletions packages/components/src/resizable-box/stories/index.js

This file was deleted.

94 changes: 94 additions & 0 deletions packages/components/src/resizable-box/stories/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* External dependencies
*/
import type { ComponentMeta, ComponentStory } from '@storybook/react';

/**
* Internal dependencies
*/
import ResizableBox from '..';

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

const meta: ComponentMeta< typeof ResizableBox > = {
title: 'Components/ResizableBox',
component: ResizableBox,
argTypes: {
__experimentalShowTooltip: { control: 'boolean' },
minHeight: { control: 'number' },
minWidth: { control: 'number' },
onResizeStop: { action: 'onResizeStop' },
showHandle: { control: 'boolean' },
},
parameters: {
controls: { expanded: true },
docs: { source: { state: 'open' } },
},
};
export default meta;

const Template: ComponentStory< typeof ResizableBox > = ( {
onResizeStop,
...props
} ) => {
const [ { height, width }, setAttributes ] = useState( {
height: 200,
width: 400,
} );

return (
<ResizableBox
{ ...props }
size={ {
height,
width,
} }
onResizeStop={ ( event, direction, elt, delta ) => {
onResizeStop?.( event, direction, elt, delta );
setAttributes( {
height: height + delta.height,
width: width + delta.width,
} );
} }
/>
);
};

export const Default = Template.bind( {} );
Default.args = {
children: (
<div
style={ {
background: '#eee',
display: 'flex',
height: '100%',
width: '100%',
alignItems: 'center',
justifyContent: 'center',
} }
>
Resize
</div>
),
};

/**
* The `enable` prop can be used to disable resizing in specific directions.
*/
export const DisabledDirections = Template.bind( {} );
DisabledDirections.args = {
...Default.args,
enable: {
top: false,
right: true,
bottom: true,
left: false,
topRight: false,
bottomRight: true,
bottomLeft: false,
topLeft: false,
},
};

1 comment on commit 74d0ac4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
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/3767440895
📝 Reported issues:

Please sign in to comment.