Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storybook story for text-control component #20467

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions packages/components/src/text-control/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* External dependencies
*/
import { boolean, text } from '@storybook/addon-knobs';

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

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

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

const TextControlWithState = ( props ) => {
const [ value, setValue ] = useState();

return <TextControl { ...props } value={ value } onChange={ setValue } />;
};

export const _default = () => {
const label = text( 'Label', 'Label Text' );
const hideLabelFromVision = boolean( 'Hide Label From Vision', false );
const help = text( 'Help Text', 'Help text to explain the input.' );
const type = text( 'Input Type', 'text' );
const className = text( 'Class Name', '' );

return (
<TextControlWithState
label={ label }
hideLabelFromVision={ hideLabelFromVision }
help={ help }
type={ type }
className={ className }
/>
);
};
30 changes: 30 additions & 0 deletions storybook/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7983,6 +7983,36 @@ exports[`Storyshots Components/TabPanel Default 1`] = `
</div>
`;

exports[`Storyshots Components/TextControl Default 1`] = `
<div
className="components-base-control"
>
<div
className="components-base-control__field"
>
<label
className="components-base-control__label"
htmlFor="inspector-text-control-3"
>
Label Text
</label>
<input
aria-describedby="inspector-text-control-3__help"
className="components-text-control__input"
id="inspector-text-control-3"
onChange={[Function]}
type="text"
/>
</div>
<p
className="components-base-control__help"
id="inspector-text-control-3__help"
>
Help text to explain the input.
</p>
</div>
`;

exports[`Storyshots Components/TextHighlight Default 1`] = `
Array [
"We call the new editor ",
Expand Down