-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BoxControl
: Update story and refactor to Typescript (#56462)
* BoxControl: Update story and refactor to Typescript * Cleanup and refine story based on feedback * Add Uncontrolled and Controlled templates and Controlled example * Remove default values and fix values control
- Loading branch information
Showing
2 changed files
with
82 additions
and
75 deletions.
There are no files selected for viewing
75 changes: 0 additions & 75 deletions
75
packages/components/src/box-control/stories/index.story.js
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
packages/components/src/box-control/stories/index.story.tsx
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,82 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BoxControl from '../'; | ||
|
||
const meta: Meta< typeof BoxControl > = { | ||
title: 'Components (Experimental)/BoxControl', | ||
component: BoxControl, | ||
argTypes: { | ||
values: { control: { type: null } }, | ||
}, | ||
parameters: { | ||
actions: { argTypesRegex: '^on.*' }, | ||
controls: { expanded: true }, | ||
docs: { canvas: { sourceState: 'shown' } }, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
const TemplateUncontrolled: StoryFn< typeof BoxControl > = ( props ) => { | ||
return <BoxControl { ...props } />; | ||
}; | ||
|
||
const TemplateControlled: StoryFn< typeof BoxControl > = ( props ) => { | ||
const [ values, setValues ] = useState< ( typeof props )[ 'values' ] >(); | ||
|
||
return ( | ||
<BoxControl | ||
values={ values } | ||
{ ...props } | ||
onChange={ ( nextValue ) => { | ||
setValues( nextValue ); | ||
props.onChange?.( nextValue ); | ||
} } | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = TemplateUncontrolled.bind( {} ); | ||
Default.args = { | ||
label: 'Label', | ||
}; | ||
|
||
export const Controlled = TemplateControlled.bind( {} ); | ||
Controlled.args = { | ||
...Default.args, | ||
}; | ||
|
||
export const ArbitrarySides = TemplateControlled.bind( {} ); | ||
ArbitrarySides.args = { | ||
...Default.args, | ||
sides: [ 'top', 'bottom' ], | ||
}; | ||
|
||
export const SingleSide = TemplateControlled.bind( {} ); | ||
SingleSide.args = { | ||
...Default.args, | ||
sides: [ 'bottom' ], | ||
}; | ||
|
||
export const AxialControls = TemplateControlled.bind( {} ); | ||
AxialControls.args = { | ||
...Default.args, | ||
splitOnAxis: true, | ||
}; | ||
|
||
export const AxialControlsWithSingleSide = TemplateControlled.bind( {} ); | ||
AxialControlsWithSingleSide.args = { | ||
...Default.args, | ||
sides: [ 'horizontal' ], | ||
splitOnAxis: true, | ||
}; |
5d86605
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 5d86605.
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/6986438779
📝 Reported issues:
/test/e2e/specs/editor/various/writing-flow.spec.js