-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ResizableBox: Remove knobs in stories (#46774)
* ResizableBox: Remove knobs in stories * Show more props from types * Remove unimportant prop controls * Always enable `enable` prop * Remove `parseInt()` from readme code snippet * Hide control for `children` prop
- Loading branch information
Showing
4 changed files
with
101 additions
and
105 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 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,92 @@ | ||
/** | ||
* 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: { | ||
children: { control: { type: null } }, | ||
enable: { control: 'object' }, | ||
onResizeStop: { action: 'onResizeStop' }, | ||
}, | ||
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, | ||
}, | ||
}; |
9f54821
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 9f54821.
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/3857781982
📝 Reported issues:
specs/editor/various/multi-block-selection.test.js