Skip to content

Commit

Permalink
Storybook: Adds FormToggle component (#18085)
Browse files Browse the repository at this point in the history
* Add FormToggle coomponent to storybook

* Update to use example

* Update to use withState component name

* Update packages/components/src/form-toggle/stories/index.js

* Format file

* Update index.js

Co-authored-by: Grzegorz (Greg) Ziółkowski <grzegorz@gziolo.pl>
  • Loading branch information
enejb and gziolo committed Apr 17, 2020
1 parent 10e19e0 commit 63f708a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/components/src/form-toggle/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

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

export default { title: 'Components/FormToggle', component: FormToggle };

const FormToggleWithState = ( { checked, ...props } ) => {
const [ isChecked, setChecked ] = useState( checked );
return (
<FormToggle
{ ...props }
checked={ isChecked }
onChange={ () => {
setChecked( ! isChecked );
} }
/>
);
};

export const _default = () => {
return <FormToggleWithState checked />;
};

0 comments on commit 63f708a

Please sign in to comment.